removed nullmethods
[swftools.git] / lib / as3 / abc.c
index f417e16..f1243d9 100644 (file)
@@ -869,35 +869,24 @@ void swf_WriteABC(TAG*abctag, void*code)
     TAG*tag = tmp;
     int t;
    
-    char need_null_method=0;
     for(t=0;t<file->classes->num;t++) {
        abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
-        if(!c->constructor || !c->static_constructor) {
-            need_null_method=1;
-            break;
+        if(!c->constructor) {
+            NEW(abc_method_t,m);array_append(file->methods, NO_KEY, m);
+            NEW(abc_method_body_t,body);array_append(file->method_bodies, NO_KEY, body);
+            body->method = m; m->body = body;
+            __ returnvoid(body);
+            c->constructor = m;
+        }
+        if(!c->static_constructor) {
+            NEW(abc_method_t,m);array_append(file->methods, NO_KEY, m);
+            NEW(abc_method_body_t,body);array_append(file->method_bodies, NO_KEY, body);
+            body->method = m; m->body = body;
+            __ returnvoid(body);
+            c->static_constructor = m;
         }
     }
 
-    abc_method_t*nullmethod = 0;
-    if(need_null_method) {
-        NEW(abc_method_t,m);
-        nullmethod = m;
-        /*TODO: might be more efficient to have this at the beginning */
-        array_append(file->methods, NO_KEY, nullmethod);
-        
-        NEW(abc_method_body_t,body);
-        body->method = m;
-        m->body = body;
-        __ returnvoid(body);
-        array_append(file->method_bodies, NO_KEY, body);
-    }
-    for(t=0;t<file->classes->num;t++) {
-       abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
-        if(!c->constructor)
-            c->constructor = nullmethod;
-        if(!c->static_constructor)
-            c->static_constructor = nullmethod;
-    }
 
     swf_SetU30(tag, file->methods->num);
     /* enumerate classes, methods and method bodies */
@@ -928,6 +917,8 @@ void swf_WriteABC(TAG*abctag, void*code)
 
        Not sure yet what to do with methods which are used at different
        locations- e.g. the nullmethod is used all over the place.
+       EDIT: flashplayer doesn't allow this anyway- a method can only
+             be used once
 
        Also, I have the strong suspicion that flash player uses only
        the difference between max_scope_stack and init_scope_stack, anyway.
@@ -1034,20 +1025,16 @@ void swf_WriteABC(TAG*abctag, void*code)
             interface = interface->next;
         }
 
-       if(!c->constructor) {
-            swf_SetU30(tag, nullmethod->index);
-       } else {
-           swf_SetU30(tag, c->constructor->index);
-        }
+       assert(c->constructor);
+       swf_SetU30(tag, c->constructor->index);
+
        traits_write(pool, tag, c->traits);
     }
     for(t=0;t<file->classes->num;t++) {
        abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
-       if(!c->static_constructor) {
-            swf_SetU30(tag, nullmethod->index);
-       } else {
-           swf_SetU30(tag, c->static_constructor->index);
-        }
+       assert(c->static_constructor);
+       swf_SetU30(tag, c->static_constructor->index);
+        
         traits_write(pool, tag, c->static_traits);
     }