X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fabc.c;h=59aa8804f97c403f934d4ef56b1cc288648c43f5;hb=639ac6b9f7a89f10d02c5d9ef41bca3bad4eaf2b;hp=7a7cb88f2669a64862c20865d688e211d750889e;hpb=3dea7306ae2c9590673c10dec1fbabcd6d7e1806;p=swftools.git diff --git a/lib/as3/abc.c b/lib/as3/abc.c index 7a7cb88..59aa880 100644 --- a/lib/as3/abc.c +++ b/lib/as3/abc.c @@ -119,7 +119,8 @@ abc_file_t*abc_file_new() abc_class_t* abc_class_new(abc_file_t*file, multiname_t*classname, multiname_t*superclass) { NEW(abc_class_t,c); - array_append(file->classes, NO_KEY, c); + if(file) + array_append(file->classes, NO_KEY, c); c->file = file; c->classname = multiname_clone(classname); @@ -308,7 +309,7 @@ void abc_method_body_addClassTrait(abc_method_body_t*code, char*multiname, int s /* notice: traits of a method (body) belonging to an init script and traits of the init script are *not* the same thing */ -int abc_initscript_addClassTrait(abc_script_t*script, multiname_t*multiname, abc_class_t*cls) +trait_t* abc_initscript_addClassTrait(abc_script_t*script, multiname_t*multiname, abc_class_t*cls) { abc_file_t*file = script->file; multiname_t*m = multiname_clone(multiname); @@ -316,7 +317,7 @@ int abc_initscript_addClassTrait(abc_script_t*script, multiname_t*multiname, abc trait_t*trait = trait_new(TRAIT_CLASS, m, slotid, 0, 0); trait->cls = cls; list_append(script->traits, trait); - return slotid; + return trait; } abc_script_t* abc_initscript(abc_file_t*file) @@ -345,7 +346,7 @@ static void dump_method(FILE*fo, const char*prefix, if(m->return_type) return_type = multiname_tostring(m->return_type); else - return_type = strdup("void"); + return_type = strdup("*"); fprintf(fo, "%s", prefix); fprintf(fo, "%s %s ", attr, type); @@ -647,6 +648,8 @@ void* swf_DumpABC(FILE*fo, void*code, char*prefix) char*supername = multiname_tostring(cls->superclass); fprintf(fo, " extends %s", supername); free(supername); + } + if(cls->interfaces) { multiname_list_t*ilist = cls->interfaces; if(ilist) fprintf(fo, " implements"); @@ -950,10 +953,10 @@ static pool_t*writeABC(TAG*abctag, void*code, pool_t*pool) // don't bother to set m->index body->method = m; m->body = body; if(c->superclass && c->superclass->name && strcmp(c->superclass->name,"Object")) { - __ getlocal_0(body); - __ constructsuper(body, 0); + body->code = abc_getlocal_0(body->code); + body->code = abc_constructsuper(body->code, 0); } - __ returnvoid(body); + body->code = abc_returnvoid(body->code); c->constructor = m; } else { NEW(abc_method_t,m);array_append(file->methods, NO_KEY, m); @@ -964,7 +967,7 @@ static pool_t*writeABC(TAG*abctag, void*code, pool_t*pool) 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); + body->code = abc_returnvoid(0); c->static_constructor = m; } } @@ -1128,6 +1131,9 @@ static pool_t*writeABC(TAG*abctag, void*code, pool_t*pool) swf_SetU30(tag, file->scripts->num); for(t=0;tscripts->num;t++) { abc_script_t*s = (abc_script_t*)array_getvalue(file->scripts, t); + if(!s->method->body || !s->method->body->code) { + fprintf(stderr, "Internal Error: initscript has no body\n"); + } swf_SetU30(tag, s->method->index); //!=t! traits_write(pool, tag, s->traits); }