X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fparser.y;h=33ab3de6484c86343de954c063dd0db00b76c901;hb=6e924a7805803518bb3f665b8fb35b1904991d52;hp=ce8f26206905e5367a45e7a3c5c1ea720df4dd09;hpb=780e53f414a281c516c153a578638c4f7414434c;p=swftools.git diff --git a/lib/as3/parser.y b/lib/as3/parser.y index ce8f262..33ab3de 100644 --- a/lib/as3/parser.y +++ b/lib/as3/parser.y @@ -175,7 +175,7 @@ extern int a3_lex(); %type CODEBLOCK MAYBECODE MAYBE_CASE_LIST CASE_LIST DEFAULT CASE SWITCH WITH %type PACKAGE_DECLARATION SLOT_DECLARATION %type FUNCTION_DECLARATION PACKAGE_INITCODE -%type VARIABLE_DECLARATION ONE_VARIABLE VARIABLE_LIST THROW +%type VARIABLE_DECLARATION ONE_VARIABLE VARIABLE_LIST THROW %type CATCH FINALLY %type CATCH_LIST CATCH_FINALLY_LIST %type CLASS_DECLARATION @@ -328,6 +328,7 @@ struct _methodstate { abc_method_t*abc; int var_index; // for inner methods + int slot_index; // for inner methods char is_a_slot; // for inner methods code_t*header; @@ -376,8 +377,10 @@ DECLARE_LIST(state); multiname_t m;\ namespace_t m##_ns;\ if(f) { \ - m##_ns.access = ((slotinfo_t*)(f))->access; \ - m##_ns.name = ""; \ + if((m##_ns.access = ((slotinfo_t*)(f))->access)==ACCESS_NAMESPACE) \ + m##_ns.name = ((slotinfo_t*)(f))->package; \ + else \ + m##_ns.name = ""; \ m.type = QNAME; \ m.ns = &m##_ns; \ m.namespace_set = 0; \ @@ -722,7 +725,7 @@ static code_t* method_header(methodstate_t*m) c = abc_newfunction(c, l->methodstate->abc); c = abc_dup(c); c = abc_setlocal(c, l->methodstate->var_index); - c = abc_setslot(c, l->methodstate->var_index); + c = abc_setslot(c, l->methodstate->slot_index); } else { c = abc_newfunction(c, l->methodstate->abc); c = abc_setlocal(c, l->methodstate->var_index); @@ -817,7 +820,9 @@ static void function_initvars(methodstate_t*m, params_t*params, int flags, char } if(m->uses_slots) { /* as variables and slots share the same number, make sure - that those variable indices are reserved */ + that those variable indices are reserved. It's up to the + optimizer to later shuffle the variables down to lower + indices */ m->variable_count = m->uses_slots; } @@ -833,6 +838,7 @@ static void function_initvars(methodstate_t*m, params_t*params, int flags, char methodstate_t*m = l->methodstate; variable_t* v = new_variable2(m->info->name, TYPE_FUNCTION(m->info), 0, 1); m->var_index = v->index; + m->slot_index = v->index; v->is_inner_method = m; l = l->next; } @@ -1899,7 +1905,7 @@ MAYBECODE: {$$=code_new();} CODE: CODE CODEPIECE {$$=code_append($1,$2);} CODE: CODEPIECE {$$=$1;} -// code which also may appear outside a method +// code which may appear outside of methods CODE_STATEMENT: IMPORT CODE_STATEMENT: FOR CODE_STATEMENT: FOR_IN @@ -1914,7 +1920,7 @@ CODE_STATEMENT: USE_NAMESPACE CODE_STATEMENT: '{' CODE '}' {$$=$2;} CODE_STATEMENT: '{' '}' {$$=0;} -// code which may appear anywhere +// code which may appear in methods CODEPIECE: ';' {$$=0;} CODEPIECE: CODE_STATEMENT CODEPIECE: VARIABLE_DECLARATION @@ -3250,7 +3256,7 @@ E : E '?' E ':' E %prec below_assignment { code_t*j2 = $$.c = abc_jump($$.c, 0); $$.c = j1->branch = abc_label($$.c); $$.c = code_append($$.c, $5.c); - $$.c = converttype($$.c, $3.t, $$.t); + $$.c = converttype($$.c, $5.t, $$.t); $$.c = j2->branch = abc_label($$.c); } @@ -3330,7 +3336,6 @@ E : "super" '.' T_IDENTIFIER if(!t) t = TYPE_OBJECT; memberinfo_t*f = registry_findmember(t, $3, 1); - namespace_t ns = {f->access, ""}; MEMBER_MULTINAME(m, f, $3); $$.c = 0; $$.c = abc_getlocal_0($$.c);