checked the number of instance/class variables against the internal limit
This commit is contained in:
parent
171b02449e
commit
9ae27ee39a
@ -231,12 +231,13 @@ class X(Object)
|
|||||||
self.yy := 9.
|
self.yy := 9.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class(#byte(3)) Y(X)
|
##class(#byte(3)) Y(X)
|
||||||
{
|
class(#pointer) Y(X)
|
||||||
}
|
|
||||||
class (#word(2)) Z(Y)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
##class (#word(2)) Z(Y)
|
||||||
|
##{
|
||||||
|
##}
|
||||||
|
|
||||||
##class InetSocketAddress(SocketAddress)
|
##class InetSocketAddress(SocketAddress)
|
||||||
##{
|
##{
|
||||||
@ -381,8 +382,14 @@ class MyObject(Object)
|
|||||||
{
|
{
|
||||||
| s conact inact outact |
|
| s conact inact outact |
|
||||||
|
|
||||||
s := Y new.
|
s:= X new: 20.
|
||||||
|
s basicSize dump.
|
||||||
|
'****************************' dump.
|
||||||
|
|
||||||
|
s := Y new: 10.
|
||||||
s x.
|
s x.
|
||||||
|
s basicAt: 1 put: 20.
|
||||||
|
s dump.
|
||||||
s basicSize dump.
|
s basicSize dump.
|
||||||
'****************************' dump.
|
'****************************' dump.
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ class MyObject(Object)
|
|||||||
'unusable variable in compiled code'
|
'unusable variable in compiled code'
|
||||||
'inaccessible variable'
|
'inaccessible variable'
|
||||||
'ambiguous variable'
|
'ambiguous variable'
|
||||||
|
'too many instance/class variables'
|
||||||
'inaccessible self'
|
'inaccessible self'
|
||||||
'wrong expression primary'
|
'wrong expression primary'
|
||||||
'too many temporaries'
|
'too many temporaries'
|
||||||
|
@ -2712,16 +2712,33 @@ static MOO_INLINE int set_pooldic_fqn (moo_t* moo, moo_pooldic_t* pd, const moo_
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static MOO_INLINE int add_class_level_variable (moo_t* moo, var_type_t var_type, const moo_oocs_t* name)
|
static MOO_INLINE int add_class_level_variable (moo_t* moo, var_type_t var_type, const moo_oocs_t* name, const moo_ioloc_t* loc)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
n = copy_string_to (moo, name, &moo->c->cls.var[var_type].str, &moo->c->cls.var[var_type].str_capa, 1, ' ');
|
n = copy_string_to (moo, name, &moo->c->cls.var[var_type].str, &moo->c->cls.var[var_type].str_capa, 1, ' ');
|
||||||
if (n >= 0)
|
if (n >= 0)
|
||||||
{
|
{
|
||||||
|
static moo_oow_t varlim[] =
|
||||||
|
{
|
||||||
|
MOO_MAX_NAMED_INSTVARS, /* VAR_INSTANCE */
|
||||||
|
MOO_MAX_CLASSINSTVARS, /* VAR_CLASSINST */
|
||||||
|
MOO_MAX_CLASSVARS, /* VAR_CLASS */
|
||||||
|
};
|
||||||
|
|
||||||
|
MOO_ASSERT (moo, VAR_INSTANCE == 0);
|
||||||
|
MOO_ASSERT (moo, VAR_CLASSINST == 1);
|
||||||
|
MOO_ASSERT (moo, VAR_CLASS == 2);
|
||||||
|
MOO_ASSERT (moo, var_type >= VAR_INSTANCE && var_type <= VAR_CLASS);
|
||||||
|
|
||||||
|
if (moo->c->cls.var[var_type].total_count >= varlim[var_type])
|
||||||
|
{
|
||||||
|
set_syntax_errbfmt (moo, MOO_SYNERR_VARFLOOD, loc, name, "too many ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
moo->c->cls.var[var_type].count++;
|
moo->c->cls.var[var_type].count++;
|
||||||
moo->c->cls.var[var_type].total_count++;
|
moo->c->cls.var[var_type].total_count++;
|
||||||
/* TODO: check if it exceeds MOO_MAX_NAMED_INSTVARS, MOO_MAX_CLASSVARS, MOO_MAX_CLASSINSTVARS */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
@ -3295,7 +3312,7 @@ if super is variable-nonpointer, no instance variable is allowed.
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add_class_level_variable(moo, dcl_type, TOKEN_NAME(moo)) <= -1) return -1;
|
if (add_class_level_variable(moo, dcl_type, TOKEN_NAME(moo), TOKEN_LOC(moo)) <= -1) return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3438,7 +3455,7 @@ if super is variable-nonpointer, no instance variable is allowed.
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add_class_level_variable(moo, dcl_type, TOKEN_NAME(moo)) <= -1) return -1;
|
if (add_class_level_variable(moo, dcl_type, TOKEN_NAME(moo), TOKEN_LOC(moo)) <= -1) return -1;
|
||||||
|
|
||||||
GET_TOKEN (moo);
|
GET_TOKEN (moo);
|
||||||
|
|
||||||
|
@ -123,28 +123,29 @@ static moo_ooch_t synerrstr_46[] = {'u','n','d','e','c','l','a','r','e','d',' ',
|
|||||||
static moo_ooch_t synerrstr_47[] = {'u','n','u','s','a','b','l','e',' ','v','a','r','i','a','b','l','e',' ','i','n',' ','c','o','m','p','i','l','e','d',' ','c','o','d','e','\0'};
|
static moo_ooch_t synerrstr_47[] = {'u','n','u','s','a','b','l','e',' ','v','a','r','i','a','b','l','e',' ','i','n',' ','c','o','m','p','i','l','e','d',' ','c','o','d','e','\0'};
|
||||||
static moo_ooch_t synerrstr_48[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','v','a','r','i','a','b','l','e','\0'};
|
static moo_ooch_t synerrstr_48[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','v','a','r','i','a','b','l','e','\0'};
|
||||||
static moo_ooch_t synerrstr_49[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'};
|
static moo_ooch_t synerrstr_49[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'};
|
||||||
static moo_ooch_t synerrstr_50[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','s','e','l','f','\0'};
|
static moo_ooch_t synerrstr_50[] = {'t','o','o',' ','m','a','n','y',' ','i','n','s','t','a','n','c','e','/','c','l','a','s','s',' ','v','a','r','i','a','b','l','e','s','\0'};
|
||||||
static moo_ooch_t synerrstr_51[] = {'w','r','o','n','g',' ','e','x','p','r','e','s','s','i','o','n',' ','p','r','i','m','a','r','y','\0'};
|
static moo_ooch_t synerrstr_51[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','s','e','l','f','\0'};
|
||||||
static moo_ooch_t synerrstr_52[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
static moo_ooch_t synerrstr_52[] = {'w','r','o','n','g',' ','e','x','p','r','e','s','s','i','o','n',' ','p','r','i','m','a','r','y','\0'};
|
||||||
static moo_ooch_t synerrstr_53[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'};
|
static moo_ooch_t synerrstr_53[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
||||||
static moo_ooch_t synerrstr_54[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
static moo_ooch_t synerrstr_54[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'};
|
||||||
static moo_ooch_t synerrstr_55[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t','s','\0'};
|
static moo_ooch_t synerrstr_55[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
||||||
static moo_ooch_t synerrstr_56[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'};
|
static moo_ooch_t synerrstr_56[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t','s','\0'};
|
||||||
static moo_ooch_t synerrstr_57[] = {'t','o','o',' ','l','a','r','g','e',' ','a','r','r','a','y',' ','e','x','p','r','e','s','s','i','o','n','\0'};
|
static moo_ooch_t synerrstr_57[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'};
|
||||||
static moo_ooch_t synerrstr_58[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','n','u','m','b','e','r','\0'};
|
static moo_ooch_t synerrstr_58[] = {'t','o','o',' ','l','a','r','g','e',' ','a','r','r','a','y',' ','e','x','p','r','e','s','s','i','o','n','\0'};
|
||||||
static moo_ooch_t synerrstr_59[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','i','d','e','n','t','i','f','i','e','r','\0'};
|
static moo_ooch_t synerrstr_59[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','n','u','m','b','e','r','\0'};
|
||||||
static moo_ooch_t synerrstr_60[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','a','r','g','u','m','e','n','t',' ','d','e','f','i','n','i','t','i','o','n','\0'};
|
static moo_ooch_t synerrstr_60[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','i','d','e','n','t','i','f','i','e','r','\0'};
|
||||||
static moo_ooch_t synerrstr_61[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_61[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','a','r','g','u','m','e','n','t',' ','d','e','f','i','n','i','t','i','o','n','\0'};
|
||||||
static moo_ooch_t synerrstr_62[] = {'f','a','i','l','e','d',' ','t','o',' ','i','m','p','o','r','t',' ','m','o','d','u','l','e','\0'};
|
static moo_ooch_t synerrstr_62[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_63[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
|
static moo_ooch_t synerrstr_63[] = {'f','a','i','l','e','d',' ','t','o',' ','i','m','p','o','r','t',' ','m','o','d','u','l','e','\0'};
|
||||||
static moo_ooch_t synerrstr_64[] = {'w','r','o','n','g',' ','p','r','a','g','m','a',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_64[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
|
||||||
static moo_ooch_t synerrstr_65[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_65[] = {'w','r','o','n','g',' ','p','r','a','g','m','a',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_66[] = {'w','r','o','n','g',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_66[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_67[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
|
static moo_ooch_t synerrstr_67[] = {'w','r','o','n','g',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_68[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
|
static moo_ooch_t synerrstr_68[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
|
||||||
static moo_ooch_t synerrstr_69[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','n','o','t',' ','w','i','t','h','i','n',' ','a',' ','l','o','o','p','\0'};
|
static moo_ooch_t synerrstr_69[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
|
||||||
static moo_ooch_t synerrstr_70[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','w','i','t','h','i','n',' ','a',' ','b','l','o','c','k','\0'};
|
static moo_ooch_t synerrstr_70[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','n','o','t',' ','w','i','t','h','i','n',' ','a',' ','l','o','o','p','\0'};
|
||||||
static moo_ooch_t synerrstr_71[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'};
|
static moo_ooch_t synerrstr_71[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','w','i','t','h','i','n',' ','a',' ','b','l','o','c','k','\0'};
|
||||||
|
static moo_ooch_t synerrstr_72[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||||
static moo_ooch_t* synerrstr[] =
|
static moo_ooch_t* synerrstr[] =
|
||||||
{
|
{
|
||||||
synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7,
|
synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7,
|
||||||
@ -155,7 +156,8 @@ static moo_ooch_t* synerrstr[] =
|
|||||||
synerrstr_40, synerrstr_41, synerrstr_42, synerrstr_43, synerrstr_44, synerrstr_45, synerrstr_46, synerrstr_47,
|
synerrstr_40, synerrstr_41, synerrstr_42, synerrstr_43, synerrstr_44, synerrstr_45, synerrstr_46, synerrstr_47,
|
||||||
synerrstr_48, synerrstr_49, synerrstr_50, synerrstr_51, synerrstr_52, synerrstr_53, synerrstr_54, synerrstr_55,
|
synerrstr_48, synerrstr_49, synerrstr_50, synerrstr_51, synerrstr_52, synerrstr_53, synerrstr_54, synerrstr_55,
|
||||||
synerrstr_56, synerrstr_57, synerrstr_58, synerrstr_59, synerrstr_60, synerrstr_61, synerrstr_62, synerrstr_63,
|
synerrstr_56, synerrstr_57, synerrstr_58, synerrstr_59, synerrstr_60, synerrstr_61, synerrstr_62, synerrstr_63,
|
||||||
synerrstr_64, synerrstr_65, synerrstr_66, synerrstr_67, synerrstr_68, synerrstr_69, synerrstr_70, synerrstr_71
|
synerrstr_64, synerrstr_65, synerrstr_66, synerrstr_67, synerrstr_68, synerrstr_69, synerrstr_70, synerrstr_71,
|
||||||
|
synerrstr_72
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
/* END: GENERATED WITH generr.moo */
|
/* END: GENERATED WITH generr.moo */
|
||||||
|
@ -222,7 +222,7 @@ typedef enum moo_method_type_t moo_method_type_t;
|
|||||||
#define MOO_OOP_TAG_EXTENDED 3 /* 11 - internal use only */
|
#define MOO_OOP_TAG_EXTENDED 3 /* 11 - internal use only */
|
||||||
#define MOO_OOP_TAG_CHAR 3 /* 0011 */
|
#define MOO_OOP_TAG_CHAR 3 /* 0011 */
|
||||||
#define MOO_OOP_TAG_ERROR 7 /* 0111 */
|
#define MOO_OOP_TAG_ERROR 7 /* 0111 */
|
||||||
#define MOO_OOP_TAG_HANDLE 11 /* 1011 */
|
#define MOO_OOP_TAG_RESERVED0 11 /* 1011 */
|
||||||
#define MOO_OOP_TAG_RESERVED1 15 /* 1111 */
|
#define MOO_OOP_TAG_RESERVED1 15 /* 1111 */
|
||||||
|
|
||||||
#define MOO_OOP_GET_TAG_LO(oop) (((moo_oow_t)oop) & MOO_LBMASK(moo_oow_t, MOO_OOP_TAG_BITS_LO))
|
#define MOO_OOP_GET_TAG_LO(oop) (((moo_oow_t)oop) & MOO_LBMASK(moo_oow_t, MOO_OOP_TAG_BITS_LO))
|
||||||
@ -244,17 +244,13 @@ typedef enum moo_method_type_t moo_method_type_t;
|
|||||||
#define MOO_SMPTR_TO_OOP(ptr) ((moo_oop_t)(((moo_oow_t)ptr) | MOO_OOP_TAG_SMPTR))
|
#define MOO_SMPTR_TO_OOP(ptr) ((moo_oop_t)(((moo_oow_t)ptr) | MOO_OOP_TAG_SMPTR))
|
||||||
#define MOO_OOP_TO_SMPTR(oop) ((void*)(((moo_oow_t)oop) & ~MOO_LBMASK(moo_oow_t, MOO_OOP_TAG_BITS_LO)))
|
#define MOO_OOP_TO_SMPTR(oop) ((void*)(((moo_oow_t)oop) & ~MOO_LBMASK(moo_oow_t, MOO_OOP_TAG_BITS_LO)))
|
||||||
|
|
||||||
|
|
||||||
#define MOO_OOP_IS_CHAR(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_CHAR)
|
#define MOO_OOP_IS_CHAR(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_CHAR)
|
||||||
#define MOO_OOP_IS_ERROR(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_ERROR)
|
#define MOO_OOP_IS_ERROR(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_ERROR)
|
||||||
#define MOO_OOP_IS_HANDLE(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_HANDLE)
|
|
||||||
|
|
||||||
#define MOO_OOP_TO_CHAR(oop) (((moo_oow_t)oop) >> (MOO_OOP_TAG_BITS_LO + MOO_OOP_TAG_BITS_LO))
|
#define MOO_OOP_TO_CHAR(oop) (((moo_oow_t)oop) >> (MOO_OOP_TAG_BITS_LO + MOO_OOP_TAG_BITS_LO))
|
||||||
#define MOO_CHAR_TO_OOP(num) ((moo_oop_t)((((moo_oow_t)(num)) << (MOO_OOP_TAG_BITS_LO + MOO_OOP_TAG_BITS_LO)) | MOO_OOP_TAG_CHAR))
|
#define MOO_CHAR_TO_OOP(num) ((moo_oop_t)((((moo_oow_t)(num)) << (MOO_OOP_TAG_BITS_LO + MOO_OOP_TAG_BITS_LO)) | MOO_OOP_TAG_CHAR))
|
||||||
#define MOO_OOP_TO_ERROR(oop) (((moo_oow_t)oop) >> (MOO_OOP_TAG_BITS_LO + MOO_OOP_TAG_BITS_LO))
|
#define MOO_OOP_TO_ERROR(oop) (((moo_oow_t)oop) >> (MOO_OOP_TAG_BITS_LO + MOO_OOP_TAG_BITS_LO))
|
||||||
#define MOO_ERROR_TO_OOP(num) ((moo_oop_t)((((moo_oow_t)(num)) << (MOO_OOP_TAG_BITS_LO + MOO_OOP_TAG_BITS_LO)) | MOO_OOP_TAG_ERROR))
|
#define MOO_ERROR_TO_OOP(num) ((moo_oop_t)((((moo_oow_t)(num)) << (MOO_OOP_TAG_BITS_LO + MOO_OOP_TAG_BITS_LO)) | MOO_OOP_TAG_ERROR))
|
||||||
#define MOO_OOP_TO_HANDLE(oop) (((moo_oow_t)oop) >> (MOO_OOP_TAG_BITS_LO + MOO_OOP_TAG_BITS_LO))
|
|
||||||
#define MOO_HANDLE_TO_OOP(num) ((moo_oop_t)((((moo_oow_t)(num)) << (MOO_OOP_TAG_BITS_LO + MOO_OOP_TAG_BITS_LO)) | MOO_OOP_TAG_ERROR))
|
|
||||||
|
|
||||||
/* -------------------------------- */
|
/* -------------------------------- */
|
||||||
|
|
||||||
@ -1562,6 +1558,7 @@ enum moo_synerrnum_t
|
|||||||
MOO_SYNERR_VARUNUSE, /* unsuable variable in compiled code */
|
MOO_SYNERR_VARUNUSE, /* unsuable variable in compiled code */
|
||||||
MOO_SYNERR_VARINACC, /* inaccessible variable - e.g. accessing an instance variable from a class method is not allowed. */
|
MOO_SYNERR_VARINACC, /* inaccessible variable - e.g. accessing an instance variable from a class method is not allowed. */
|
||||||
MOO_SYNERR_VARAMBIG, /* ambiguious variable - e.g. the variable is found in multiple pool dictionaries imported */
|
MOO_SYNERR_VARAMBIG, /* ambiguious variable - e.g. the variable is found in multiple pool dictionaries imported */
|
||||||
|
MOO_SYNERR_VARFLOOD, /* too many instance/class variables */
|
||||||
MOO_SYNERR_SELFINACC, /* inaccessible self */
|
MOO_SYNERR_SELFINACC, /* inaccessible self */
|
||||||
MOO_SYNERR_PRIMARYINVAL, /* wrong expression primary */
|
MOO_SYNERR_PRIMARYINVAL, /* wrong expression primary */
|
||||||
MOO_SYNERR_TMPRFLOOD, /* too many temporaries */
|
MOO_SYNERR_TMPRFLOOD, /* too many temporaries */
|
||||||
|
@ -173,10 +173,10 @@ MOO_INLINE moo_oop_t moo_allocwordobj (moo_t* moo, const moo_oow_t* ptr, moo_oow
|
|||||||
return alloc_numeric_array (moo, ptr, len, MOO_OBJ_TYPE_WORD, MOO_SIZEOF(moo_oow_t), 0);
|
return alloc_numeric_array (moo, ptr, len, MOO_OBJ_TYPE_WORD, MOO_SIZEOF(moo_oow_t), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MOO_INLINE int decode_spec (moo_t* moo, moo_oop_class_t _class, moo_oow_t vlen, moo_obj_type_t* type, moo_oow_t* outlen)
|
static MOO_INLINE int decode_spec (moo_t* moo, moo_oop_class_t _class, moo_oow_t num_flexi_fields, moo_obj_type_t* type, moo_oow_t* outlen)
|
||||||
{
|
{
|
||||||
moo_oow_t spec;
|
moo_oow_t spec;
|
||||||
moo_oow_t named_instvar;
|
moo_oow_t num_fixed_fields;
|
||||||
moo_obj_type_t indexed_type;
|
moo_obj_type_t indexed_type;
|
||||||
|
|
||||||
MOO_ASSERT (moo, MOO_OOP_IS_POINTER(_class));
|
MOO_ASSERT (moo, MOO_OOP_IS_POINTER(_class));
|
||||||
@ -185,63 +185,26 @@ static MOO_INLINE int decode_spec (moo_t* moo, moo_oop_class_t _class, moo_oow_t
|
|||||||
MOO_ASSERT (moo, MOO_OOP_IS_SMOOI(_class->spec));
|
MOO_ASSERT (moo, MOO_OOP_IS_SMOOI(_class->spec));
|
||||||
spec = MOO_OOP_TO_SMOOI(_class->spec);
|
spec = MOO_OOP_TO_SMOOI(_class->spec);
|
||||||
|
|
||||||
named_instvar = MOO_CLASS_SPEC_NAMED_INSTVARS(spec); /* size of the named_instvar part */
|
num_fixed_fields = MOO_CLASS_SPEC_NAMED_INSTVARS(spec);
|
||||||
|
MOO_ASSERT (moo, num_fixed_fields <= MOO_MAX_NAMED_INSTVARS);
|
||||||
|
|
||||||
if (MOO_CLASS_SPEC_IS_INDEXED(spec))
|
if (MOO_CLASS_SPEC_IS_INDEXED(spec))
|
||||||
{
|
{
|
||||||
indexed_type = MOO_CLASS_SPEC_INDEXED_TYPE(spec);
|
indexed_type = MOO_CLASS_SPEC_INDEXED_TYPE(spec);
|
||||||
|
|
||||||
#if 0
|
/* the number of the fixed fields for a non-pointer object are supported.
|
||||||
if (indexed_type == MOO_OBJ_TYPE_OOP)
|
* the fixed fields of a pointer object holds named instance variables
|
||||||
{
|
* and a non-pointer object is facilitated with the fixed fields of the size
|
||||||
if (named_instvar > MOO_MAX_NAMED_INSTVARS)
|
|
||||||
{
|
|
||||||
moo_seterrbfmt (moo, MOO_EINVAL, "too many named instance variables for a variable-pointer class %O - %zu/%zu", _class, named_instvar, (moo_oow_t)MOO_MAX_NAMED_INSTVARS);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (vlen > MOO_MAX_INDEXED_INSTVARS(named_instvar))
|
|
||||||
{
|
|
||||||
moo_seterrbfmt (moo, MOO_EINVAL, "too many unnamed instance variables for a variable-pointer class %O - %zu/%zu", _class, vlen, (moo_oow_t)MOO_MAX_INDEXED_INSTVARS(named_instvar));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOO_ASSERT (moo, named_instvar + vlen <= MOO_OBJ_SIZE_MAX);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* a non-pointer indexed class can't have named instance variables */
|
|
||||||
if (named_instvar > MOO_)
|
|
||||||
{
|
|
||||||
moo_seterrbfmt (moo, MOO_EINVAL, "named instance variables in a variable-nonpointer class %O", _class);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (vlen > MOO_OBJ_SIZE_MAX)
|
|
||||||
{
|
|
||||||
moo_seterrbfmt (moo, MOO_EINVAL, "too many unnamed instance variables for a variable-nonpointer class %O - %zu/%zu", _class, vlen, (moo_oow_t)MOO_OBJ_SIZE_MAX);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* the size of the fixed area for non-pointer objects are supported.
|
|
||||||
* the fixed area of a pointer object holds named instance variables
|
|
||||||
* and a non-pointer object is facilitated with the fixed area of the size
|
|
||||||
* specified in the class description like #byte(5), #word(10).
|
* specified in the class description like #byte(5), #word(10).
|
||||||
*
|
*
|
||||||
* when it comes to spec decoding, there is no different between a pointer
|
* when it comes to spec decoding, there is no difference between a pointer
|
||||||
* object and a non-pointer object */
|
* object and a non-pointer object */
|
||||||
if (named_instvar > MOO_MAX_NAMED_INSTVARS)
|
|
||||||
{
|
|
||||||
moo_seterrbfmt (moo, MOO_EINVAL, "too many fixed fields for a class %O - %zu/%zu", _class, named_instvar, (moo_oow_t)MOO_MAX_NAMED_INSTVARS);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (vlen > MOO_MAX_INDEXED_INSTVARS(named_instvar))
|
|
||||||
{
|
|
||||||
moo_seterrbfmt (moo, MOO_EINVAL, "too many variable fields for a class %O - %zu/%zu", _class, vlen, (moo_oow_t)MOO_MAX_INDEXED_INSTVARS(named_instvar));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOO_ASSERT (moo, named_instvar + vlen <= MOO_OBJ_SIZE_MAX);
|
if (num_flexi_fields > MOO_MAX_INDEXED_INSTVARS(num_fixed_fields))
|
||||||
#endif
|
{
|
||||||
|
moo_seterrbfmt (moo, MOO_EINVAL, "number of flexi-fields(%zu) too big for a class %O", num_flexi_fields, _class);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -249,23 +212,16 @@ static MOO_INLINE int decode_spec (moo_t* moo, moo_oop_class_t _class, moo_oow_t
|
|||||||
* indexable class with no variable data */
|
* indexable class with no variable data */
|
||||||
indexed_type = MOO_OBJ_TYPE_OOP;
|
indexed_type = MOO_OBJ_TYPE_OOP;
|
||||||
|
|
||||||
if (vlen > 0)
|
if (num_flexi_fields > 0)
|
||||||
{
|
{
|
||||||
moo_seterrbfmt (moo, MOO_EINVAL, "unnamed instance variables for a fixed class %O - %zu", _class, vlen);
|
moo_seterrbfmt (moo, MOO_EPERM, "number of flexi-fields(%zu) disallowed for a class %O", num_flexi_fields, _class);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/*vlen = 0;*/ /* vlen is not used */
|
|
||||||
|
|
||||||
if (named_instvar > MOO_MAX_NAMED_INSTVARS)
|
|
||||||
{
|
|
||||||
moo_seterrbfmt (moo, MOO_EINVAL, "too many named instance variables for a fixed class %O - %zu/%zu", _class, named_instvar, (moo_oow_t)MOO_MAX_NAMED_INSTVARS);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
MOO_ASSERT (moo, named_instvar <= MOO_OBJ_SIZE_MAX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MOO_ASSERT (moo, num_fixed_fields + num_flexi_fields <= MOO_OBJ_SIZE_MAX);
|
||||||
*type = indexed_type;
|
*type = indexed_type;
|
||||||
*outlen = named_instvar + vlen;
|
*outlen = num_fixed_fields + num_flexi_fields;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user