supporting fixed type size specification for a nonpointer variable object like class(#byte(30))). work still in progress
This commit is contained in:
parent
68f67cf595
commit
f4875ba51d
@ -13,23 +13,23 @@ class(#byte) IPAddress(Object)
|
||||
###class(#byte(4)) IP4Address(IPAddress) -> new basicNew always create 4 bytes. size to new: or basicNew: is ignored.
|
||||
###class(#byte(16)) IP6Address(IPAddress)
|
||||
|
||||
class(#byte) IP4Address(IPAddress)
|
||||
class(#byte(4)) IP4Address(IPAddress)
|
||||
{
|
||||
method(#class) new
|
||||
(*method(#class) new
|
||||
{
|
||||
^self basicNew: 4.
|
||||
}
|
||||
}*)
|
||||
|
||||
method(#class) fromString: str
|
||||
{
|
||||
^self new fromString: str.
|
||||
}
|
||||
|
||||
method __fromString: str offset: offset
|
||||
method __fromString: str offset: string_offset offset: address_offset
|
||||
{
|
||||
| dots digits pos size c acc |
|
||||
|
||||
pos := 0.
|
||||
pos := string_offset.
|
||||
size := str size.
|
||||
|
||||
acc := 0.
|
||||
@ -41,7 +41,7 @@ class(#byte) IP4Address(IPAddress)
|
||||
if (pos >= size)
|
||||
{
|
||||
if (dots < 3 or: [digits == 0]) { ^Error.Code.EINVAL }.
|
||||
self basicAt: (dots + offset) put: acc.
|
||||
self basicAt: (dots + address_offset) put: acc.
|
||||
break.
|
||||
}.
|
||||
|
||||
@ -57,7 +57,7 @@ class(#byte) IP4Address(IPAddress)
|
||||
elsif (c = $.)
|
||||
{
|
||||
if (dots >= 3 or: [digits == 0]) { ^Error.Code.EINVAL }.
|
||||
self basicAt: (dots + offset) put: acc.
|
||||
self basicAt: (dots + address_offset) put: acc.
|
||||
dots := dots + 1.
|
||||
acc := 0.
|
||||
digits := 0.
|
||||
@ -79,19 +79,19 @@ class(#byte) IP4Address(IPAddress)
|
||||
|
||||
method fromString: str
|
||||
{
|
||||
if ((self __fromString: str offset: 0) isError)
|
||||
if ((self __fromString: str offset: 0 offset: 0) isError)
|
||||
{
|
||||
Exception signal: ('invalid IPv4 address ' & str).
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class(#byte) IP6Address(IP4Address)
|
||||
class(#byte(16)) IP6Address(IP4Address)
|
||||
{
|
||||
method(#class) new
|
||||
(*method(#class) new
|
||||
{
|
||||
^self basicNew: 16.
|
||||
}
|
||||
}*)
|
||||
|
||||
##method(#class) fromString: str
|
||||
##{
|
||||
@ -164,7 +164,8 @@ class(#byte) IP6Address(IP4Address)
|
||||
|
||||
if (ch == $. and: [tgpos + 4 <= mysize])
|
||||
{
|
||||
if ((super __fromString: (str copyFrom: curseg) offset: tgpos) isError) { ^Error.Code.EINVAL }.
|
||||
##if ((super __fromString: (str copyFrom: curseg) offset:0 offset: tgpos) isError) { ^Error.Code.EINVAL }.
|
||||
if ((super __fromString: str offset: curseg offset: tgpos) isError) { ^Error.Code.EINVAL }.
|
||||
tgpos := tgpos + 4.
|
||||
saw_xdigit := false.
|
||||
break.
|
||||
@ -185,9 +186,6 @@ class(#byte) IP6Address(IP4Address)
|
||||
if (colonpos >= 0)
|
||||
{
|
||||
## double colon position
|
||||
tgpos dump.
|
||||
colonpos dump.
|
||||
'--------' dump.
|
||||
self basicShiftFrom: colonpos to: (colonpos + (mysize - tgpos)) count: (tgpos - colonpos).
|
||||
##tgpos := tgpos + (mysize - tgpos).
|
||||
}
|
||||
@ -381,10 +379,10 @@ s := IP4Address fromString: '192.168.123.232'.
|
||||
s dump.
|
||||
s basicSize dump.
|
||||
|
||||
##s := IP6Address fromString: 'fe80::c225:e9ff:fe47:99.2.3.4'.
|
||||
s := IP6Address fromString: 'fe80::c225:e9ff:fe47:99.2.3.4'.
|
||||
##s := IP6Address fromString: '::99.12.34.54'.
|
||||
s := IP6Address fromString: '::FFFF:0:0'.
|
||||
s := IP6Address fromString: 'fe80::'.
|
||||
##s := IP6Address fromString: '::FFFF:0:0'.
|
||||
##s := IP6Address fromString: 'fe80::'.
|
||||
s dump.
|
||||
s basicSize dump.
|
||||
|
||||
|
@ -79,6 +79,7 @@ class MyObject(Object)
|
||||
'wrong class name'
|
||||
'non-pointer class not allowed to inherit a superclass with trailer size set'
|
||||
'not allowed to inherit a #final class'
|
||||
'invalid class type size'
|
||||
'variable declaration not allowed'
|
||||
'modifier expected'
|
||||
'wrong modifier'
|
||||
|
@ -6928,7 +6928,18 @@ static int make_defined_class (moo_t* moo)
|
||||
flags = 0;
|
||||
if (moo->c->cls.flags & CLASS_INDEXED) flags |= MOO_CLASS_SPEC_FLAG_INDEXED;
|
||||
if (moo->c->cls.flags & CLASS_IMMUTABLE) flags |= MOO_CLASS_SPEC_FLAG_IMMUTABLE;
|
||||
|
||||
if (moo->c->cls.type_size > 0)
|
||||
{
|
||||
MOO_ASSERT (moo, moo->c->cls.var[VAR_INSTANCE].total_count == 0);
|
||||
MOO_ASSERT (moo, moo->c->cls.indexed_type != MOO_OBJ_TYPE_OOP);
|
||||
spec = MOO_CLASS_SPEC_MAKE (moo->c->cls.type_size, flags, moo->c->cls.indexed_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
MOO_ASSERT (moo, moo->c->cls.type_size == 0);
|
||||
spec = MOO_CLASS_SPEC_MAKE (moo->c->cls.var[VAR_INSTANCE].total_count, flags, moo->c->cls.indexed_type);
|
||||
}
|
||||
|
||||
flags = 0;
|
||||
if (moo->c->cls.flags & CLASS_FINAL) flags |= MOO_CLASS_SELFSPEC_FLAG_FINAL;
|
||||
@ -7130,29 +7141,44 @@ static int __compile_class_definition (moo_t* moo, int extend)
|
||||
{
|
||||
do
|
||||
{
|
||||
int permit_type_size = 0;
|
||||
|
||||
if (is_token_symbol(moo, VOCA_BYTE_S))
|
||||
{
|
||||
/* class(#byte) */
|
||||
if (_set_class_indexed_type (moo, MOO_OBJ_TYPE_BYTE) <= -1) return -1;
|
||||
GET_TOKEN (moo);
|
||||
permit_type_size = 1;
|
||||
}
|
||||
else if (is_token_symbol(moo, VOCA_CHARACTER_S))
|
||||
{
|
||||
/* class(#character) */
|
||||
if (_set_class_indexed_type (moo, MOO_OBJ_TYPE_CHAR) <= -1) return -1;
|
||||
GET_TOKEN (moo);
|
||||
permit_type_size = 1;
|
||||
}
|
||||
else if (is_token_symbol(moo, VOCA_HALFWORD_S))
|
||||
{
|
||||
/* class(#halfword) */
|
||||
if (_set_class_indexed_type (moo, MOO_OBJ_TYPE_HALFWORD) <= -1) return -1;
|
||||
GET_TOKEN (moo);
|
||||
permit_type_size = 1;
|
||||
}
|
||||
else if (is_token_symbol(moo, VOCA_WORD_S))
|
||||
{
|
||||
/* class(#word) */
|
||||
if (_set_class_indexed_type (moo, MOO_OBJ_TYPE_WORD) <= -1) return -1;
|
||||
GET_TOKEN (moo);
|
||||
permit_type_size = 1;
|
||||
}
|
||||
else if (is_token_symbol(moo, VOCA_LIWORD_S))
|
||||
{
|
||||
/* class(#liword) -
|
||||
* the liword type maps to one of word or halfword.
|
||||
* see the definiton of MOO_OBJ_TYPE_LIWORD in moo.h */
|
||||
if (_set_class_indexed_type (moo, MOO_OBJ_TYPE_LIWORD) <= -1) return -1;
|
||||
GET_TOKEN (moo);
|
||||
permit_type_size = 1;
|
||||
}
|
||||
else if (is_token_symbol(moo, VOCA_POINTER_S))
|
||||
{
|
||||
@ -7160,12 +7186,6 @@ static int __compile_class_definition (moo_t* moo, int extend)
|
||||
if (_set_class_indexed_type (moo, MOO_OBJ_TYPE_OOP) <= -1) return -1;
|
||||
GET_TOKEN (moo);
|
||||
}
|
||||
else if (is_token_symbol(moo, VOCA_LIWORD_S))
|
||||
{
|
||||
/* class(#liword) */
|
||||
if (_set_class_indexed_type (moo, MOO_OBJ_TYPE_LIWORD) <= -1) return -1;
|
||||
GET_TOKEN (moo);
|
||||
}
|
||||
else if (is_token_symbol(moo, VOCA_FINAL_S))
|
||||
{
|
||||
if (moo->c->cls.flags & CLASS_FINAL)
|
||||
@ -7207,6 +7227,47 @@ static int __compile_class_definition (moo_t* moo, int extend)
|
||||
/* invalid modifier */
|
||||
set_syntax_error (moo, MOO_SYNERR_MODIFIERINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
return -1;
|
||||
}size 16 specified for fixed-sized(4) class IP6Addre
|
||||
|
||||
if (permit_type_size)
|
||||
{
|
||||
/* class(#byte(20))
|
||||
* class(#word(3))
|
||||
* ... */
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_LPAREN)
|
||||
{
|
||||
moo_ooi_t tmp;
|
||||
|
||||
GET_TOKEN (moo);
|
||||
|
||||
if (TOKEN_TYPE(moo) != MOO_IOTOK_NUMLIT && TOKEN_TYPE(moo) != MOO_IOTOK_RADNUMLIT)
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_LITERAL, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (string_to_smooi(moo, TOKEN_NAME(moo), TOKEN_TYPE(moo) == MOO_IOTOK_RADNUMLIT, &tmp) <= -1 ||
|
||||
tmp < 0 || tmp > MOO_MAX_NAMED_INSTVARS)
|
||||
{
|
||||
/* the class type size has nothing to do with the name instance variables
|
||||
* in the semantics. but it is stored into the named-instvar bits in the
|
||||
* spec field of a class. so i check it against MOO_MAX_NAMED_INSTVARS. */
|
||||
set_syntax_error (moo, MOO_SYNERR_CLASSTSIZEINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
return -1;
|
||||
}
|
||||
|
||||
GET_TOKEN (moo);
|
||||
|
||||
if (TOKEN_TYPE(moo) != MOO_IOTOK_RPAREN)
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_RPAREN, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
return -1;
|
||||
}
|
||||
GET_TOKEN (moo);
|
||||
|
||||
moo->c->cls.type_size = tmp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (TOKEN_TYPE(moo) != MOO_IOTOK_COMMA) break; /* hopefully ) */
|
||||
@ -7363,7 +7424,6 @@ static int __compile_class_definition (moo_t* moo, int extend)
|
||||
|
||||
if (get_variable_info (moo, &moo->c->cls.superfqn, &moo->c->cls.superfqn_loc, superfqn_is_dotted, &var) <= -1) return -1;
|
||||
|
||||
|
||||
if (var.type != VAR_GLOBAL) goto unknown_superclass;
|
||||
if (MOO_CLASSOF(moo, var.u.gbl->value) == moo->_class && MOO_OBJ_GET_FLAGS_KERNEL(var.u.gbl->value) != 1)
|
||||
{
|
||||
@ -7622,6 +7682,7 @@ static int compile_class_definition (moo_t* moo, int extend)
|
||||
/* reset the structure to hold information about a class to be compiled */
|
||||
moo->c->cls.flags = 0;
|
||||
moo->c->cls.indexed_type = MOO_OBJ_TYPE_OOP;
|
||||
moo->c->cls.type_size = 0;
|
||||
|
||||
moo->c->cls.name.len = 0;
|
||||
moo->c->cls.fqn.len = 0;
|
||||
|
@ -106,45 +106,46 @@ static moo_ooch_t synerrstr_29[] = {'c','o','n','t','r','a','d','i','c','t','o',
|
||||
static moo_ooch_t synerrstr_30[] = {'w','r','o','n','g',' ','c','l','a','s','s',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_31[] = {'n','o','n','-','p','o','i','n','t','e','r',' ','c','l','a','s','s',' ','n','o','t',' ','a','l','l','o','w','e','d',' ','t','o',' ','i','n','h','e','r','i','t',' ','a',' ','s','u','p','e','r','c','l','a','s','s',' ','w','i','t','h',' ','t','r','a','i','l','e','r',' ','s','i','z','e',' ','s','e','t','\0'};
|
||||
static moo_ooch_t synerrstr_32[] = {'n','o','t',' ','a','l','l','o','w','e','d',' ','t','o',' ','i','n','h','e','r','i','t',' ','a',' ','#','f','i','n','a','l',' ','c','l','a','s','s','\0'};
|
||||
static moo_ooch_t synerrstr_33[] = {'v','a','r','i','a','b','l','e',' ','d','e','c','l','a','r','a','t','i','o','n',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_34[] = {'m','o','d','i','f','i','e','r',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_35[] = {'w','r','o','n','g',' ','m','o','d','i','f','i','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_36[] = {'d','i','s','a','l','l','o','w','e','d',' ','m','o','d','i','f','i','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_37[] = {'d','u','p','l','i','c','a','t','e',' ','m','o','d','i','f','i','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_38[] = {'m','e','t','h','o','d',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_39[] = {'d','u','p','l','i','c','a','t','e',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_40[] = {'i','n','v','a','l','i','d',' ','v','a','r','i','a','d','i','c',' ','m','e','t','h','o','d',' ','d','e','f','i','n','i','t','i','o','n','\0'};
|
||||
static moo_ooch_t synerrstr_41[] = {'v','a','r','i','a','b','l','e',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_42[] = {'d','u','p','l','i','c','a','t','e',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_43[] = {'d','u','p','l','i','c','a','t','e',' ','t','e','m','p','o','r','a','r','y',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_44[] = {'d','u','p','l','i','c','a','t','e',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_45[] = {'d','u','p','l','i','c','a','t','e',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_46[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','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_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_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_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_53[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','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_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_56[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\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_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_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_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_61[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\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_63[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\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_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_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_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_68[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\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_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_71[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_33[] = {'i','n','v','a','l','i','d',' ','c','l','a','s','s',' ','t','y','p','e',' ','s','i','z','e','\0'};
|
||||
static moo_ooch_t synerrstr_34[] = {'v','a','r','i','a','b','l','e',' ','d','e','c','l','a','r','a','t','i','o','n',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_35[] = {'m','o','d','i','f','i','e','r',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_36[] = {'w','r','o','n','g',' ','m','o','d','i','f','i','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_37[] = {'d','i','s','a','l','l','o','w','e','d',' ','m','o','d','i','f','i','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_38[] = {'d','u','p','l','i','c','a','t','e',' ','m','o','d','i','f','i','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_39[] = {'m','e','t','h','o','d',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_40[] = {'d','u','p','l','i','c','a','t','e',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_41[] = {'i','n','v','a','l','i','d',' ','v','a','r','i','a','d','i','c',' ','m','e','t','h','o','d',' ','d','e','f','i','n','i','t','i','o','n','\0'};
|
||||
static moo_ooch_t synerrstr_42[] = {'v','a','r','i','a','b','l','e',' ','n','a','m','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_43[] = {'d','u','p','l','i','c','a','t','e',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_44[] = {'d','u','p','l','i','c','a','t','e',' ','t','e','m','p','o','r','a','r','y',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_45[] = {'d','u','p','l','i','c','a','t','e',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_46[] = {'d','u','p','l','i','c','a','t','e',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_47[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_48[] = {'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_49[] = {'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_50[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\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[] = {'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',' ','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',' ','t','e','m','p','o','r','a','r','i','e','s','\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',' ','b','l','o','c','k','\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',' ','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',' ','i','d','e','n','t','i','f','i','e','r','\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[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\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[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\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',' ','n','a','m','e','s','p','a','c','e',' ','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[] = {'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[] = {'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',' ','n','o','t',' ','w','i','t','h','i','n',' ','a',' ','l','o','o','p','\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[] =
|
||||
{
|
||||
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_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_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
|
||||
/* END: GENERATED WITH generr.moo */
|
||||
|
@ -134,8 +134,8 @@
|
||||
* For example, on a platform where sizeof(moo_oow_t) is 4,
|
||||
* the layout of the spec field of a class as an OOP value looks like this:
|
||||
*
|
||||
* 31 10 9 8 7 6 5 4 3 2 1 0
|
||||
* |number of named instance variables|indexed-type|indexability|oop-tag|
|
||||
* 31 11 10 9 8 7 6 5 4 3 2 1 0
|
||||
* |number of named instance variables|indexed-type|flags|oop-tag|
|
||||
*
|
||||
* the number of named instance variables is stored in high 23 bits.
|
||||
* the indexed type takes up bit 3 to bit 8 (assuming MOO_OBJ_TYPE_BITS is 6.
|
||||
@ -143,7 +143,7 @@
|
||||
* and the indexability is stored in bit 2.
|
||||
*
|
||||
* The maximum number of named(fixed) instance variables for a class is:
|
||||
* 2 ^ ((BITS-IN-OOW - MOO_OOP_TAG_BITS_LO) - MOO_OBJ_TYPE_BITS - 1) - 1
|
||||
* 2 ^ ((BITS-IN-OOW - MOO_OOP_TAG_BITS_LO) - MOO_OBJ_TYPE_BITS - 1 - 2) - 1
|
||||
*
|
||||
* MOO_OOP_TAG_BITS_LO are decremented from the number of bits in OOW because
|
||||
* the spec field is always encoded as a small integer.
|
||||
@ -187,11 +187,9 @@
|
||||
#define MOO_CLASS_SPEC_IS_IMMUTABLE(spec) (MOO_CLASS_SPEC_FLAGS(spec) & MOO_CLASS_SPEC_FLAG_IMMUTABLE)
|
||||
|
||||
/* What is the maximum number of named instance variables?
|
||||
* This limit is set so because the number must be encoded into the spec field
|
||||
* of the class with limited number of bits assigned to the number of
|
||||
* named instance variables. the trailing -1 in the calculation of number of
|
||||
* bits is to consider the sign bit of a small-integer which is a typical
|
||||
* type of the spec field in the class object.
|
||||
* This limit is set this way because the number must be encoded into
|
||||
* the spec field of the class with limited number of bits assigned to
|
||||
* the number of named instance variables.
|
||||
*/
|
||||
#define MOO_MAX_NAMED_INSTVARS \
|
||||
MOO_BITS_MAX(moo_oow_t, MOO_SMOOI_ABS_BITS - (MOO_OBJ_FLAGS_TYPE_BITS + 2))
|
||||
@ -515,6 +513,7 @@ struct moo_compiler_t
|
||||
{
|
||||
int flags;
|
||||
int indexed_type;
|
||||
moo_oow_t type_size; /* fixed type size */
|
||||
|
||||
moo_oop_class_t self_oop;
|
||||
moo_oop_t super_oop; /* this may be nil. so the type is moo_oop_t */
|
||||
|
@ -1545,6 +1545,7 @@ enum moo_synerrnum_t
|
||||
MOO_SYNERR_CLASSNAMEINVAL, /* wrong class name */
|
||||
MOO_SYNERR_CLASSTRSIZE, /* non-pointer class now allowed to inherit a superclass with trailer size set */
|
||||
MOO_SYNERR_CLASSFINAL, /* now allowed to inherit a #final class */
|
||||
MOO_SYNERR_CLASSTSIZEINVAL, /* invalid class type size */
|
||||
MOO_SYNERR_VARDCLBANNED, /* variable declaration not allowed */
|
||||
MOO_SYNERR_MODIFIER, /* modifier expected */
|
||||
MOO_SYNERR_MODIFIERINVAL, /* wrong modifier */
|
||||
|
@ -195,12 +195,12 @@ static MOO_INLINE int decode_spec (moo_t* moo, moo_oop_class_t _class, moo_oow_t
|
||||
{
|
||||
if (named_instvar > MOO_MAX_NAMED_INSTVARS)
|
||||
{
|
||||
MOO_DEBUG3 (moo, "Too many named instance variables for a variable-pointer class %O - %zu/%zu\n", _class, named_instvar, (moo_oow_t)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_DEBUG3 (moo, "Too many unnamed instance variables for a variable-pointer class %O - %zu/%zu\n", _class, vlen, (moo_oow_t)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;
|
||||
}
|
||||
|
||||
@ -209,14 +209,24 @@ static MOO_INLINE int decode_spec (moo_t* moo, moo_oop_class_t _class, moo_oow_t
|
||||
else
|
||||
{
|
||||
/* a non-pointer indexed class can't have named instance variables */
|
||||
#if 0
|
||||
if (named_instvar > 0)
|
||||
{
|
||||
MOO_DEBUG1 (moo, "Named instance variables in a variable-nonpointer class %O\n", _class);
|
||||
moo_seterrbfmt (moo, MOO_EINVAL, "named instance variables in a variable-nonpointer class %O", _class);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (named_instvar > 0 && vlen > 0)
|
||||
{
|
||||
/* disallow the user-defined length if the fixed type size is specified
|
||||
* and it's greater than 0, the user-defined length is not allowed */
|
||||
moo_seterrbfmt (moo, MOO_EINVAL, "size %zu specified for fixed-sized(%zu) class %O", vlen, named_instvar, _class);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
if (vlen > MOO_OBJ_SIZE_MAX)
|
||||
{
|
||||
MOO_DEBUG3 (moo, "Too many unnamed instance variables for a variable-nonpointer class %O - %zu/%zu\n", _class, vlen, (moo_oow_t)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;
|
||||
}
|
||||
}
|
||||
@ -229,14 +239,14 @@ static MOO_INLINE int decode_spec (moo_t* moo, moo_oop_class_t _class, moo_oow_t
|
||||
|
||||
if (vlen > 0)
|
||||
{
|
||||
MOO_DEBUG2 (moo, "Unnamed instance variables for a fixed class %O - %zu\n", _class, vlen);
|
||||
moo_seterrbfmt (moo, MOO_EINVAL, "unnamed instance variables for a fixed class %O - %zu", _class, vlen);
|
||||
return -1;
|
||||
}
|
||||
/*vlen = 0;*/ /* vlen is not used */
|
||||
|
||||
if (named_instvar > MOO_MAX_NAMED_INSTVARS)
|
||||
{
|
||||
MOO_DEBUG3 (moo, "Too many named instance variables for a fixed class %O - %zu/%zu\n", _class, named_instvar, (moo_oow_t)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);
|
||||
@ -256,11 +266,7 @@ moo_oop_t moo_instantiate (moo_t* moo, moo_oop_class_t _class, const void* vptr,
|
||||
|
||||
MOO_ASSERT (moo, moo->_nil != MOO_NULL);
|
||||
|
||||
if (decode_spec (moo, _class, vlen, &type, &alloclen) <= -1)
|
||||
{
|
||||
moo_seterrnum (moo, MOO_EINVAL);
|
||||
return MOO_NULL;
|
||||
}
|
||||
if (decode_spec(moo, _class, vlen, &type, &alloclen) <= -1) return MOO_NULL;
|
||||
|
||||
moo_pushtmp (moo, (moo_oop_t*)&_class); tmp_count++;
|
||||
|
||||
@ -348,11 +354,7 @@ moo_oop_t moo_instantiatewithtrailer (moo_t* moo, moo_oop_class_t _class, moo_oo
|
||||
|
||||
MOO_ASSERT (moo, moo->_nil != MOO_NULL);
|
||||
|
||||
if (decode_spec (moo, _class, vlen, &type, &alloclen) <= -1)
|
||||
{
|
||||
moo_seterrnum (moo, MOO_EINVAL);
|
||||
return MOO_NULL;
|
||||
}
|
||||
if (decode_spec(moo, _class, vlen, &type, &alloclen) <= -1) return MOO_NULL;
|
||||
|
||||
moo_pushtmp (moo, (moo_oop_t*)&_class); tmp_count++;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user