Use a lisp object to fill unbound slots rather than a null pointer which may end up causing SIGSEGV.

This commit is contained in:
jjgarcia 2003-12-11 12:56:38 +00:00
parent c5ec810687
commit 789844e8d3
4 changed files with 10 additions and 8 deletions

View file

@ -22,7 +22,7 @@ ecl_allocate_instance(cl_object clas, int size)
int i;
CLASS_OF(x) = clas;
for (i = 0; i < size; i++)
x->instance.slots[i] = OBJNULL;
x->instance.slots[i] = ECL_UNBOUND;
return(x);
}
@ -58,7 +58,7 @@ si_change_instance(cl_object x, cl_object clas, cl_object size, cl_object corr)
corr = CDR(corr);
}
else
x->instance.slots[i] = OBJNULL;
x->instance.slots[i] = ECL_UNBOUND;
}
@(return) /* FIXME! Is this what we need? */
}
@ -116,7 +116,7 @@ si_instance_ref_safe(cl_object x, cl_object index)
(i = fix(index)) < 0 || i >= x->instance.length)
FEerror("~S is an illegal slot index.", 1, index);
x = x->instance.slots[i];
if (x == OBJNULL)
if (x == ECL_UNBOUND)
FEerror("Slot index ~S unbound", 1, index);
@(return x)
}
@ -157,13 +157,13 @@ si_unbound()
{
/* Returns an object that cannot be read or written and which
is used to represent an unitialized slot */
@(return OBJNULL)
@(return ECL_UNBOUND)
}
cl_object
si_sl_boundp(cl_object x)
{
@(return ((x == OBJNULL) ? Cnil : Ct))
@(return ((x == ECL_UNBOUND) ? Cnil : Ct))
}
cl_object
@ -176,7 +176,7 @@ si_sl_makunbound(cl_object x, cl_object index)
if (!FIXNUMP(index) ||
(i = fix(index)) >= x->instance.length || i < 0)
FEerror("~S is an illegal slot index.", 1, index);
x->instance.slots[i] = OBJNULL;
x->instance.slots[i] = ECL_UNBOUND;
@(return x)
}

View file

@ -18,6 +18,7 @@ cl_symbols[] = {
{"NIL", CL_ORDINARY, NULL, -1},
{"T", CL_ORDINARY, NULL, -1},
{SYS_ "UNBOUND", SI_ORDINARY, NULL, -1, OBJNULL},
/* LISP PACKAGE */
{"&ALLOW-OTHER-KEYS", CL_ORDINARY, NULL, -1, OBJNULL},

View file

@ -1049,9 +1049,9 @@ type_of(#0)==t_bitvector"))
(si::INSTANCE-CLASS-SET (t t) T)
(si::INSTANCEP (t) T nil t)
(si::UNBOUND nil T nil t
:inline-always (nil T nil nil "OBJNULL"))
:inline-always (nil T nil nil "ECL_UNBOUND"))
(si::SL-BOUNDP (t) T nil t
:inline-always ((t) :bool nil nil "(#0)!=OBJNULL"))
:inline-always ((t) :bool nil nil "(#0)!=ECL_UNBOUND"))
(si::SL-MAKUNBOUND (t fixnum) T nil t)
)) ; end of of #+clos

View file

@ -118,6 +118,7 @@ enum ecl_stype { /* symbol type */
#define Cnil ((cl_object)cl_symbols)
#define Ct ((cl_object)(cl_symbols+1))
#define ECL_UNBOUND ((cl_object)(cl_symbols+2))
struct ecl_symbol {
HEADER4(stype, mflag, isform, dynamic);