as3: Ast supports brackets now, too. Fixed Math bug in builtins.c
[swftools.git] / lib / as3 / import.c
index 0fcba24..fb3c7de 100644 (file)
@@ -22,6 +22,8 @@
 #include "import.h"
 #include "abc.h"
 #include "registry.h"
+#include "common.h"
+#include "common.h"
 #include "tokenizer.h"
 #include "../os.h"
 
@@ -58,6 +60,7 @@ void as3_import_swf(char*filename)
         tag = tag->next;
     }
 
+    tag = swf->firstTag;
     /* pass 2 */
     while(tag) {
         if(tag->id == ST_DOABC || tag->id == ST_RAWABC) {
@@ -153,7 +156,7 @@ static void import_code(void*_abc, char*filename, int pass)
                 c->flags |= FLAG_DYNAMIC;
         }
         return;
-    } 
+    }
     
     for(t=0;t<abc->classes->num;t++) {
         abc_class_t*cls = array_getvalue(abc->classes, t);
@@ -173,6 +176,10 @@ static void import_code(void*_abc, char*filename, int pass)
         trait_list_t*l=0;
         char is_static = 0;
         l = cls->traits;
+        if(!l) {
+            l = cls->static_traits;
+            is_static = 1;
+        }
         while(l) {
             trait_t*trait = l->trait;
             U8 access = trait->name->ns->access;
@@ -242,8 +249,10 @@ static void import_code(void*_abc, char*filename, int pass)
                 m = (memberinfo_t*)methodinfo_register_global(access, package, name);
                 m->return_type = resolve_class(filename, "return type", trait->method->return_type);
             } else {
-                m = (memberinfo_t*)varinfo_register_global(access, package, name);
-                m->type = resolve_class(filename, "type", trait->type_name);
+                varinfo_t*v = varinfo_register_global(access, package, name);
+                v->type = resolve_class(filename, "type", trait->type_name);
+                v->value = constant_clone(trait->value);
+                m = (memberinfo_t*)v;
             }
             m->flags |= FLAG_BUILTIN;
             m->parent = 0;