fixed bug in MEMBER_MULTINAME
[swftools.git] / lib / as3 / parser.y
index 7d5404c..6808ae8 100644 (file)
@@ -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 */