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 */
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.
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);
}
abc_exception_list_t*l = c->exceptions;
while(l) {
// warning: assumes "pos" in each code_t is up-to-date
- swf_SetU30(tag, l->exception->from->pos);
- swf_SetU30(tag, l->exception->to->pos);
- swf_SetU30(tag, l->exception->target->pos);
- swf_SetU30(tag, pool_register_multiname(pool, l->exception->exc_type));
- swf_SetU30(tag, pool_register_multiname(pool, l->exception->var_name));
+ swf_SetU30(tag, l->abc_exception->from->pos);
+ swf_SetU30(tag, l->abc_exception->to->pos);
+ swf_SetU30(tag, l->abc_exception->target->pos);
+ swf_SetU30(tag, pool_register_multiname(pool, l->abc_exception->exc_type));
+ swf_SetU30(tag, pool_register_multiname(pool, l->abc_exception->var_name));
l = l->next;
}
abc_exception_list_t*ee = body->exceptions;
while(ee) {
- abc_exception_t*e=ee->exception;ee->exception=0;
+ abc_exception_t*e=ee->abc_exception;ee->abc_exception=0;
e->from = e->to = e->target = 0;
multiname_destroy(e->exc_type);e->exc_type=0;
multiname_destroy(e->var_name);e->var_name=0;