changed decode_spec to honor the field info for a non-indexed spec instead of hardcoding it to HCL_OBJ_TYPE_OOP
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f6f475df4a
commit
617ab3e753
@ -758,7 +758,7 @@ static HCL_INLINE hcl_oop_t expand_bigint (hcl_t* hcl, hcl_oop_t oop, hcl_oow_t
|
||||
}
|
||||
|
||||
hcl_pushvolat (hcl, &oop);
|
||||
z = hcl_instantiate(hcl, HCL_OBJ_GET_CLASS(oop), HCL_NULL, count + inc);
|
||||
z = hcl_instantiate(hcl, (hcl_oop_class_t)HCL_OBJ_GET_CLASS(oop), HCL_NULL, count + inc);
|
||||
hcl_popvolat (hcl);
|
||||
if (!z)
|
||||
{
|
||||
@ -782,7 +782,7 @@ static HCL_INLINE hcl_oop_t _clone_bigint(hcl_t* hcl, hcl_oop_t oop, hcl_oow_t c
|
||||
HCL_ASSERT (hcl, HCL_OOP_IS_POINTER(oop));
|
||||
if (count <= 0) count = HCL_OBJ_GET_SIZE(oop);
|
||||
|
||||
hcl_pushvolat (hcl, &_class);
|
||||
hcl_pushvolat (hcl, (hcl_oop_t*)&_class);
|
||||
hcl_pushvolat (hcl, &oop);
|
||||
z = hcl_instantiate(hcl, _class, HCL_NULL, count);
|
||||
hcl_popvolat (hcl);
|
||||
@ -798,7 +798,7 @@ static HCL_INLINE hcl_oop_t _clone_bigint(hcl_t* hcl, hcl_oop_t oop, hcl_oow_t c
|
||||
|
||||
static HCL_INLINE hcl_oop_t clone_bigint (hcl_t* hcl, hcl_oop_t oop, hcl_oow_t count)
|
||||
{
|
||||
return _clone_bigint(hcl, oop, count, HCL_OBJ_GET_CLASS(oop));
|
||||
return _clone_bigint(hcl, oop, count, (hcl_oop_class_t)HCL_OBJ_GET_CLASS(oop));
|
||||
}
|
||||
|
||||
static HCL_INLINE hcl_oop_t clone_bigint_negated (hcl_t* hcl, hcl_oop_t oop, hcl_oow_t count)
|
||||
@ -2131,7 +2131,7 @@ static hcl_oop_t add_unsigned_integers (hcl_t* hcl, hcl_oop_t x, hcl_oop_t y)
|
||||
|
||||
hcl_pushvolat (hcl, &x);
|
||||
hcl_pushvolat (hcl, &y);
|
||||
z = hcl_instantiate(hcl, HCL_OBJ_GET_CLASS(x), HCL_NULL, zs);
|
||||
z = hcl_instantiate(hcl, (hcl_oop_class_t)HCL_OBJ_GET_CLASS(x), HCL_NULL, zs);
|
||||
hcl_popvolats (hcl, 2);
|
||||
if (!z) return HCL_NULL;
|
||||
|
||||
|
31
lib/hcl.h
31
lib/hcl.h
@ -420,22 +420,6 @@ typedef enum hcl_obj_type_t hcl_obj_type_t;
|
||||
#define HCL_OBJ_SET_FLAGS_RDONLY(oop,v) HCL_SETBITS(hcl_oow_t, (oop)->_flags, HCL_OBJ_FLAGS_RDONLY_SHIFT, HCL_OBJ_FLAGS_RDONLY_BITS, v)
|
||||
#define HCL_OBJ_SET_FLAGS_PROC(oop,v) HCL_SETBITS(hcl_oow_t, (oop)->_flags, HCL_OBJ_FLAGS_PROC_SHIFT, HCL_OBJ_FLAGS_PROC_BITS, v)
|
||||
|
||||
#define HCL_OBJ_GET_SIZE(oop) ((oop)->_size)
|
||||
#define HCL_OBJ_GET_CLASS(oop) ((oop)->_class)
|
||||
|
||||
#define HCL_OBJ_SET_SIZE(oop,v) ((oop)->_size = (v))
|
||||
#define HCL_OBJ_SET_CLASS(oop,c) ((oop)->_class = (c))
|
||||
|
||||
/* [NOTE] this macro doesn't include the size of the trailer */
|
||||
#define HCL_OBJ_BYTESOF(oop) ((HCL_OBJ_GET_SIZE(oop) + HCL_OBJ_GET_FLAGS_EXTRA(oop)) * HCL_OBJ_GET_FLAGS_UNIT(oop))
|
||||
|
||||
#define HCL_OBJ_IS_OOP_POINTER(oop) (HCL_OOP_IS_POINTER(oop) && (HCL_OBJ_GET_FLAGS_TYPE(oop) == HCL_OBJ_TYPE_OOP))
|
||||
#define HCL_OBJ_IS_CHAR_POINTER(oop) (HCL_OOP_IS_POINTER(oop) && (HCL_OBJ_GET_FLAGS_TYPE(oop) == HCL_OBJ_TYPE_CHAR))
|
||||
#define HCL_OBJ_IS_BYTE_POINTER(oop) (HCL_OOP_IS_POINTER(oop) && (HCL_OBJ_GET_FLAGS_TYPE(oop) == HCL_OBJ_TYPE_BYTE))
|
||||
#define HCL_OBJ_IS_HALFWORD_POINTER(oop) (HCL_OOP_IS_POINTER(oop) && (HCL_OBJ_GET_FLAGS_TYPE(oop) == HCL_OBJ_TYPE_HALFWORD))
|
||||
#define HCL_OBJ_IS_WORD_POINTER(oop) (HCL_OOP_IS_POINTER(oop) && (HCL_OBJ_GET_FLAGS_TYPE(oop) == HCL_OBJ_TYPE_WORD))
|
||||
|
||||
|
||||
/* [NOTE] this macro doesn't check the range of the actual value.
|
||||
* make sure that the value of each bit fields given falls within the
|
||||
* possible range of the defined bits */
|
||||
@ -454,6 +438,21 @@ typedef enum hcl_obj_type_t hcl_obj_type_t;
|
||||
#define HCL_OBJ_FLAGS_KERNEL_IMMATURE 1 /* incomplete kernel object. defined in gc.c for bootstrapping. but no complete class definition has been read */
|
||||
#define HCL_OBJ_FLAGS_KERNEL_MATURE 2 /* kernel object with its full class defintion read in */
|
||||
|
||||
#define HCL_OBJ_GET_SIZE(oop) ((oop)->_size)
|
||||
#define HCL_OBJ_GET_CLASS(oop) ((oop)->_class)
|
||||
|
||||
#define HCL_OBJ_SET_SIZE(oop,v) ((oop)->_size = (v))
|
||||
#define HCL_OBJ_SET_CLASS(oop,c) ((oop)->_class = (c))
|
||||
|
||||
/* [NOTE] this macro doesn't include the size of the trailer */
|
||||
#define HCL_OBJ_BYTESOF(oop) ((HCL_OBJ_GET_SIZE(oop) + HCL_OBJ_GET_FLAGS_EXTRA(oop)) * HCL_OBJ_GET_FLAGS_UNIT(oop))
|
||||
|
||||
#define HCL_OBJ_IS_OOP_POINTER(oop) (HCL_OOP_IS_POINTER(oop) && (HCL_OBJ_GET_FLAGS_TYPE(oop) == HCL_OBJ_TYPE_OOP))
|
||||
#define HCL_OBJ_IS_CHAR_POINTER(oop) (HCL_OOP_IS_POINTER(oop) && (HCL_OBJ_GET_FLAGS_TYPE(oop) == HCL_OBJ_TYPE_CHAR))
|
||||
#define HCL_OBJ_IS_BYTE_POINTER(oop) (HCL_OOP_IS_POINTER(oop) && (HCL_OBJ_GET_FLAGS_TYPE(oop) == HCL_OBJ_TYPE_BYTE))
|
||||
#define HCL_OBJ_IS_HALFWORD_POINTER(oop) (HCL_OOP_IS_POINTER(oop) && (HCL_OBJ_GET_FLAGS_TYPE(oop) == HCL_OBJ_TYPE_HALFWORD))
|
||||
#define HCL_OBJ_IS_WORD_POINTER(oop) (HCL_OOP_IS_POINTER(oop) && (HCL_OBJ_GET_FLAGS_TYPE(oop) == HCL_OBJ_TYPE_WORD))
|
||||
|
||||
#define HCL_STORE_OOP(hcl,var,val) (*(var) = val)
|
||||
|
||||
#define HCL_OBJ_HEADER \
|
||||
|
29
lib/obj.c
29
lib/obj.c
@ -134,10 +134,10 @@ static HCL_INLINE hcl_oop_t alloc_oop_array (hcl_t* hcl, int brand, hcl_oow_t si
|
||||
}
|
||||
if (!hdr) return HCL_NULL;
|
||||
|
||||
hdr->_flags = HCL_OBJ_MAKE_FLAGS(HCL_OBJ_TYPE_OOP, HCL_SIZEOF(hcl_oop_t), 0, 0, 0, ngc, 0, 0);
|
||||
hdr->_flags = HCL_OBJ_MAKE_FLAGS(HCL_OBJ_TYPE_OOP, HCL_SIZEOF(hcl_oop_t), 0, 0, 0, ngc, 0, brand);
|
||||
HCL_OBJ_SET_SIZE (hdr, size);
|
||||
HCL_OBJ_SET_CLASS (hdr, hcl->_nil);
|
||||
HCL_OBJ_SET_FLAGS_BRAND (hdr, brand);
|
||||
/*HCL_OBJ_SET_CLASS (hdr, hcl->_nil);*/
|
||||
/*HCL_OBJ_SET_FLAGS_BRAND (hdr, brand);*/
|
||||
|
||||
while (size > 0) hdr->slot[--size] = hcl->_nil;
|
||||
|
||||
@ -163,10 +163,10 @@ hcl_oop_t hcl_allocoopobjwithtrailer (hcl_t* hcl, int brand, hcl_oow_t size, con
|
||||
hdr = (hcl_oop_oop_t)hcl_allocbytes(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
if (HCL_UNLIKELY(!hdr)) return HCL_NULL;
|
||||
|
||||
hdr->_flags = HCL_OBJ_MAKE_FLAGS(HCL_OBJ_TYPE_OOP, HCL_SIZEOF(hcl_oop_t), 0, 0, 0, 0, 1, 0);
|
||||
hdr->_flags = HCL_OBJ_MAKE_FLAGS(HCL_OBJ_TYPE_OOP, HCL_SIZEOF(hcl_oop_t), 0, 0, 0, 0, 1, brand);
|
||||
HCL_OBJ_SET_SIZE (hdr, size);
|
||||
/*HCL_OBJ_SET_CLASS (hdr, hcl->_nil);*/
|
||||
HCL_OBJ_SET_FLAGS_BRAND (hdr, brand);
|
||||
/*HCL_OBJ_SET_FLAGS_BRAND (hdr, brand);*/
|
||||
|
||||
for (i = 0; i < size; i++) hdr->slot[i] = hcl->_nil;
|
||||
|
||||
@ -203,11 +203,11 @@ static HCL_INLINE hcl_oop_t alloc_numeric_array (hcl_t* hcl, int brand, const vo
|
||||
hdr = (hcl_oop_t)hcl_allocbytes(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
if (HCL_UNLIKELY(!hdr)) return HCL_NULL;
|
||||
|
||||
hdr->_flags = HCL_OBJ_MAKE_FLAGS(type, unit, extra, 0, 0, ngc, 0, 0);
|
||||
hdr->_flags = HCL_OBJ_MAKE_FLAGS(type, unit, extra, 0, 0, ngc, 0, brand);
|
||||
hdr->_size = len;
|
||||
HCL_OBJ_SET_SIZE (hdr, len);
|
||||
/*HCL_OBJ_SET_CLASS (hdr, hcl->_nil);*/
|
||||
HCL_OBJ_SET_FLAGS_BRAND (hdr, brand);
|
||||
/*HCL_OBJ_SET_FLAGS_BRAND (hdr, brand);*/
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
@ -526,19 +526,14 @@ hcl_oop_t hcl_makeclass (hcl_t* hcl, hcl_oop_t class_name, hcl_oop_t superclass,
|
||||
hcl_pushvolat (hcl, &superclass);
|
||||
hcl_pushvolat (hcl, &ivars_str);
|
||||
hcl_pushvolat (hcl, &cvars_str);
|
||||
#if 0
|
||||
c = (hcl_oop_class_t)hcl_allocoopobj(hcl, HCL_BRAND_CLASS, HCL_CLASS_NAMED_INSTVARS + ncvars);
|
||||
#else
|
||||
c = (hcl_oop_class_t)hcl_instantiate(hcl, hcl->c_class, HCL_NULL, ncvars);
|
||||
#endif
|
||||
hcl_popvolats (hcl, 4);
|
||||
if (HCL_UNLIKELY(!c))
|
||||
{
|
||||
const hcl_ooch_t* orgmsg = hcl_backuperrmsg(hcl);
|
||||
hcl_seterrbfmt (hcl, HCL_ERRNUM(hcl), "unable to make class - %js", orgmsg);
|
||||
hcl_seterrbfmt (hcl, HCL_ERRNUM(hcl), "unable to make class %O - %js", class_name, orgmsg);
|
||||
return HCL_NULL;
|
||||
}
|
||||
HCL_OBJ_SET_CLASS (c, (hcl_oop_t)hcl->c_class);
|
||||
|
||||
/* TODO: other flags... indexable? byte? word?*/
|
||||
spec = HCL_CLASS_SPEC_MAKE(nivars, 0, 0); /* TODO: how to include nivars_super ? */
|
||||
@ -613,7 +608,13 @@ static HCL_INLINE int decode_spec (hcl_t* hcl, hcl_oop_class_t _class, hcl_oow_t
|
||||
{
|
||||
/* named instance variables only. treat it as if it is an
|
||||
* indexable class with no variable data */
|
||||
indexed_type = HCL_OBJ_TYPE_OOP;
|
||||
|
||||
/* for an object composed of non-oop fields,
|
||||
* the field can be accessed using a instance variable name.
|
||||
* the instructions for instance variable access must cater for this.
|
||||
* for example, the Primitive class is HCL_OBJ_TYPE_WORD and not variable */
|
||||
/*indexed_type = HCL_OBJ_TYPE_OOP; <- no more fixed to OOP fields only. */
|
||||
indexed_type = (hcl_obj_type_t)HCL_CLASS_SPEC_INDEXED_TYPE(spec);
|
||||
|
||||
if (num_flexi_fields > 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user