make error handling for callable more ISO like.
This commit is contained in:
parent
47d1bd5ecc
commit
0cd0ece207
@ -724,7 +724,7 @@ get_pred(Term t, Term tmod, char *pname)
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor fun = FunctorOfTerm(t);
|
||||
if (IsExtensionFunctor(fun)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t0, pname);
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, Yap_PredicateIndicator(t, tmod), pname);
|
||||
return NULL;
|
||||
}
|
||||
if (fun == FunctorModule) {
|
||||
@ -2615,8 +2615,11 @@ p_compile( USES_REGS1 )
|
||||
addclause(t, codeadr, (int) (IntOfTerm(t1) & 3), mod, &tn);
|
||||
YAPLeaveCriticalSection();
|
||||
if (LOCAL_ErrorMessage) {
|
||||
if (LOCAL_Error_TYPE == TYPE_ERROR_CALLABLE) {
|
||||
Yap_Error(LOCAL_Error_TYPE, Yap_PredicateIndicator(t, mod), LOCAL_ErrorMessage);
|
||||
}
|
||||
if (IntOfTerm(t1) & 4) {
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term,
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, LOCAL_Error_Term,
|
||||
"in line %d, %s", Yap_FirstLineInParse(), LOCAL_ErrorMessage);
|
||||
} else {
|
||||
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
|
||||
|
67
C/exec.c
67
C/exec.c
@ -103,12 +103,42 @@ Yap_ExecuteCallMetaCall(Term mod) {
|
||||
return(Yap_MkApplTerm(PredMetaCall->FunctorOfPred,4,ts));
|
||||
}
|
||||
|
||||
Term
|
||||
Yap_PredicateIndicator(Term t, Term mod)
|
||||
{
|
||||
CACHE_REGS
|
||||
// generate predicate indicator in this case
|
||||
Term ti[2];
|
||||
t = Yap_StripModule( t, &mod );
|
||||
if (IsApplTerm(t) && !IsExtensionFunctor(FunctorOfTerm(t))) {
|
||||
ti[0] = MkAtomTerm(NameOfFunctor(FunctorOfTerm(t)));
|
||||
ti[1] = MkIntegerTerm(ArityOfFunctor(FunctorOfTerm(t)));
|
||||
} else if (IsPairTerm(t)) {
|
||||
ti[0] = MkAtomTerm(AtomDot);
|
||||
ti[1] = MkIntTerm(2);
|
||||
} else {
|
||||
ti[0] = t;
|
||||
ti[1] = MkIntTerm(0);
|
||||
}
|
||||
t = Yap_MkApplTerm(FunctorSlash, 2, ti);
|
||||
if (mod != CurrentModule) {
|
||||
ti[0] = mod;
|
||||
ti[1] = t;
|
||||
return Yap_MkApplTerm(FunctorModule, 2, ti);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
static Int
|
||||
CallError(yap_error_number err, Term t, Term mod USES_REGS)
|
||||
{
|
||||
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {
|
||||
return(CallMetaCall(t, mod PASS_REGS));
|
||||
} else {
|
||||
if (err == TYPE_ERROR_CALLABLE) {
|
||||
t = Yap_PredicateIndicator(t, mod);
|
||||
}
|
||||
Yap_Error(err, t, "call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
@ -181,11 +211,11 @@ do_execute(Term t, Term mod USES_REGS)
|
||||
|
||||
f = FunctorOfTerm(t);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
return CallError(TYPE_ERROR_CALLABLE, t0, mod PASS_REGS);
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
}
|
||||
arity = ArityOfFunctor(f);
|
||||
if (arity > MaxTemps) {
|
||||
return CallError(TYPE_ERROR_CALLABLE, t0, mod PASS_REGS);
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
}
|
||||
pen = RepPredProp(PredPropByFunc(f, mod));
|
||||
/* You thought we would be over by now */
|
||||
@ -239,7 +269,7 @@ do_execute(Term t, Term mod USES_REGS)
|
||||
pe = RepPredProp(PredPropByAtom(a, mod));
|
||||
return (CallPredicate(pe, B, pe->CodeOfPred PASS_REGS));
|
||||
} else if (IsIntTerm(t)) {
|
||||
return CallError(TYPE_ERROR_CALLABLE, t0, mod PASS_REGS);
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
} else {
|
||||
/* Is Pair Term */
|
||||
return(CallMetaCall(t, mod PASS_REGS));
|
||||
@ -301,7 +331,7 @@ do_execute_n(Term t, Term mod, unsigned int n USES_REGS)
|
||||
Name = AtomOfTerm(t);
|
||||
pt = NULL;
|
||||
} else if (IsIntTerm(t)) {
|
||||
return CallError(TYPE_ERROR_CALLABLE, t0, mod PASS_REGS);
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
} else if (IsPairTerm(t)) {
|
||||
arity = n+2;
|
||||
pt = RepPair(t);
|
||||
@ -328,7 +358,7 @@ do_execute_n(Term t, Term mod, unsigned int n USES_REGS)
|
||||
}
|
||||
f = Yap_MkFunctor(Name,arity);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
return CallError(TYPE_ERROR_CALLABLE, t0, mod PASS_REGS);
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
}
|
||||
if (PRED_GOAL_EXPANSION_ALL) {
|
||||
/* disable creeping when we do goal expansion */
|
||||
@ -343,7 +373,7 @@ do_execute_n(Term t, Term mod, unsigned int n USES_REGS)
|
||||
return EnterCreepMode(copy_execn_to_heap(f, pt, n, arity, CurrentModule PASS_REGS), mod PASS_REGS);
|
||||
}
|
||||
if (arity > MaxTemps) {
|
||||
return CallError(TYPE_ERROR_CALLABLE, t0, mod PASS_REGS);
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
}
|
||||
pen = RepPredProp(PredPropByFunc(f, mod));
|
||||
/* You thought we would be over by now */
|
||||
@ -572,7 +602,7 @@ p_execute12( USES_REGS1 )
|
||||
static Int
|
||||
p_execute_clause( USES_REGS1 )
|
||||
{ /* '$execute_clause'(Goal) */
|
||||
Term t = Deref(ARG1), t0 = t;
|
||||
Term t = Deref(ARG1);
|
||||
Term mod = Deref(ARG2);
|
||||
choiceptr cut_cp = cp_from_integer(Deref(ARG4) PASS_REGS);
|
||||
unsigned int arity;
|
||||
@ -605,7 +635,7 @@ p_execute_clause( USES_REGS1 )
|
||||
pe = PredPropByFunc(f, mod);
|
||||
arity = ArityOfFunctor(f);
|
||||
if (arity > MaxTemps) {
|
||||
return CallError(TYPE_ERROR_CALLABLE, t0, mod PASS_REGS);
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
}
|
||||
/* I cannot use the standard macro here because
|
||||
otherwise I would dereference the argument and
|
||||
@ -623,8 +653,7 @@ p_execute_clause( USES_REGS1 )
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,ARG3,"call/1");
|
||||
return FALSE;
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
}
|
||||
/* N = arity; */
|
||||
/* call may not define new system predicates!! */
|
||||
@ -783,7 +812,7 @@ p_execute0( USES_REGS1 )
|
||||
// Yap_DebugPlWrite(mod);fprintf(stderr,"\n");
|
||||
arity = ArityOfFunctor(f);
|
||||
if (arity > MaxTemps) {
|
||||
return CallError(TYPE_ERROR_CALLABLE, t0, mod PASS_REGS);
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
}
|
||||
/* I cannot use the standard macro here because
|
||||
otherwise I would dereference the argument and
|
||||
@ -801,7 +830,7 @@ p_execute0( USES_REGS1 )
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,ARG1,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,Yap_PredicateIndicator(t, mod),"call/1");
|
||||
return FALSE;
|
||||
}
|
||||
/* N = arity; */
|
||||
@ -847,14 +876,14 @@ p_execute_nonstop( USES_REGS1 )
|
||||
if (IsVarTerm(tmod)) {
|
||||
return CallError(INSTANTIATION_ERROR, t0, mod PASS_REGS);
|
||||
} else {
|
||||
return CallError(TYPE_ERROR_ATOM, t0, mod PASS_REGS);
|
||||
return CallError(TYPE_ERROR_ATOM, t, mod PASS_REGS);
|
||||
}
|
||||
}
|
||||
}
|
||||
pe = PredPropByFunc(f, mod);
|
||||
arity = ArityOfFunctor(f);
|
||||
if (arity > MaxTemps) {
|
||||
return CallError(TYPE_ERROR_CALLABLE, t0, mod PASS_REGS);
|
||||
return CallError(TYPE_ERROR_CALLABLE, t, mod PASS_REGS);
|
||||
}
|
||||
/* I cannot use the standard macro here because
|
||||
otherwise I would dereference the argument and
|
||||
@ -872,7 +901,7 @@ p_execute_nonstop( USES_REGS1 )
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,ARG3,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,Yap_PredicateIndicator(t, mod),"call/1");
|
||||
return FALSE;
|
||||
}
|
||||
/* N = arity; */
|
||||
@ -1276,7 +1305,7 @@ Yap_execute_goal(Term t, int nargs, Term mod)
|
||||
Functor f = FunctorOfTerm(t);
|
||||
|
||||
if (IsBlobFunctor(f)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,Yap_PredicateIndicator(t, mod),"call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
/* I cannot use the standard macro here because
|
||||
@ -1285,7 +1314,7 @@ Yap_execute_goal(Term t, int nargs, Term mod)
|
||||
pt = RepAppl(t)+1;
|
||||
pe = PredPropByFunc(f, mod);
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,Yap_PredicateIndicator(t, mod),"call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
ppe = RepPredProp(pe);
|
||||
@ -1339,7 +1368,7 @@ Yap_RunTopGoal(Term t)
|
||||
Functor f = FunctorOfTerm(t);
|
||||
|
||||
if (IsBlobFunctor(f)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,Yap_PredicateIndicator(t, mod),"call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
if (f == FunctorModule) {
|
||||
@ -1364,7 +1393,7 @@ Yap_RunTopGoal(Term t)
|
||||
pt = RepAppl(t)+1;
|
||||
arity = ArityOfFunctor(f);
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,t,"call/1");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,Yap_PredicateIndicator(t, mod),"call/1");
|
||||
return(FALSE);
|
||||
}
|
||||
ppe = RepPredProp(pe);
|
||||
|
@ -260,7 +260,7 @@ p_strip_module( USES_REGS1 )
|
||||
}
|
||||
t1 = Yap_StripModule( t1, &tmod );
|
||||
if (!t1) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,ARG1,"trying to obtain module");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,Yap_PredicateIndicator(t1,tmod),"trying to obtain module");
|
||||
return FALSE;
|
||||
}
|
||||
return Yap_unify(ARG3, t1) &&
|
||||
@ -316,7 +316,7 @@ p_yap_strip_module( USES_REGS1 )
|
||||
}
|
||||
t1 = Yap_YapStripModule( t1, &tmod );
|
||||
if (!t1) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,ARG1,"trying to obtain module");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE,Yap_PredicateIndicator(t1, tmod),"trying to obtain module");
|
||||
return FALSE;
|
||||
}
|
||||
return Yap_unify(ARG3, t1) &&
|
||||
|
@ -995,12 +995,12 @@ p_with_mutex( USES_REGS1 )
|
||||
|
||||
f = FunctorOfTerm(tg);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, tg, "with_mutex/2");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, Yap_PredicateIndicator(tg, tm), "with_mutex/2");
|
||||
goto end;
|
||||
}
|
||||
arity = ArityOfFunctor(f);
|
||||
if (arity > MaxTemps) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, tg, "with_mutex/2");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, Yap_PredicateIndicator(tg, tm), "with_mutex/2");
|
||||
goto end;
|
||||
}
|
||||
pe = RepPredProp(PredPropByFunc(f, tm));
|
||||
@ -1019,7 +1019,7 @@ p_with_mutex( USES_REGS1 )
|
||||
XREGS[1] = pt[0];
|
||||
XREGS[2] = pt[1];
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, tg, "with_mutex/2");
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, Yap_PredicateIndicator(tg, tm), "with_mutex/2");
|
||||
goto end;
|
||||
}
|
||||
if (
|
||||
|
@ -188,7 +188,7 @@ Term Yap_GetException(void);
|
||||
void Yap_PrepGoal(UInt, CELL *, choiceptr USES_REGS);
|
||||
int Yap_execute_pred(struct pred_entry *ppe, CELL *pt USES_REGS);
|
||||
int Yap_dogc( int extra_args, Term *tp USES_REGS );
|
||||
|
||||
Term Yap_PredicateIndicator(Term t, Term mod);
|
||||
/* exo.c */
|
||||
void Yap_InitExoPreds(void);
|
||||
void Yap_udi_Interval_init(void);
|
||||
|
@ -265,7 +265,8 @@ flag_define(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, MH
|
||||
; \+ memberchk(Access, [read_write, read_only, hidden, hidden_read_only]),
|
||||
throw(error(domain_error(access, Access), message('Wrong access attribute, available are: read_write, read_only, hidden, hidden_read_only.', flag_define(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, Module:Handler))))
|
||||
; \+ callable(Handler) ->
|
||||
throw(error(type_error(callable, Handler), message('Flag handler needs to be callable.', flag_define(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, Module:Handler))))
|
||||
strip_module(Handler, Mod, G),
|
||||
throw(error(type_error(callable, G/0), message('Flag handler needs to be callable.', flag_define(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, Module:Handler))))
|
||||
;
|
||||
validate(FlagType, Module:Handler, DefaultValue, FlagName),
|
||||
assertz('$defined_flag$'(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, Module:Handler)),
|
||||
|
12
pl/boot.yap
12
pl/boot.yap
@ -628,9 +628,9 @@ number of steps.
|
||||
'$execute_command'(C,_,_,top,Source) :- var(C), !,
|
||||
'$do_error'(instantiation_error,meta_call(Source)).
|
||||
'$execute_command'(C,_,_,top,Source) :- number(C), !,
|
||||
'$do_error'(type_error(callable,C),meta_call(Source)).
|
||||
'$do_error'(type_error(callable,C/0),meta_call(Source)).
|
||||
'$execute_command'(R,_,_,top,Source) :- db_reference(R), !,
|
||||
'$do_error'(type_error(callable,R),meta_call(Source)).
|
||||
'$do_error'(type_error(callable,R/0),meta_call(Source)).
|
||||
'$execute_command'(end_of_file,_,_,_,_) :- !.
|
||||
'$execute_command'(Command,_,_,_,_) :-
|
||||
'$nb_getval'('$if_skip_mode', skip, fail),
|
||||
@ -1298,9 +1298,9 @@ not(G) :- \+ '$execute'(G).
|
||||
'$check_callable'(_:G1,G) :- !,
|
||||
'$check_callable'(G1,G).
|
||||
'$check_callable'(A,G) :- number(A), !,
|
||||
'$do_error'(type_error(callable,A),G).
|
||||
'$do_error'(type_error(callable,A/0),G).
|
||||
'$check_callable'(R,G) :- db_reference(R), !,
|
||||
'$do_error'(type_error(callable,R),G).
|
||||
'$do_error'(type_error(callable,R/0),G).
|
||||
'$check_callable'(_,_).
|
||||
|
||||
|
||||
@ -1394,9 +1394,9 @@ bootstrap(F) :-
|
||||
'$check_head'(H,P) :- var(H), !,
|
||||
'$do_error'(instantiation_error,P).
|
||||
'$check_head'(H,P) :- number(H), !,
|
||||
'$do_error'(type_error(callable,H),P).
|
||||
'$do_error'(type_error(callable,H/0),P).
|
||||
'$check_head'(H,P) :- db_reference(H), !,
|
||||
'$do_error'(type_error(callable,H),P).
|
||||
'$do_error'(type_error(callable,H/0),P).
|
||||
'$check_head'(_,_).
|
||||
|
||||
% term expansion
|
||||
|
@ -1398,9 +1398,9 @@ environment. Use initialization/2 for more flexible behavior.
|
||||
var(V), !,
|
||||
'$do_error'(instantiation_error,initialization(V)).
|
||||
'$initialization'(C) :- number(C), !,
|
||||
'$do_error'(type_error(callable,C),initialization(C)).
|
||||
'$do_error'(type_error(callable,C/0),initialization(C)).
|
||||
'$initialization'(C) :- db_reference(C), !,
|
||||
'$do_error'(type_error(callable,C),initialization(C)).
|
||||
'$do_error'(type_error(callable,C/0),initialization(C)).
|
||||
'$initialization'(G) :-
|
||||
'$show_consult_level'(Level1),
|
||||
% it will be done after we leave the current consult level.
|
||||
@ -1438,11 +1438,11 @@ initialization(G,OPT) :-
|
||||
;
|
||||
number(G)
|
||||
->
|
||||
'$do_error'(type_error(callable,G),initialization(G,OPT))
|
||||
'$do_error'(type_error(callable,G/0),initialization(G,OPT))
|
||||
;
|
||||
db_reference(G)
|
||||
->
|
||||
'$do_error'(type_error(callable,G),initialization(G,OPT))
|
||||
'$do_error'(type_error(callable,G/0),initialization(G,OPT))
|
||||
;
|
||||
var(OPT)
|
||||
->
|
||||
|
@ -516,7 +516,7 @@ prolog_initialization(G) :- var(G), !,
|
||||
prolog_initialization(T) :- callable(T), !,
|
||||
'$assert_init'(T).
|
||||
prolog_initialization(T) :-
|
||||
'$do_error'(type_error(callable,T),initialization(T)).
|
||||
'$do_error'(type_error(callable,T/0),initialization(T)).
|
||||
|
||||
'$assert_init'(T) :- recordz('$startup_goal',T,_), fail.
|
||||
'$assert_init'(_).
|
||||
|
@ -103,7 +103,7 @@ dynamic(X) :-
|
||||
'$do_error'(permission_error(modify,static_procedure,A/N),dynamic(Mod:A/N))
|
||||
).
|
||||
'$dynamic2'(X,Mod) :-
|
||||
'$do_error'(type_error(callable,X),dynamic(Mod:X)).
|
||||
'$do_error'(type_error(callable,X/0),dynamic(Mod:X)).
|
||||
|
||||
'$logical_updatable'(A//N,Mod) :- integer(N), !,
|
||||
N1 is N+2,
|
||||
@ -118,7 +118,7 @@ dynamic(X) :-
|
||||
'$do_error'(permission_error(modify,static_procedure,A/N),dynamic(Mod:A/N))
|
||||
).
|
||||
'$logical_updatable'(X,Mod) :-
|
||||
'$do_error'(type_error(callable,X),dynamic(Mod:X)).
|
||||
'$do_error'(type_error(callable,X/0),dynamic(Mod:X)).
|
||||
|
||||
/** @pred public( _P_ ) is iso
|
||||
|
||||
@ -145,7 +145,7 @@ defines all new or redefined predicates to be public.
|
||||
functor(T,A,N),
|
||||
'$do_make_public'(T, Mod).
|
||||
'$public'(X, Mod) :-
|
||||
'$do_error'(type_error(callable,X),dynamic(Mod:X)).
|
||||
'$do_error'(type_error(callable,X/0),dynamic(Mod:X)).
|
||||
|
||||
'$do_make_public'(T, Mod) :-
|
||||
'$is_dynamic'(T, Mod), !. % all dynamic predicates are public.
|
||||
|
@ -163,7 +163,7 @@ assert(C) :-
|
||||
'$assert'(V,Mod,_,_,_) :- var(Mod), !,
|
||||
'$do_error'(instantiation_error,assert(Mod:V)).
|
||||
'$assert'(I,Mod,_,_,_) :- number(I), !,
|
||||
'$do_error'(type_error(callable,I),assert(Mod:I)).
|
||||
'$do_error'(type_error(callable,I/0),assert(Mod:I)).
|
||||
'$assert'(M:C,_,Where,R,P) :- !,
|
||||
'$assert'(C,M,Where,R,P).
|
||||
'$assert'((H:-G),M1,Where,R,P) :- !,
|
||||
@ -487,10 +487,10 @@ clause(V,Q,R) :-
|
||||
'$do_error'(instantiation_error,clause(M:V,Q,R)).
|
||||
'$clause'(C,M,Q,R) :-
|
||||
number(C), !,
|
||||
'$do_error'(type_error(callable,C),clause(M:C,Q,R)).
|
||||
'$do_error'(type_error(callable,C/0),clause(M:C,Q,R)).
|
||||
'$clause'(C,M,Q,R) :-
|
||||
db_reference(C), !,
|
||||
'$do_error'(type_error(callable,C),clause(M:R,Q,R)).
|
||||
'$do_error'(type_error(callable,C/0),clause(M:R,Q,R)).
|
||||
'$clause'(M:P,_,Q,R) :- !,
|
||||
'$clause'(P,M,Q,R).
|
||||
'$clause'(P,M,Q,R) :-
|
||||
|
@ -186,14 +186,16 @@ save_program(File, _Goal) :-
|
||||
strip_module(M:B, M1, G1),
|
||||
recordz('$restore_flag',goal(M1:G1),_)
|
||||
;
|
||||
'$do_error'(type_error(callable,B),G)
|
||||
strip_module(M:B, M1, G1),
|
||||
'$do_error'(type_error(callable,G1/0),G)
|
||||
).
|
||||
'$cvt_qsave_flag'(toplevel(B), G, M) :- !,
|
||||
( callable(B) ->
|
||||
strip_module(M:B, M1, G1),
|
||||
recordz('$restore_flag',toplevel(M1:G1),_)
|
||||
;
|
||||
'$do_error'(type_error(callable,B),G)
|
||||
strip_module(M:B, M1, G1),
|
||||
'$do_error'(type_error(callable,G1/0),G)
|
||||
).
|
||||
'$cvt_qsave_flag'(init_file(B), G, M) :- !,
|
||||
( atom(B) ->
|
||||
|
@ -38,7 +38,7 @@ save_program(A, G) :- var(A), !,
|
||||
save_program(A, G) :- var(G), !,
|
||||
'$do_error'(instantiation_error, save_program(A,G)).
|
||||
save_program(A, G) :- \+ callable(G), !,
|
||||
'$do_error'(type_error(callable,G), save_program(A,G)).
|
||||
'$do_error'(type_error(callable,G/0), save_program(A,G)).
|
||||
save_program(A, G) :-
|
||||
( atom(A) -> atom_codes(A,S) ; A = S),
|
||||
'$save_program2'(S, G),
|
||||
|
@ -290,11 +290,11 @@ on_signal(Signal,OldAction,Action) :-
|
||||
on_signal(Signal,OldAction,Action) :-
|
||||
'$reset_signal'(Signal, OldAction),
|
||||
% 13211-2 speaks only about callable
|
||||
( Action = M:Goal -> true ; throw(error(type_error(callable,Action),on_signal/3)) ),
|
||||
( Action = M:Goal -> true ; throw(error(type_error(callable,Action/0),on_signal/3)) ),
|
||||
% the following disagrees with 13211-2:6.7.1.4 which disagrees with 13211-1:7.12.2a
|
||||
% but the following agrees with 13211-1:7.12.2a
|
||||
( nonvar(M) -> true ; throw(error(instantiation_error,on_signal/3)) ),
|
||||
( atom(M) -> true ; throw(error(type_error(callable,Action),on_signal/3)) ),
|
||||
( atom(M) -> true ; throw(error(type_error(callable,Action/0),on_signal/3)) ),
|
||||
( nonvar(Goal) -> true ; throw(error(instantiation_error,on_signal/3)) ),
|
||||
recordz('$signal_handler', action(Signal,Action), _).
|
||||
|
||||
|
@ -335,7 +335,7 @@ time(_:Goal) :-
|
||||
var(Goal),
|
||||
'$do_error'(instantiation_error,time(Goal)).
|
||||
time(Goal) :- \+ callable(Goal), !,
|
||||
'$do_error'(type_error(callable,Goal),time(Goal)).
|
||||
'$do_error'(type_error(callable,Goal/0),time(Goal)).
|
||||
time(Goal) :-
|
||||
statistics(walltime, _),
|
||||
statistics(cputime, _),
|
||||
|
@ -8,7 +8,7 @@
|
||||
'$do_error'(instantiation_error,call(G)).
|
||||
'$iso_check_goal'(V,G) :-
|
||||
number(V), !,
|
||||
'$do_error'(type_error(callable,V),G).
|
||||
'$do_error'(type_error(callable,V/0),G).
|
||||
'$iso_check_goal'(_:G,G0) :- !,
|
||||
'$iso_check_goal'(G,G0).
|
||||
'$iso_check_goal'((G1,G2),G0) :- !,
|
||||
@ -44,7 +44,7 @@
|
||||
'$do_error'(instantiation_error,call(G)).
|
||||
'$iso_check_a_goal'(V,E,G) :-
|
||||
number(V), !,
|
||||
'$do_error'(type_error(callable,E),call(G)).
|
||||
'$do_error'(type_error(callable,E/0),call(G)).
|
||||
'$iso_check_a_goal'(_:G,E,G0) :- !,
|
||||
'$iso_check_a_goal'(G,E,G0).
|
||||
'$iso_check_a_goal'((G1,G2),E,G0) :- !,
|
||||
|
@ -281,7 +281,7 @@ table(Pred) :-
|
||||
functor(PredFunctor,PredName,PredArity), !,
|
||||
'$set_table'(Mod,PredFunctor,PredModeList).
|
||||
'$do_table'(Mod,Pred) :-
|
||||
'$do_error'(type_error(callable,Mod:Pred),table(Mod:Pred)).
|
||||
'$do_error'(type_error(callable,Pred/0),table(Mod:Pred)).
|
||||
|
||||
'$set_table'(Mod,PredFunctor,_PredModeList) :-
|
||||
'$undefined'('$c_table'(_,_,_),prolog), !,
|
||||
@ -349,7 +349,7 @@ is_tabled(Pred) :-
|
||||
'$flags'(PredFunctor,Mod,Flags,Flags), !,
|
||||
Flags /\ 0x000040 =\= 0.
|
||||
'$do_is_tabled'(Mod,Pred) :-
|
||||
'$do_error'(type_error(callable,Mod:Pred),is_tabled(Mod:Pred)).
|
||||
'$do_error'(type_error(callable,Pred/0),is_tabled(Mod:Pred)).
|
||||
|
||||
|
||||
|
||||
@ -384,7 +384,7 @@ tabling_mode(Pred,Options) :-
|
||||
'$do_error'(domain_error(table,Mod:PredName/PredArity),tabling_mode(Mod:PredName/PredArity,Options))
|
||||
).
|
||||
'$do_tabling_mode'(Mod,Pred,Options) :-
|
||||
'$do_error'(type_error(callable,Mod:Pred),tabling_mode(Mod:Pred,Options)).
|
||||
'$do_error'(type_error(callable,Pred/0),tabling_mode(Mod:Pred,Options)).
|
||||
|
||||
'$set_tabling_mode'(Mod,PredFunctor,Options) :-
|
||||
var(Options), !,
|
||||
@ -445,7 +445,7 @@ abolish_table(Pred) :-
|
||||
'$do_error'(domain_error(table,Mod:PredName/PredArity),abolish_table(Mod:PredName/PredArity))
|
||||
).
|
||||
'$do_abolish_table'(Mod,Pred) :-
|
||||
'$do_error'(type_error(callable,Mod:Pred),abolish_table(Mod:Pred)).
|
||||
'$do_error'(type_error(callable,Pred/0),abolish_table(Mod:Pred)).
|
||||
|
||||
|
||||
|
||||
@ -485,7 +485,7 @@ show_table(Stream,Pred) :-
|
||||
'$do_error'(domain_error(table,Mod:PredName/PredArity),show_table(Mod:PredName/PredArity))
|
||||
).
|
||||
'$do_show_table'(_,Mod,Pred) :-
|
||||
'$do_error'(type_error(callable,Mod:Pred),show_table(Mod:Pred)).
|
||||
'$do_error'(type_error(callable,Pred/0),show_table(Mod:Pred)).
|
||||
|
||||
|
||||
|
||||
@ -525,7 +525,7 @@ table_statistics(Stream,Pred) :-
|
||||
'$do_error'(domain_error(table,Mod:PredName/PredArity),table_statistics(Mod:PredName/PredArity))
|
||||
).
|
||||
'$do_table_statistics'(_,Mod,Pred) :-
|
||||
'$do_error'(type_error(callable,Mod:Pred),table_statistics(Mod:Pred)).
|
||||
'$do_error'(type_error(callable,Pred/0),table_statistics(Mod:Pred)).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
@ -421,7 +421,7 @@ thread_set_default(Default) :-
|
||||
|
||||
'$thread_set_default'(at_exit(AtExit), G) :-
|
||||
\+ callable(AtExit), !,
|
||||
'$do_error'(type_error(callable, AtExit), G).
|
||||
'$do_error'(type_error(callable, AtExit/0), G).
|
||||
'$thread_set_default'(at_exit(AtExit), _) :- !,
|
||||
recorded('$thread_defaults', [Stack, Trail, System, Detached, _], Ref),
|
||||
erase(Ref),
|
||||
@ -1099,7 +1099,7 @@ with_mutex(M, G) :-
|
||||
var(G) -> mutex_unlock(M), '$do_error'(instantiation_error,with_mutex(M, G))
|
||||
;
|
||||
\+ callable(G) ->
|
||||
mutex_unlock(M), '$do_error'(type_error(callable,G),with_mutex(M, G))
|
||||
mutex_unlock(M), '$do_error'(type_error(callable,G/0),with_mutex(M, G))
|
||||
;
|
||||
catch('$execute'(G), E, (mutex_unlock(M), throw(E))) ->
|
||||
mutex_unlock(M)
|
||||
@ -1552,7 +1552,7 @@ thread_local(X) :-
|
||||
'$do_error'(permission_error(modify,static_procedure,A/N),thread_local(Mod:A/N))
|
||||
).
|
||||
'$thread_local2'(X,Mod) :-
|
||||
'$do_error'(type_error(callable,X),thread_local(Mod:X)).
|
||||
'$do_error'(type_error(callable,X/0),thread_local(Mod:X)).
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user