Skip to content

Commit bb75d86

Browse files
committed
start of the writing of a separated standalone compilable file
1 parent a440cbb commit bb75d86

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

prolog/metta_lang/metta_compiler.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,7 @@
17831783
compiler_assertz(InfoC).
17841784

17851785
compiler_assertz(Info):-
1786+
send_to_pl_file(Info),
17861787
once(try_optimize_prolog(ca,Info,Info2)),
17871788
Info\=@=Info2,!,
17881789
info_identity(Info,Id),
@@ -1793,7 +1794,6 @@
17931794
compiler_assertz(Info):-
17941795
once(unnumbervars_clause(Info,Assert)),
17951796
transpiler_debug(2,output_prolog(Info)),
1796-
send_to_pl_file(Info),
17971797
once(locally_clause_asserted(Assert)->true;assertz(Assert)),!.
17981798

17991799

prolog/metta_lang/metta_debug.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,12 +1057,12 @@
10571057
debug_info_filtered( Topic, Info, [How,showall,Topic]):- (filter_matches_var(showall,Topic, How); filter_matches_var(showall,Info, How)),!.
10581058
debug_info_filtered( Topic,_Info,fail(dont_show_any_qcompile(Topic))):- is_qcompiling, dont_show_any_qcompile,!.
10591059
% Roy requested to make it easy to hide stdlib building in transpiler
1060-
debug_info_filtered( Topic,_Info,fail(currently_stdlib1(Topic,How))):- currently_stdlib, (filter_matches_var(hideall,stdlib,How); filter_matches_var(hide,stdlib,How)),!.
10611060
debug_info_filtered( Topic,_Info,fail(currently_stdlib2(Topic))):- currently_stdlib, !, \+ filter_matches_var(showall,stdlib,_), \+ filter_matches_var(show,stdlib,_),!.
1061+
%debug_info_filtered( Topic,_Info,fail(currently_stdlib1(Topic,How))):- currently_stdlib, (filter_matches_var(hideall,stdlib,How); filter_matches_var(hide,stdlib,How)),!.
10621062
debug_info_filtered( Topic,_Info, [How,show=Topic]):- filter_matches_var(show, Topic, How), !.
1063-
debug_info_filtered( Topic,_Info, fail([default,hide,Topic])):- option_value(filter_default,Show), Show==hide, !.
1063+
debug_info_filtered( Topic,_Info, fail([default,hide,Topic])):- option_value(default_show_hide,Show), Show==hide, !.
10641064
debug_info_filtered( Topic,_Info, fail([hide=Topic,How])):- filter_matches_var(hide, Topic, How), !.
1065-
debug_info_filtered( Topic,_Info, [show,Topic,'']):- option_value(filter_default,Show), Show==show, !.
1065+
debug_info_filtered( Topic,_Info, [show,Topic,'']):- option_value(default_show_hide,Show), Show==show, !.
10661066
%debug_info_filtered( Topic, Info):- some_debug_show(Why,Topic), !, debug_info_now([Why,Topic], Info),!.
10671067
%debug_info_filtered( Topic, Info, [unfiltered_topic_and_info,Topic]):- unfiltered_topic_and_info( Topic, Info),!.
10681068
%debug_info_filtered( Topic,_,fail(unfiltered_topic_and_info(Topic))).
@@ -1109,7 +1109,7 @@
11091109
%number_vars_wo_conficts1(Info,RNVInfo),
11101110
if_t(var(RNVInfo),Info=RNVInfo),
11111111
(should_comment(Topic, Info) ->
1112-
nop(format(X,'/* ~@: ~@ */~n',[maybe_ansicall(TopicColor,write(TopicStr)),maybe_ansicall(InfoColor,w_no_crlf(debug_pp_info(RNVInfo)))]));
1112+
format(X,'/* ~@: ~@ */~n',[maybe_ansicall(TopicColor,write(TopicStr)),maybe_ansicall(InfoColor,w_no_crlf(debug_pp_info(RNVInfo)))]);
11131113
format(X,'% ~@:~n~@ ~n',[maybe_ansicall(TopicColor,write(TopicStr)),maybe_ansicall(InfoColor,w_no_crlf(debug_pp_info(RNVInfo)))]))
11141114
)))).
11151115

prolog/metta_lang/metta_interp.pl

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,12 +1569,20 @@
15691569
on_set_value(_Note,abort_trace,true):- nocut, ignore(abort_trace),!.
15701570

15711571
on_set_value(_Note,show, Value):-
1572-
if_t( \+ prolog_debug:debugging(filter_default,_,_), set_option_value(filter_default,hide)),
1572+
if_t( \+ option_value(default_show_hide,_), set_option_value(default_show_hide,hide)),
15731573
listify(Value,List), maplist(set_tf_debug(true),List).
15741574
on_set_value(_Note,hide,Value):-
1575-
if_t( \+ prolog_debug:debugging(filter_default,_,_), (set_option_value(filter_default,show))),
1575+
if_t( \+ option_value(default_show_hide,_), (set_option_value(default_show_hide,show))),
15761576
listify(Value,List), maplist(set_tf_debug(false),List).
15771577

1578+
on_set_value(_Note,trace, Value):-
1579+
if_t( \+ option_value(default_trace_notrace,_), set_option_value(default_trace_notrace,notrace)),
1580+
listify(Value,List), maplist(set_tf_debug(true),List).
1581+
on_set_value(_Note,notrace,Value):-
1582+
if_t( \+ option_value(default_trace_notrace,_), (set_option_value(default_trace_notrace,trace))),
1583+
listify(Value,List), maplist(set_tf_debug(false),List).
1584+
1585+
15781586
on_set_value(_Note,log,true):-
15791587
% Switch to mettalog mode if 'log' is set to true.
15801588
switch_to_mettalog,!.
@@ -1833,7 +1841,7 @@
18331841
%
18341842
user_io(G) :-
18351843
% Execute the goal using the user_io_0/1 helper.
1836-
notrace(user_io_0(G)).
1844+
user_io_0(G).
18371845

18381846
%! user_io_0(:Goal) is det.
18391847
%
@@ -4132,7 +4140,7 @@
41324140
% Pass the components to `load_hook1/5` for further processing.
41334141
load_hook1(Load, Self, [Eq, H, B]).
41344142

4135-
load_hook0(Load, Assertion) :- fail,
4143+
load_hook0(Load, Assertion) :-
41364144
% Extract components of the assertion using `assertion_hb/5`.
41374145
once(assertion_fact(Assertion, Self, Fact)), !,
41384146
% Pass the components to `load_hook1/5` for further processing.
@@ -4157,10 +4165,12 @@
41574165
% load_hook1(_Load, '&corelib', _Eq, _H, _B) :- !.
41584166

41594167
metta_asserted_hook(_Load, Self, [Eq,H,B]):- Eq == '=', compiler_assertz(metta_function_asserted(Self,H,B)),!.
4160-
metta_asserted_hook(_Load, Self, StuffHook):- send_to_pl_file(metta_other_asserted(Self,StuffHook)),!.
4168+
%metta_asserted_hook(_Load, Self, [Eq,H,B]):- Eq == 'ALT=', compiler_assertz(metta_function_asserted(Self,H,B)),!.
4169+
metta_asserted_hook(_Load, Self, StuffHook):- compiler_assertz( metta_other_asserted(Self,StuffHook)). %send_to_pl_file( metta_other_asserted(Self,StuffHook)))),!.
41614170

41624171
load_hook1(Load, Self, StuffHook) :-
4163-
once(metta_asserted_hook(Load, Self, StuffHook)), fail.
4172+
metta_asserted_hook(Load, Self, StuffHook), fail.
4173+
41644174
load_hook1(Load, Self, Fact) :-
41654175
% Ensure the Metta compiler is ready for use.
41664176
once(use_metta_compiler),!,
@@ -4184,7 +4194,8 @@
41844194

41854195
:- dynamic(did_load_hook_compiler/3).
41864196

4187-
load_hook_compiler(Load, Self, Assertion):- \+ \+ ((did_load_hook_compiler(Load, Self, Assertion1),Assertion1=@=Assertion)),!,
4197+
load_hook_compiler(Load, Self, Assertion):-
4198+
\+ \+ ((did_load_hook_compiler(Load, Self, Assertion1),Assertion1=@=Assertion)),!,
41884199
%debug_info(skip_load_repeated_hook_compiler(Load, Self, Assertion)),!.
41894200
debug_info(skip_2nd(Load, Self, Assertion)),!.
41904201
load_hook_compiler(Load, Self, Assertion):-
@@ -7255,9 +7266,10 @@
72557266
% is allowed, it handles modifications to `system:notrace/1` to customize its behavior.
72567267
%
72577268

7258-
nts1 :- !. % Disable redefinition by cutting execution.
7269+
%nts1 :- !. % Disable redefinition by cutting execution.
72597270
nts1 :- is_flag(notrace),!.
72607271
nts1 :- no_interupts(nts1r).
7272+
%nts1r :- !. % Disable redefinition by cutting execution.
72617273
nts1r :-
72627274
% Redefine the system predicate `system:notrace/1` to customize its behavior.
72637275
redefine_system_predicate(system:notrace/1),

prolog/metta_lang/metta_loader.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,15 +2094,15 @@
20942094
% Register the file as loaded in the knowledge base.
20952095
pfcAdd_Now(user:loaded_into_kb(Self, Filename)),
20962096
% Process each buffered expression.
2097-
(forall(
2097+
user_io(((forall(
20982098
user:metta_file_buffer(0, _Ord, _Kind, Expr, NamedVarsList, Filename, LineCount),
20992099
(must_det_lls(maybe_name_vars(NamedVarsList)),
21002100
with_option(loading_file, Filename,
21012101
with_option(file_loc, LineCount,
21022102
(
21032103
(must_det_lls(do_metta(file(Filename), Mode, Self, Expr, _O)) -> true
21042104
; (ignore(rtrace(do_metta(file(Filename), Mode, Self, Expr, _O2))),
2105-
trace, pp_m(unknown_do_metta(file(Filename), Mode, Self, Expr)))))))))).
2105+
trace, pp_m(unknown_do_metta(file(Filename), Mode, Self, Expr)))))))))))).
21062106

21072107

21082108
%! is_file_stream_and_size(+Stream, -Size) is nondet.

prolog/metta_lang/metta_transpiled_header.pl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,19 @@
3131
:-dynamic(pred_uses_fallback/2).
3232
:-dynamic(pred_uses_impl/2).
3333

34+
:- dynamic(metta_function_asserted/3).
35+
:- multifile(metta_function_asserted/3).
36+
:- dynamic(metta_other_asserted/2).
37+
:- multifile(metta_other_asserted/2).
38+
:- dynamic(metta_function_asserted/3).
39+
:- multifile(metta_function_asserted/3).
40+
:- dynamic(metta_atom_asserted/2).
41+
:- multifile(metta_atom_asserted/2).
42+
:- dynamic(metta_atom_deduced/2).
43+
:- multifile(metta_atom_deduced/2).
44+
:- dynamic(metta_atom_in_file/2).
45+
:- multifile(metta_atom_in_file/2).
46+
:- dynamic(metta_atom_asserted_last/2).
47+
:- multifile(metta_atom_asserted_last/2).
48+
49+

0 commit comments

Comments
 (0)