diff --git a/C/terms.c b/C/terms.c index a255881e7..ace0d9a6e 100644 --- a/C/terms.c +++ b/C/terms.c @@ -1380,9 +1380,10 @@ static Int t_ref(cl_connector *d, cl_connector * q, int max) { static Int create_entry(Term t, Int i, Int j, cl_connector * q, Int max) { Term ref, h, *s, *ostart; - bool pair = false; ssize_t n; // first time, create a new term + if (i==0) + return 0; if (IsVarTerm(t)) { return -1; } @@ -1393,7 +1394,6 @@ static Int create_entry(Term t, Int i, Int j, cl_connector * q, Int max) { return t_ref((cl_connector*)AtomOfTerm(h),q,max); } n = 2; - pair = true; ostart = HR; ref = AbsPair(ostart); HR += 2; @@ -1439,12 +1439,19 @@ Int cp_link(Term t, Int i, Int j, cl_connector * q, Int max, CELL * tailp) { Term ref = Deref(q[me].reference); if (IsVarTerm(ref)) { q[i].copy[j] = ref; - } else { - q[i].copy[j] = - q[me].parent[0] = - UNFOLD_LOOP(ref, tailp); + } else if (i == 0){ + Term p = TermNil; + Term v = UNFOLD_LOOP(ref,&p); + q[i].reference = HeadOfTerm(p); + q[i].copy[j] = v; } - return max; + else if (tailp && q[me].parent) { + Term v = UNFOLD_LOOP(ref, tailp); + q[i].copy[j] = v; + q[me].parent[0] = v; + q[i].reference = v; + } + return max; } q[i].copy[j] = t; return me; diff --git a/pl/boot.yap b/pl/boot.yap index 3e6660197..89188051e 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -28,6 +28,25 @@ */ +print_message(informational,_) :- + yap_flag(verbose, silent), + !. +print_message(informational,E) :- + format('informational message ~q.~n',[E]), + !. +%% +% boot:print_message( Type, Error ) +% +print_message(Type,error(error(_,_),exception(Desc))) :- + !, + '$print_exception'(Desc). +print_message(Type,error(warning(_,_),exception(Desc))) :- + !, + '$print_exception'(Desc). +print_message(Type,Error) :- + format( user_error, '~w while bootstraping: event is ~q~n',[Type,Error]). + + /** * @pred system_module( _Mod_, _ListOfPublicPredicates, ListOfPrivatePredicates * * Define a system module _Mod_. _ListOfPublicPredicates_ . Currentlt, all @@ -63,6 +82,10 @@ private(_). % boootstrap predicates. % :- system_module( '$_boot', [ + !/0, + ':-'/1, + '?-'/1, + []/0, bootstrap/1, call/1, catch/3, @@ -76,12 +99,7 @@ private(_). (not)/1, repeat/0, throw/1, - true/0]). - -:- system_module( '$_init', [!/0, - ':-'/1, - '?-'/1, - []/0, + true/0, extensions_to_present_answer/1, fail/0, false/0, @@ -94,34 +112,12 @@ private(_). '$do_log_upd_clause'/6, '$do_log_upd_clause0'/6, '$do_log_upd_clause_erase'/6, - '$do_static_clause'/5], + '$do_static_clause'/5, '$system_module'/1]). -:- use_system_module( '$_boot', ['$cut_by'/1]). % be careful here not to generate an undefined exception.. -print_message(informational,_) :- - yap_flag(verbose, silent), - !. -print_message(informational,E) :- - format('informational message ~q.~n',[E]), - !. -%% -% boot:print_message( Type, Error ) -% -print_message(Type,error(_,exception(Desc))) :- - '$get_exception'(Desc), - print_boot_message(Type,Error,Desc), - '$print_exception'(Desc), -print_message(Type,warning(_,exception(Desc))) :- - '$get_exception'(Desc), - print_boot_message(Type,Error,Desc), - '$print_exception'(Desc), - !. -print_message(Type,Error) :- - format( user_error, '~w while bootstraping: event is ~q~n',[Type,Error]). - print_boot_message(Type,Error,Desc) :- diff --git a/pl/consult.yap b/pl/consult.yap index ef4654cbd..b629500a4 100644 --- a/pl/consult.yap +++ b/pl/consult.yap @@ -1450,9 +1450,7 @@ environment. Use initialization/2 for more flexible behavior. '$initialization_queue'(G) :- b_getval('$lf_status', TOpts), '$lf_opt'( initialization, TOpts, Ref), - writeln(G), nb:nb_queue_enqueue(Ref, G), - writeln(Ref), fail. '$initialization_queue'(_). diff --git a/pl/ground.yap b/pl/ground.yap index e3df5c1d5..e50b00990 100644 --- a/pl/ground.yap +++ b/pl/ground.yap @@ -33,7 +33,6 @@ /* % grounds all free variables % as terms of the form '$VAR'(N) -*/ _numbervars(Term, M, N) :- '$variables_in_term'(Term, [], L), '$numbermarked_vars'(L, M, N). diff --git a/pl/init.yap b/pl/init.yap index d783a7dc7..e88f2a0b1 100644 --- a/pl/init.yap +++ b/pl/init.yap @@ -97,7 +97,6 @@ set_prolog_flag(debug, false), % simple trick to find out if this is we are booting from Prolog. % boot from a saved state - writeln(ok), '$init_from_saved_state_and_args', %start_low_level_trace, '$db_clean_queues'(_), diff --git a/pl/top.yap b/pl/top.yap index fd2d9850f..12ea5db19 100644 --- a/pl/top.yap +++ b/pl/top.yap @@ -878,7 +878,7 @@ gated_call(Setup, Goal, Catcher, Cleanup) :- '$expand_clause'(InputCl, C1, CO) :- '$yap_strip_clause'(InputCl, M, ICl), - '$expand_a_clause'( M:ICl, SM, C1, CO), + '$expand_a_clause'( M:ICl, M, C1, CO), !. '$expand_clause'(Cl, Cl, Cl).