47 '$convert_for_export'/6,
50 '$get_undefined_pred'/4,
51 '$imported_predicate'/4,
57 '$module_expansion'/6,
58 '$module_transparent'/2,
59 '$module_transparent'/4]).
63:-
'$c_built_in'/3
use_system_module(
'$_arith', []).
65:-
'$lf_opt'/3
'$load_files'/3
use_system_module(
'$_consult', [,
68:-
'$skipeol'/1
use_system_module(
'$_debug', []).
70:-
'$do_error'/2
use_system_module(
'$_errors', []).
72:-
'$full_clause_optimisation'/4
use_system_module(
'$_eval', []).
74:-
multifile '$system_module'/1.
77:-
'$purge_clauses'(module(
_,
_), prolog).
78:-
'$purge_clauses'(
'$module'(
_,
_), prolog).
79:-
'$purge_clauses'(use_module(
_), prolog).
80:-
'$purge_clauses'(use_module(
_,
_), prolog).
237 load_files(
F, [if(not_loaded),must_be_module(true),imports(
Is)] ).
239'$module'(
O,
N,
P,
Opts)
:- '$module',
241 '$process_module_decls_options'(
Opts,module(
Opts,
N,
P)).
244'$process_module_decls_options'(
Var,
Mod)
:-
246 '$do_error'(instantiation_error,
Mod).
247'$process_module_decls_options'([],
_)
:- '$process_module_decls_options'.
248'$process_module_decls_options'([
H|L],
M)
:- '$process_module_decls_options',
249 '$process_module_decls_option'(
H,
M),
250 '$process_module_decls_options'(
L,
M).
251'$process_module_decls_options'(
T,
M)
:-
252 '$do_error'(type_error(list,
T),
M).
254'$process_module_decls_option'(
Var,
M)
:-
256 '$do_error'(instantiation_error,
M).
257'$process_module_decls_option'(
At,
M)
:-
260'$process_module_decls_option'(library(
L),
M)
:- '$process_module_decls_option',
262'$process_module_decls_option'(hidden(
Bool),
M)
:- '$process_module_decls_option',
263 '$process_hidden_module'(
Bool,
M).
264'$process_module_decls_option'(
Opt,
M)
:-
265 '$do_error'(domain_error(module_decl_options,
Opt),
M).
267'$process_hidden_module'(
TNew,
M)
:-
268 '$convert_true_off_mod3'(
TNew,
New,
M),
270 '$prepare_restore_hidden'(
Old,
New).
272'$convert_true_off_mod3'(true, off,
_)
:- '$convert_true_off_mod3'.
273'$convert_true_off_mod3'(false, on,
_)
:- '$convert_true_off_mod3'.
274'$convert_true_off_mod3'(
X,
_,
M)
:-
275 '$do_error'(domain_error(module_decl_options,hidden(
X)),
M).
277'$prepare_restore_hidden'(
Old,
Old)
:- '$prepare_restore_hidden'.
278'$prepare_restore_hidden'(
Old,
New)
:-
279 recorda(
'$system_initialization', source_mode(
New,
Old),
_).
282'$extend_exports'(
HostF,
Exports,
DonorF )
:-
283 (
recorded(
'$module',
'$module'(
DonorF,
DonorM,
_,
DonorExports,
_),
_)
-> recorded
; DonorF = recorded ),
284 (
recorded(
'$module',
'$module'(
HostF,
HostM,
SourceF,
AllExports,
Line),
R)
-> erase(
R)
; HostF = erase,
AllExports=[] ),
285 '$convert_for_export'(
Exports,
DonorExports,
DonorM,
HostM,
_TranslationTab,
AllReExports),
286 '$convert_for_export'
:append(
AllReExports,
AllExports,
Everything0 ),
287 '$sort'(
Everything0,
Everything ),
289 recorda(
'$module',
'$module'(
HostF,
HostM,
SourceF,
Everything,
Line),
_).
291'$module_produced by'(
M,
M0,
N,
K)
:-
292 recorded(
'$import',
'$import'(
M,
M0,
_,
_,
N,
K),
_),
recorded.
293'$module_produced by'(
M,
M0,
N,
K)
:-
294 recorded(
'$import',
'$import'(
MI,
M0,
G1,
_,
N,
K),
_),
296 '$module_produced by'(
M,
MI,
N1,
K1).
312 '$yap_strip_module'(
F,
M1,
F1),
316 '$use_module'(
M,
M1,
Is).
321'$use_module'(
M,
M1,
Is)
:-
322 recorded(
'$module',
'$module'(
F,
M,
_,
_,
_),
_),
324 load_files(
M1:F, [if(not_loaded),must_be_module(true),imports(
Is)]).
325'$use_module'(
M,
M1,
Is)
:-
328 load_files(
M1:M, [if(not_loaded),must_be_module(true),imports(
Is)]).
329'$use_module'(
M,
F,
Is)
:-
330 '$do_error'(error(instantiation_error, use_module(
M,
F,
Is))).
343 '$all_current_modules'(
Mod),
344 \+ '$hidden_atom'(
Mod).
351 (
atom(
Mod)
-> atom
; '$all_current_modules'(
Mod) ),
352 (
recorded(
'$module',
'$module'(
TFN,
Mod,
_,
_Publics,
_),
_)
-> recorded
; TFN = recorded ).
355 (
atom(
Mod)
-> atom
; '$all_current_modules'(
Mod) ),
356 '$is_system_module'(
Mod).
359 open(
'P0:debug', append,
S),
360 fornat(
S,
'~w~n', [
X]),
364'$trace_module'(
X,
Y)
:- X==Y,
'$trace_module'.
365'$trace_module'(
X,
Y)
:-
367 tell(
'~/.dbg.modules'),
368 write(
'***************'),
write,
380'$continue_imported'(
Mod,
Mod,
Pred,
Pred)
:-
381 '$pred_exists'(
Pred,
Mod),
383'$continue_imported'(
FM,
Mod,
FPred,
Pred)
:-
384 recorded(
'$import',
'$import'(
IM,
Mod,
IPred,
Pred,
_,
_),
_),
385 '$continue_imported'(
FM,
IM,
FPred,
IPred),
'$continue_imported'.
386'$continue_imported'(
FM,
Mod,
FPred,
Pred)
:-
387 '$continue_imported'
:'$parent_module'(
Mod,
IM),
388 '$continue_imported'(
FM,
IM,
FPred,
Pred).
402'$declare_module'(
Name,
_Super,
Context,
_File,
_Line)
:-
403 addi_mport_module(
Name,
Context, start).
416 '$current_predicate'(
Na,
Mod,
S,
_),
424 '$do_error'(instantiation_error,export(
Resource)).
426export([
Resource| Resources])
:- export,
427 export_resource(
Resource),
430 export_resource(
Resource).
432export_resource(
Resource)
:-
434 '$do_error'(instantiation_error,export(
Resource)).
437 '$current_module'(
Mod),
439 recorded(
'$module',
'$module'(
File,
Mod,
SourceF,
ExportedPreds,
Line),
R)
442 lists
:member(
P,
ExportedPreds)
447 recorda(
'$module',
'$module'(
File,
Mod,
SourceF,[
P|ExportedPreds],
Line),
_)
453 recorda(
'$module',
'$module'(
File,
Mod,
SourceF,[
P],
Line),
_)
455 recorda(
'$module',
'$module'(user_input,
Mod,user_input,[
P],
1),
_)
458export_resource(
P0)
:-
459 P0 = F//N,
atom(
F),
number(
N),
N >= 0,
number,
462export_resource(op(
Prio,
Assoc,
Name))
:-
463 '$current_module'(
Mod),
464 op(
Prio,
Assoc,
Mod:Name),
467 recorded(
'$module',
'$module'(
File,
Mod,
SourceF,
ExportedPreds,
Line),
R)
470 lists
:delete(
ExportedPreds, op(
OldPrio,
Assoc,
Name),
Rem)
480 Update = ,
Rem = ExportedPreds
489 recorda(
'$module',
'$module'(
File,
Mod,
SourceF,[op(
Prio,
Assoc,
Name)
|Rem],
Line ),
_)
493 recorda(
'$module',
'$module'(
File,
Mod,
SourceF,[op(
Prio,
Assoc,
Name)],
Line),
_)
495 recorda(
'$module',
'$module'(user_input,
Mod,user_input,[op(
Prio,
Assoc,
Name)],
1),
_)
497export_resource(
Resource)
:-
498 '$do_error'(type_error(predicate_indicator,
Resource),export(
Resource)).
500export_list(
Module,
List)
:-
501 recorded(
'$module',
'$module'(
_,
Module,
_,
List,
_),
_).
504'$add_to_imports'([],
_,
_).
506'$add_to_imports'([
T|_Tab],
Module,
ContextModule)
:-
507 '$do_import'(
T,
Module,
ContextModule),
509'$add_to_imports'([
_T|Tab],
Module,
ContextModule)
:-
510 '$add_to_imports'(
Tab,
Module,
ContextModule).
512'$do_import'(op(
Prio,
Assoc,
Name),
Mod,
ContextMod)
:-
514 op(
Prio,
Assoc,
ContextMod:Name),
515 op(
Prio,
Assoc,
Mod:Name),
517'$do_import'(
N0/K-N1/K,
M0,
M1)
:-
519 once(
'$check_import'(
M1,
M0,
N1,
K)),
529 '$proxy_predicate'(
G1,
M1),
532'$follow_import_chain'(prolog,
G,prolog,
G)
:- '$follow_import_chain'.
533'$follow_import_chain'(
ImportingM,
G,
M0,
G0)
:-
534 recorded(
'$import',
'$import'(
ExportingM1,
ImportingM,
G1,
G,
_,
_),
_),
recorded,
535 '$follow_import_chain'(
ExportingM1,
G1,
M0,
G0).
536'$follow_import_chain'(
M,
G,
M,
G).
538'$import_chain'(prolog,
_G,
_,
_)
:- '$import_chain'.
539'$import_chain'(
M,
_G,
M,
_G).
540'$import_chain'(
ImportingM,
G,
M0,
G0)
:-
541 recorded(
'$import',
'$import'(
ExportingM1,
ImportingM,
G1,
G,
_,
_),
_),
542 '$import_chain'(
ExportingM1,
G1,
M0,
G0).
546'$check_import'(prolog,
_ContextM,
_N,
_K)
:-
549'$check_import'(
M,
M,
_N,
_K)
:-
552'$check_import'(
_,
_,
N,
K)
:-
556'$check_import'(
M0,
M1,
N,
K)
:-
557 recorded(
'$import',
'$import'(
M2,
M1,
_,
_,
N,
K),
_R),
561 '$redefine_import'(
M2,
M1,
M0,
N/K)
563 '$check_import'(
M0,
M2,
N,
K)
565'$check_import'(
_,
_,
_,
_).
567'$redefine_import'(
M1,
M2,
Mod,
ContextM,
N/K)
:-
568 '__NB_getval__'(
'$lf_status',
TOpts, fail),
569 '$lf_opt'(redefine_module,
TOpts,
Action),
'$lf_opt',
570 '$redefine_action'(
Action,
M1,
M2,
Mod,
ContextM,
N/K).
571'$redefine_import'(
M1,
M2,
Mod,
ContextM,
N/K)
:-
572 '$redefine_action'(false,
M1,
M2,
Mod,
ContextM,
N/K).
575'$redefine_action'(ask,
M1,
M2,
M,
_,
N/K)
:-
577 format(user_error,
'NAME CLASH: ~w was already imported to module ~w;~n',[
M1:N/K,
M2]),
578 format(user_error,
' Do you want to import it from ~w ? [y, n, e or h] ',
M),
580 (
C == e
-> halt(
1)
;
582'$redefine_action'(true,
M1,
_,
_,
_,
_)
:- '$redefine_action',
583 recorded(
'$module',
'$module'(
F,
M1,
_,
_MyExports,
_Line),
_),
585'$redefine_action'(false,
M1,
M2,
_M,
ContextM,
N/K)
:-
586 recorded(
'$module',
'$module'(
F,
ContextM,
_,
_MyExports,
_Line),
_),
587 '$current_module'(
_,
M2),
588 '$do_error'(permission_error(import,
M1:N/K,redefined,
M2),
F).
593 (
C == y
-> true
; C == n).
608 var(
ExportingModule),
609 '$do_error'(instantiation_error,set_base_module(
ExportingModule)).
611 atom(
ExportingModule),
atom,
612 '$current_module'(
Mod),
614 asserta(prolog
:'$parent_module'(
Mod,
ExportingModule)).
616 '$do_error'(type_error(atom,
ExportingModule),set_base_module(
ExportingModule)).
631 '$do_error'(instantiation_error,import_module(
Mod,
ImportModule)).
634 atom
:'$parent_module'(
Mod,
ImportModule).
636 '$do_error'(type_error(atom,
Mod),import_module(
Mod,
EM)).
652 '$do_error'(instantiation_error,add_import_module(
Mod,
ImportModule,
Pos)).
655 '$do_error'(instantiation_error,add_import_module(
Mod,
ImportModule,
Pos)).
658 retractall(prolog
:'$parent_module'(
Mod,
ImportModule)),
659 asserta(prolog
:'$parent_module'(
Mod,
ImportModule)).
662 retractall(prolog
:'$parent_module'(
Mod,
ImportModule)),
663 assertz(prolog
:'$parent_module'(
Mod,
ImportModule)).
666 '$do_error'(type_error(atom,
Mod),add_import_module(
Mod,
ImportModule,
Pos)).
668 '$do_error'(domain_error(start_end,
Pos),add_import_module(
Mod,
ImportModule,
Pos)).
681 '$do_error'(instantiation_error,delete_import_module(
Mod,
ImportModule)).
684 '$do_error'(instantiation_error,delete_import_module(
Mod,
ImportModule)).
687 atom(
ImportModule),
atom,
688 retractall(prolog
:'$parent_module'(
Mod,
ImportModule)).
691 '$do_error'(type_error(atom,
Mod),delete_import_module(
Mod,
ImportModule)).
693 '$do_error'(type_error(atom,
ImportModule),delete_import_module(
Mod,
ImportModule)).
695'$set_source_module'(
Source0,
SourceF)
:-
698'$set_source_module'(
Source0,
SourceF)
:-
718module_property(
Mod,
Prop)
:-
721 recorded(
'$module',
'$module'(
_,
Mod,
_,
_Es,
_),
_),
723module_property(
Mod, class(
L))
:-
724 '$module_class'(
Mod,
L).
725module_property(
Mod, line_count(
L))
:-
726 recorded(
'$module',
'$module'(
_F,
Mod,
_,
_,
L),
_).
727module_property(
Mod, file(
F))
:-
728 recorded(
'$module',
'$module'(
F,
Mod,
_,
_,
_),
_).
729module_property(
Mod, exports(
Es))
:-
731 recorded(
'$module',
'$module'(
_,
Mod,
_,
Es,
_),
_)
737 findall(
P, (current_predicate(user
:P)),
Es)
741 findall(
N/A, (predicate_property(
Mod:P0,
public),functor(
P0,
N,
A)),
Es)
744'$module_class'(
Mod, system)
:- '$is_system_module'(
Mod ),
'$is_system_module'.
745'$module_class'(
Mod, library)
:- '$library_module'(
Mod ),
'$library_module'.
746'$module_class'(
_Mod, user)
:- '$module_class'.
747'$module_class'(
_, temporary)
:- '$module_class'.
748'$module_class'(
_, test)
:- '$module_class'.
749'$module_class'(
_, development)
:- '$module_class'.
751'$library_module'(
M1)
:-
752 recorded(
'$module',
'$module'(
_,
M1, library(
_),
_MyExports,
_Line),
_).
755 recorded(
'$import',
'$import'(
M0,
M,
G0,
G,
_N,
_K),
_R),
757 format(
'~a:~w <- ~a:~w~n', [
M,
G,
M0,
G0]),
762 recorded(
'$mf',
meta_predicate(
Mod,
_P),
_,
R),
766 recorded(
'$multifile_defs',
'$defined'(
_FileName,
_Name,
_Arity,
Mod),
R),
770 recorded(
'$foreign',
Mod:_Foreign,
R),
775 setof(
M, recorded(
'$import',
_G0^_G^_N^_K^_R^'$import'(
Mod,
M,
_G0,
_G,
_N,
_K),
_R),
Ms),
776 recorded(
'$module',
'$module'(
_,
Mod,
_,
_,
Exports),
_),
779 current_op
:member( op(
X,
Y,
Op),
Exports ),
783 recorded(
'$module',
'$module'(
_,
Mod,
_,
_,
Exports),
_),
784 recorded
:member( op(
X,
_Y,
Op),
Exports ),
792 recorded(
'$import',
'$import'(
Mod,
_M,
_G0,
_G,
_N,
_K),
R),
796 recorded(
'$module',
'$module'(
_,
Mod,
_,
_,
_),
R),
802 recorded(
'$module',
'$module'(
HostF,
HostM,
SourceF,
Everything,
Line),
_),
804 format(
'%%%%%%~n ~a,~n%% at ~w,~n%% loaded at ~a:~d,~n%% Exporlist ~w.~nImports~n:', [
HostM,
SourceF,
HostF,
Line,
Everything]),
806 recorded(
'$import',
'$import'(
M,
HostM,
_G,
_GO,
N,
K),
_R),
807 format(
'% ~w:~a/~d:.~n',[
M,
N,
K])
809 format(
'%%%%%%~nExports~n:', []),
810 recorded(
'$import',
'$import'(
HostM,
M,
_G,
_GO,
N,
K),
_R),
811 format(
'% ~w:~a/~d:.~n',[
M,
N,
K])
816:-
recorda(
'$module',
'$module'(user,user,user,[],
1),
_).
819
start input for a meta-clause
stream_property( Stream, Prop )
add_import_module( + Module, + ImportModule , +_Pos_)
current_module( ? Mod:atom)
current_module( ? Mod:atom, ? F : file )
delete_import_module( + ExportModule, + ImportModule )
import_module( +ImportingModule, +ExportingModule )
module_property( +Module, ? Property )
set_base_module( +Expor tingModule )
use_module(+Files, +Imports)
current_prolog_flag(? Flag,- Value)
set_prolog_flag(+ Flag,+ Value)
load_files(+_Files_, +_Options_)
prolog_load_context(? Key, ? Value)
numbervars( t,+ _N1,- Nn)
append(? List1,? List2,? List3)
delete(+ List, ? Element, ? Residue)
member(?Element, ?Set) is true when Set is a list, and Element occurs in it