make nb_ undefined variable return an error, as SWI does.
This commit is contained in:
parent
ec30e08f69
commit
7037b38fa7
15
C/errors.c
15
C/errors.c
@ -902,6 +902,21 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
|||||||
serious = TRUE;
|
serious = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case EXISTENCE_ERROR_VARIABLE:
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
Term ti[2];
|
||||||
|
|
||||||
|
i = strlen(tmpbuf);
|
||||||
|
ti[0] = MkAtomTerm(AtomVariable);
|
||||||
|
ti[1] = where;
|
||||||
|
nt[0] = Yap_MkApplTerm(FunctorExistenceError, 2, ti);
|
||||||
|
tp = tmpbuf+i;
|
||||||
|
psize -= i;
|
||||||
|
fun = FunctorError;
|
||||||
|
serious = TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case EVALUATION_ERROR_FLOAT_OVERFLOW:
|
case EVALUATION_ERROR_FLOAT_OVERFLOW:
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
16
C/globals.c
16
C/globals.c
@ -1285,8 +1285,10 @@ p_nb_getval(void)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ge = FindGlobalEntry(AtomOfTerm(t));
|
ge = FindGlobalEntry(AtomOfTerm(t));
|
||||||
if (!ge)
|
if (!ge) {
|
||||||
|
Yap_Error(EXISTENCE_ERROR_VARIABLE,t,"nb_getval");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
READ_LOCK(ge->GRWLock);
|
READ_LOCK(ge->GRWLock);
|
||||||
to = ge->global;
|
to = ge->global;
|
||||||
if (IsVarTerm(to) && IsUnboundVar(VarOfTerm(to))) {
|
if (IsVarTerm(to) && IsUnboundVar(VarOfTerm(to))) {
|
||||||
@ -1309,8 +1311,10 @@ nbdelete(Atom at)
|
|||||||
Prop gp, g0;
|
Prop gp, g0;
|
||||||
|
|
||||||
ge = FindGlobalEntry(at);
|
ge = FindGlobalEntry(at);
|
||||||
if (!ge)
|
if (!ge) {
|
||||||
|
Yap_Error(EXISTENCE_ERROR_VARIABLE,MkAtomTerm(at),"nb_delete");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
WRITE_LOCK(ge->GRWLock);
|
WRITE_LOCK(ge->GRWLock);
|
||||||
ae = ge->AtomOfGE;
|
ae = ge->AtomOfGE;
|
||||||
if (GlobalVariables == ge) {
|
if (GlobalVariables == ge) {
|
||||||
@ -1375,8 +1379,10 @@ p_nb_create(void)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
ge = GetGlobalEntry(AtomOfTerm(t));
|
||||||
if (!ge)
|
if (!ge) {
|
||||||
|
Yap_Error(EXISTENCE_ERROR_VARIABLE,t,"nb_create");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
if (IsVarTerm(tarity)) {
|
if (IsVarTerm(tarity)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR,tarity,"nb_create");
|
Yap_Error(INSTANTIATION_ERROR,tarity,"nb_create");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1418,8 +1424,10 @@ p_nb_create2(void)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ge = GetGlobalEntry(AtomOfTerm(t));
|
ge = GetGlobalEntry(AtomOfTerm(t));
|
||||||
if (!ge)
|
if (!ge) {
|
||||||
|
Yap_Error(EXISTENCE_ERROR_VARIABLE,t,"nb_create");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
if (IsVarTerm(tarity)) {
|
if (IsVarTerm(tarity)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR,tarity,"nb_create");
|
Yap_Error(INSTANTIATION_ERROR,tarity,"nb_create");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
1
H/Yap.h
1
H/Yap.h
@ -464,6 +464,7 @@ typedef enum
|
|||||||
EXISTENCE_ERROR_KEY,
|
EXISTENCE_ERROR_KEY,
|
||||||
EXISTENCE_ERROR_SOURCE_SINK,
|
EXISTENCE_ERROR_SOURCE_SINK,
|
||||||
EXISTENCE_ERROR_STREAM,
|
EXISTENCE_ERROR_STREAM,
|
||||||
|
EXISTENCE_ERROR_VARIABLE,
|
||||||
INSTANTIATION_ERROR,
|
INSTANTIATION_ERROR,
|
||||||
INTERRUPT_ERROR,
|
INTERRUPT_ERROR,
|
||||||
OPERATING_SYSTEM_ERROR,
|
OPERATING_SYSTEM_ERROR,
|
||||||
|
@ -75,6 +75,8 @@ true :- true.
|
|||||||
nb_setval('$open_expands_filename',true),
|
nb_setval('$open_expands_filename',true),
|
||||||
'$debug_on'(false),
|
'$debug_on'(false),
|
||||||
nb_setval('$trace',off),
|
nb_setval('$trace',off),
|
||||||
|
nb_setval('$assert_all',off),
|
||||||
|
nb_setval('$if_skip_mode',no_skip),
|
||||||
b_setval('$spy_glist',[]),
|
b_setval('$spy_glist',[]),
|
||||||
% simple trick to find out if this is we are booting from Prolog.
|
% simple trick to find out if this is we are booting from Prolog.
|
||||||
get_value('$user_module',V),
|
get_value('$user_module',V),
|
||||||
|
@ -166,6 +166,8 @@ system_message(error(existence_error(key,Key), Where)) -->
|
|||||||
[ 'EXISTENCE ERROR- ~w: ~w not an existing key' - [Where,Key] ].
|
[ 'EXISTENCE ERROR- ~w: ~w not an existing key' - [Where,Key] ].
|
||||||
system_message(error(existence_error(thread,Thread), Where)) -->
|
system_message(error(existence_error(thread,Thread), Where)) -->
|
||||||
[ 'EXISTENCE ERROR- ~w: ~w not a running thread' - [Where,Thread] ].
|
[ 'EXISTENCE ERROR- ~w: ~w not a running thread' - [Where,Thread] ].
|
||||||
|
system_message(error(existence_error(variable,Var), Where)) -->
|
||||||
|
[ 'EXISTENCE ERROR- ~w: variable ~w does not exist' - [Where,Var] ].
|
||||||
system_message(error(existence_error(Name,F), W)) -->
|
system_message(error(existence_error(Name,F), W)) -->
|
||||||
{ object_name(Name, ObjName) },
|
{ object_name(Name, ObjName) },
|
||||||
[ 'EXISTENCE ERROR- ~w could not open ~a ~w' - [W,ObjName,F] ].
|
[ 'EXISTENCE ERROR- ~w could not open ~a ~w' - [W,ObjName,F] ].
|
||||||
|
Reference in New Issue
Block a user