make full init even before entering Prolog top-level
This commit is contained in:
parent
ceb5785120
commit
d5bf100b71
@ -3186,7 +3186,7 @@ YAP_Init(YAP_init_args *yap_init)
|
|||||||
Yap_AttsSize = 2048*sizeof(CELL);
|
Yap_AttsSize = 2048*sizeof(CELL);
|
||||||
if (restore_result == DO_ONLY_CODE) {
|
if (restore_result == DO_ONLY_CODE) {
|
||||||
/* first, initialise the saved state */
|
/* first, initialise the saved state */
|
||||||
Term t_goal = MkAtomTerm(AtomStartupSavedState);
|
Term t_goal = MkAtomTerm(AtomInitProlog);
|
||||||
YAP_RunGoalOnce(t_goal);
|
YAP_RunGoalOnce(t_goal);
|
||||||
Yap_InitYaamRegs();
|
Yap_InitYaamRegs();
|
||||||
/* reset stacks */
|
/* reset stacks */
|
||||||
|
11
C/qlyr.c
11
C/qlyr.c
@ -999,9 +999,13 @@ p_read_module_preds( USES_REGS1 )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ReInitCatch(void)
|
ReInitProlog(void)
|
||||||
{
|
{
|
||||||
Term t = Yap_MkNewApplTerm(PredHandleThrow->FunctorOfPred, PredHandleThrow->ArityOfPE);
|
Term t = MkAtomTerm(AtomInitProlog);
|
||||||
|
#if defined(YAPOR) || defined(TABLING)
|
||||||
|
Yap_init_root_frames();
|
||||||
|
#endif /* YAPOR || TABLING */
|
||||||
|
Yap_InitYaamRegs();
|
||||||
YAP_RunGoalOnce(t);
|
YAP_RunGoalOnce(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1030,7 +1034,7 @@ p_read_program( USES_REGS1 )
|
|||||||
Sclose( stream );
|
Sclose( stream );
|
||||||
/* back to the top level we go */
|
/* back to the top level we go */
|
||||||
Yap_CloseSlots(PASS_REGS1);
|
Yap_CloseSlots(PASS_REGS1);
|
||||||
ReInitCatch();
|
ReInitProlog();
|
||||||
Yap_RestartYap( 3 );
|
Yap_RestartYap( 3 );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1044,7 +1048,6 @@ Yap_Restore(char *s, char *lib_dir)
|
|||||||
return -1;
|
return -1;
|
||||||
read_module(stream);
|
read_module(stream);
|
||||||
Sclose( stream );
|
Sclose( stream );
|
||||||
ReInitCatch();
|
|
||||||
return DO_ONLY_CODE;
|
return DO_ONLY_CODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +135,7 @@
|
|||||||
AtomId = Yap_LookupAtom("id");
|
AtomId = Yap_LookupAtom("id");
|
||||||
AtomInf = Yap_LookupAtom("inf");
|
AtomInf = Yap_LookupAtom("inf");
|
||||||
AtomInitGoal = Yap_FullLookupAtom("$init_goal");
|
AtomInitGoal = Yap_FullLookupAtom("$init_goal");
|
||||||
|
AtomInitProlog = Yap_FullLookupAtom("$init_prolog");
|
||||||
AtomInStackExpansion = Yap_LookupAtom("in stack expansion");
|
AtomInStackExpansion = Yap_LookupAtom("in stack expansion");
|
||||||
AtomInput = Yap_LookupAtom("input");
|
AtomInput = Yap_LookupAtom("input");
|
||||||
AtomInstantiationError = Yap_LookupAtom("instantiation_error");
|
AtomInstantiationError = Yap_LookupAtom("instantiation_error");
|
||||||
|
@ -135,6 +135,7 @@
|
|||||||
AtomId = AtomAdjust(AtomId);
|
AtomId = AtomAdjust(AtomId);
|
||||||
AtomInf = AtomAdjust(AtomInf);
|
AtomInf = AtomAdjust(AtomInf);
|
||||||
AtomInitGoal = AtomAdjust(AtomInitGoal);
|
AtomInitGoal = AtomAdjust(AtomInitGoal);
|
||||||
|
AtomInitProlog = AtomAdjust(AtomInitProlog);
|
||||||
AtomInStackExpansion = AtomAdjust(AtomInStackExpansion);
|
AtomInStackExpansion = AtomAdjust(AtomInStackExpansion);
|
||||||
AtomInput = AtomAdjust(AtomInput);
|
AtomInput = AtomAdjust(AtomInput);
|
||||||
AtomInstantiationError = AtomAdjust(AtomInstantiationError);
|
AtomInstantiationError = AtomAdjust(AtomInstantiationError);
|
||||||
|
@ -268,6 +268,8 @@
|
|||||||
#define AtomInf Yap_heap_regs->AtomInf_
|
#define AtomInf Yap_heap_regs->AtomInf_
|
||||||
Atom AtomInitGoal_;
|
Atom AtomInitGoal_;
|
||||||
#define AtomInitGoal Yap_heap_regs->AtomInitGoal_
|
#define AtomInitGoal Yap_heap_regs->AtomInitGoal_
|
||||||
|
Atom AtomInitProlog_;
|
||||||
|
#define AtomInitProlog Yap_heap_regs->AtomInitProlog_
|
||||||
Atom AtomInStackExpansion_;
|
Atom AtomInStackExpansion_;
|
||||||
#define AtomInStackExpansion Yap_heap_regs->AtomInStackExpansion_
|
#define AtomInStackExpansion Yap_heap_regs->AtomInStackExpansion_
|
||||||
Atom AtomInput_;
|
Atom AtomInput_;
|
||||||
|
@ -140,6 +140,7 @@ A IOMode N "io_mode"
|
|||||||
A Id N "id"
|
A Id N "id"
|
||||||
A Inf N "inf"
|
A Inf N "inf"
|
||||||
A InitGoal F "$init_goal"
|
A InitGoal F "$init_goal"
|
||||||
|
A InitProlog F "$init_prolog"
|
||||||
A InStackExpansion N "in stack expansion"
|
A InStackExpansion N "in stack expansion"
|
||||||
A Input N "input"
|
A Input N "input"
|
||||||
A InstantiationError N "instantiation_error"
|
A InstantiationError N "instantiation_error"
|
||||||
|
22
pl/boot.yap
22
pl/boot.yap
@ -25,6 +25,9 @@ true :- true.
|
|||||||
'$init_system',
|
'$init_system',
|
||||||
'$do_live'.
|
'$do_live'.
|
||||||
|
|
||||||
|
'$init_prolog' :-
|
||||||
|
'$init_system'.
|
||||||
|
|
||||||
'$do_live' :-
|
'$do_live' :-
|
||||||
repeat,
|
repeat,
|
||||||
'$current_module'(Module),
|
'$current_module'(Module),
|
||||||
@ -35,7 +38,11 @@ true :- true.
|
|||||||
),
|
),
|
||||||
'$system_catch'('$enter_top_level',Module,Error,user:'$Error'(Error)).
|
'$system_catch'('$enter_top_level',Module,Error,user:'$Error'(Error)).
|
||||||
|
|
||||||
|
|
||||||
'$init_system' :-
|
'$init_system' :-
|
||||||
|
'$nb_getval'('$yap_inited', on, fail), !.
|
||||||
|
'$init_system' :-
|
||||||
|
nb_setval('$yap_inited', on),
|
||||||
% do catch as early as possible
|
% do catch as early as possible
|
||||||
(
|
(
|
||||||
'$access_yap_flags'(15, 0),
|
'$access_yap_flags'(15, 0),
|
||||||
@ -165,18 +172,23 @@ true :- true.
|
|||||||
-> fail
|
-> fail
|
||||||
; throw(E)
|
; throw(E)
|
||||||
))),
|
))),
|
||||||
( current_predicate(_, user:rl_add_history(_))
|
(
|
||||||
-> format(atom(CompleteLine), '~W~W',
|
current_predicate(_, user:rl_add_history(_))
|
||||||
|
->
|
||||||
|
format(atom(CompleteLine), '~W~W',
|
||||||
[ Line, [partial(true)],
|
[ Line, [partial(true)],
|
||||||
'.', [partial(true)]
|
'.', [partial(true)]
|
||||||
]),
|
]),
|
||||||
call(user:rl_add_history(CompleteLine))
|
call(user:rl_add_history(CompleteLine))
|
||||||
; true
|
;
|
||||||
|
true
|
||||||
),
|
),
|
||||||
'$system_catch'(atom_to_term(Line, Goal, Bindings), prolog, E,
|
'$system_catch'(
|
||||||
|
atom_to_term(Line, Goal, Bindings), prolog, E,
|
||||||
( print_message(error, E),
|
( print_message(error, E),
|
||||||
fail
|
fail
|
||||||
)), !.
|
)
|
||||||
|
), !.
|
||||||
|
|
||||||
|
|
||||||
% reset alarms when entering top-level.
|
% reset alarms when entering top-level.
|
||||||
|
Reference in New Issue
Block a user