namespace_t m##_ns;\
registry_fill_multiname(&m, &m##_ns, x);
-#define MEMBER_MULTINAME(m,f) \
+#define MEMBER_MULTINAME(m,f,n) \
multiname_t m;\
namespace_t m##_ns;\
if(f) { \
m.type = MULTINAME; \
m.ns =0; \
m.namespace_set = &nopackage_namespace_set; \
- m.name = f->name; \
+ m.name = n; \
}
/* warning: list length of namespace set is undefined */
list_free(oldstate->wildcard_imports);
dict_destroy(oldstate->imports);oldstate->imports=0;
}
- if(state->method)
- state->method->initcode =
- code_append(state->method->initcode,
- oldstate->method->initcode);
}
void initialize_state()
{
code_t*defaultvalue(code_t*c, classinfo_t*type)
{
- if(TYPE_IS_INT(type) || TYPE_IS_UINT(type) || TYPE_IS_FLOAT(type)) {
+ if(TYPE_IS_INT(type)) {
c = abc_pushbyte(c, 0);
+ } else if(TYPE_IS_UINT(type)) {
+ c = abc_pushuint(c, 0);
+ } else if(TYPE_IS_FLOAT(type)) {
+ c = abc_pushnan(c);
} else if(TYPE_IS_BOOLEAN(type)) {
c = abc_pushfalse(c);
} else {
//MAYBEELSE: ';' "else" CODEBLOCK {$$=$3;}
IF : "if" '(' {new_state();} EXPRESSION ')' CODEBLOCK MAYBEELSE {
- $$ = state->method->initcode;state->method->initcode=0;
-
+ $$ = code_new();
$$ = code_append($$, $4.c);
code_t*myjmp,*myif = $$ = abc_iffalse($$, 0);
FOR_INIT : VOIDEXPRESSION
FOR : "for" '(' {new_state();} FOR_INIT ';' EXPRESSION ';' VOIDEXPRESSION ')' CODEBLOCK {
- $$ = state->method->initcode;state->method->initcode=0;
-
+ $$ = code_new();
$$ = code_append($$, $4);
code_t*loopstart = $$ = abc_label($$);
$$ = code_append($$, $6.c);
}
WHILE : "while" '(' {new_state();} EXPRESSION ')' CODEBLOCK {
- $$ = state->method->initcode;state->method->initcode=0;
-
+ $$ = code_new();
code_t*myjmp = $$ = abc_jump($$, 0);
code_t*loopstart = $$ = abc_label($$);
$$ = code_append($$, $6);
memberinfo_t*f = registry_findmember(t, $3);
namespace_t ns = {flags2access(f->flags), ""};
- MEMBER_MULTINAME(m, f);
+ MEMBER_MULTINAME(m, f, $3);
$$.c = 0;
$$.c = abc_getlocal_0($$.c);
$$.c = abc_getsuper2($$.c, &m);
if(f && f->slot && !noslot) {
$$.c = abc_getslot($$.c, f->slot);
} else {
- MEMBER_MULTINAME(m, f);
+ MEMBER_MULTINAME(m, f, $3);
$$.c = abc_getproperty2($$.c, &m);
}
/* determine type */