X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=lib%2Fas3%2Fparser.y;h=6808ae8000cd6d427324c3aab56846835a76f7b6;hb=1243b55cb5a0fdb7b492aa612de099f35bfeef53;hp=7d5404c07994fd553ce5f52a3309134faecbb72d;hpb=b694bcbd91787709af9775a4334c2847ea90c9ab;p=swftools.git diff --git a/lib/as3/parser.y b/lib/as3/parser.y index 7d5404c..6808ae8 100644 --- a/lib/as3/parser.y +++ b/lib/as3/parser.y @@ -293,7 +293,7 @@ DECLARE_LIST(state); 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) { \ @@ -307,7 +307,7 @@ DECLARE_LIST(state); 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 */ @@ -380,10 +380,6 @@ static void old_state() 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() { @@ -930,8 +926,12 @@ code_t*converttype(code_t*c, classinfo_t*from, classinfo_t*to) 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 { @@ -1232,8 +1232,7 @@ MAYBEELSE: "else" CODEBLOCK {$$=$2;} //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); @@ -1255,8 +1254,7 @@ FOR_INIT : VARIABLE_DECLARATION 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); @@ -1272,8 +1270,7 @@ FOR : "for" '(' {new_state();} FOR_INIT ';' EXPRESSION ';' VOIDEXPRESSION ')' CO } 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); @@ -2084,7 +2081,7 @@ E : "super" '.' T_IDENTIFIER 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); @@ -2107,7 +2104,7 @@ E : E '.' T_IDENTIFIER 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 */