Merge branch 'master' of ../yap-6.2

This commit is contained in:
Vítor Santos Costa 2010-12-07 15:08:25 +00:00
commit 30b0160b0d
8 changed files with 56 additions and 12 deletions

View File

@ -13818,7 +13818,7 @@ Yap_absmi(int inp)
ENDP(pt1);
ENDD(d1);
} else if (mod != CurrentModule) {
goto execute2_metacall;
goto execute2_metacall;
}
}
if (PRED_GOAL_EXPANSION_ALL) {

View File

@ -2647,6 +2647,9 @@ YAP_Init(YAP_init_args *yap_init)
else
Yap_AttsSize = 2048*sizeof(CELL);
if (restore_result == DO_ONLY_CODE) {
/* first, initialise the saved state */
Term t_goal = MkAtomTerm(AtomStartupSavedState);
YAP_RunGoalOnce(t_goal);
return YAP_BOOT_FROM_SAVED_CODE;
} else {
return YAP_BOOT_FROM_SAVED_STACKS;

View File

@ -484,6 +484,24 @@ InitDebug(void)
Yap_PutValue(At, MkIntTerm(15));
}
static UInt
update_flags_from_prolog(UInt flags, PredEntry *pe)
{
if (pe->PredFlags & MetaPredFlag)
flags |= MetaPredFlag;
if (pe->PredFlags & SourcePredFlag)
flags |= SourcePredFlag;
if (pe->PredFlags & SequentialPredFlag)
flags |= SequentialPredFlag;
if (pe->PredFlags & MyddasPredFlag)
flags |= MyddasPredFlag;
if (pe->PredFlags & UDIPredFlag)
flags |= UDIPredFlag;
if (pe->PredFlags & ModuleTransparentPredFlag)
flags |= ModuleTransparentPredFlag;
return flags;
}
void
Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
{
@ -521,8 +539,9 @@ Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
}
if (pe->PredFlags & CPredFlag) {
/* already exists */
flags = update_flags_from_prolog(flags, pe);
cl = ClauseCodeToStaticClause(pe->CodeOfPred);
if ((flags | StandardPredFlag | CPredFlag) != pe->PredFlags) {
if ((flags | StandardPredFlag | CPredFlag ) != pe->PredFlags) {
Yap_ClauseSpace -= cl->ClSize;
Yap_FreeCodeSpace((ADDR)cl);
cl = NULL;
@ -618,6 +637,7 @@ Yap_InitCmpPred(char *Name, unsigned long int Arity, CmpPredicate cmp_code, UInt
}
}
if (pe->PredFlags & CPredFlag) {
flags = update_flags_from_prolog(flags, pe);
p_code = pe->CodeOfPred;
/* already exists */
} else {
@ -691,7 +711,12 @@ Yap_InitAsmPred(char *Name, unsigned long int Arity, int code, CPredicate def,
return;
}
}
pe->PredFlags = flags | AsmPredFlag | StandardPredFlag | (code);
flags |= AsmPredFlag | StandardPredFlag | (code);
if (pe->PredFlags & AsmPredFlag) {
flags = update_flags_from_prolog(flags, pe);
/* already exists */
}
pe->PredFlags = flags;
pe->cs.f_code = def;
pe->ModuleOfPred = CurrentModule;
if (def != NULL) {
@ -859,6 +884,7 @@ Yap_InitCPredBack(char *Name, unsigned long int Arity,
}
if (pe->cs.p_code.FirstClause != NIL)
{
flags = update_flags_from_prolog(flags, pe);
#ifdef CUT_C
CleanBack(pe, Start, Cont, Cut);
#else

View File

@ -266,6 +266,7 @@
AtomSpy = Yap_FullLookupAtom("$spy");
AtomStack = Yap_LookupAtom("stack");
AtomStackFree = Yap_LookupAtom("stackfree");
AtomStartupSavedState = Yap_FullLookupAtom("$startup_saved_state");
AtomStaticClause = Yap_FullLookupAtom("$static_clause");
AtomStaticProcedure = Yap_LookupAtom("static_procedure");
AtomStream = Yap_FullLookupAtom("$stream");

View File

@ -266,6 +266,7 @@
AtomSpy = AtomAdjust(AtomSpy);
AtomStack = AtomAdjust(AtomStack);
AtomStackFree = AtomAdjust(AtomStackFree);
AtomStartupSavedState = AtomAdjust(AtomStartupSavedState);
AtomStaticClause = AtomAdjust(AtomStaticClause);
AtomStaticProcedure = AtomAdjust(AtomStaticProcedure);
AtomStream = AtomAdjust(AtomStream);

View File

@ -530,6 +530,8 @@
#define AtomStack Yap_heap_regs->AtomStack_
Atom AtomStackFree_;
#define AtomStackFree Yap_heap_regs->AtomStackFree_
Atom AtomStartupSavedState_;
#define AtomStartupSavedState Yap_heap_regs->AtomStartupSavedState_
Atom AtomStaticClause_;
#define AtomStaticClause Yap_heap_regs->AtomStaticClause_
Atom AtomStaticProcedure_;

View File

@ -271,6 +271,7 @@ A SourceSink N "source_sink"
A Spy F "$spy"
A Stack N "stack"
A StackFree N "stackfree"
A StartupSavedState F "$startup_saved_state"
A StaticClause F "$static_clause"
A StaticProcedure N "static_procedure"
A Stream F "$stream"

View File

@ -88,6 +88,8 @@ true :- true.
)
),
'$db_clean_queues'(0),
% this must be executed from C-code.
% '$startup_saved_state',
'$startup_reconsult',
'$startup_goals',
'$set_input'(user_input),'$set_output'(user),
@ -196,24 +198,38 @@ true :- true.
'$sync_mmapped_arrays',
set_value('$live','$false').
'$startup_goals' :-
%
% first, recover what we need from the saved state...
%
'$startup_saved_state' :-
get_value('$extend_file_search_path',P), P \= [],
set_value('$extend_file_search_path',[]),
'$extend_file_search_path'(P),
fail.
% use if we come from a save_program and we have SWI's shlib
'$startup_goals' :-
'$startup_saved_state' :-
recorded('$reload_foreign_libraries',G,R),
erase(R),
shlib:reload_foreign_libraries,
fail.
% use if we come from a save_program and we have a goal to execute
'$startup_goals' :-
'$startup_saved_state' :-
recorded('$restore_goal',G,R),
erase(R),
prompt(_,' | '),
'$system_catch'('$do_yes_no'((G->true),user),user,Error,user:'$Error'(Error)),
fail.
'$startup_saved_state'.
% then recover program.
'$startup_reconsult' :-
get_value('$consult_on_boot',X), X \= [], !,
set_value('$consult_on_boot',[]),
'$do_startup_reconsult'(X).
'$startup_reconsult'.
% then we can execute the programs.
'$startup_goals' :-
recorded('$startup_goal',G,_),
'$current_module'(Module),
@ -252,12 +268,6 @@ true :- true.
fail.
'$startup_goals'.
'$startup_reconsult' :-
get_value('$consult_on_boot',X), X \= [], !,
set_value('$consult_on_boot',[]),
'$do_startup_reconsult'(X).
'$startup_reconsult'.
%
% MYDDAS: Import all the tables from one database
%