3 Routines for handling Flash2 AVM2 ABC Actionscript
5 Extension module for the rfxswf library.
6 Part of the swftools package.
8 Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
26 #include "../rfxswf.h"
30 char stringbuffer[2048];
32 int abc_RegisterNameSpace(abc_file_t*file, const char*name);
33 int abc_RegisterPackageNameSpace(abc_file_t*file, const char*name);
34 int abc_RegisterPackageInternalNameSpace(abc_file_t*file, const char*name);
35 int abc_RegisterProtectedNameSpace(abc_file_t*file, const char*name);
36 int abc_RegisterExplicitNameSpace(abc_file_t*file, const char*name);
37 int abc_RegisterStaticProtectedNameSpace(abc_file_t*file, const char*name);
38 int abc_RegisterPrivateNameSpace(abc_file_t*file, const char*name);
40 /* TODO: switch to a datastructure with just values */
43 static char* params_tostring(multiname_list_t*list)
46 int n = list_length(list);
47 char**names = (char**)malloc(sizeof(char*)*n);
53 names[n] = multiname_tostring(l->multiname);
54 size += strlen(names[n]) + 2;
58 char* params = malloc(size+15);
67 strcat(params, names[n]);
75 sprintf(num, "[%d params]", n);
76 strcat(params, num);*/
85 static void parse_metadata(TAG*tag, abc_file_t*file, pool_t*pool)
88 int num_metadata = swf_GetU30(tag);
90 DEBUG printf("%d metadata\n");
91 for(t=0;t<num_metadata;t++) {
92 const char*entry_name = pool_lookup_string(pool, swf_GetU30(tag));
93 int num = swf_GetU30(tag);
95 DEBUG printf(" %s\n", entry_name);
96 array_t*items = array_new();
98 int i1 = swf_GetU30(tag);
99 int i2 = swf_GetU30(tag);
100 const char*key = i1?pool_lookup_string(pool, i1):"";
101 const char*value = i2?pool_lookup_string(pool, i2):"";
102 DEBUG printf(" %s=%s\n", key, value);
103 array_append(items, key, strdup(value));
105 array_append(file->metadata, entry_name, items);
109 void swf_CopyData(TAG*to, TAG*from, int len)
111 unsigned char*data = malloc(len);
112 swf_GetBlock(from, data, len);
113 swf_SetBlock(to, data, len);
117 abc_file_t*abc_file_new()
119 abc_file_t*f = malloc(sizeof(abc_file_t));
120 memset(f, 0, sizeof(abc_file_t));
121 f->metadata = array_new();
123 f->methods = array_new();
124 f->classes = array_new();
125 f->scripts = array_new();
126 f->method_bodies = array_new();
127 f->flags = ABCFILE_LAZY;
132 abc_class_t* abc_class_new(abc_file_t*file, multiname_t*classname, multiname_t*superclass) {
135 array_append(file->classes, NO_KEY, c);
138 c->classname = multiname_clone(classname);
139 c->superclass = multiname_clone(superclass);
142 c->static_constructor = 0;
143 c->traits = list_new();
146 abc_class_t* abc_class_new2(abc_file_t*pool, char*classname, char*superclass)
148 return abc_class_new(pool, multiname_fromstring(classname), multiname_fromstring(superclass));
151 void abc_class_sealed(abc_class_t*c)
153 c->flags |= CLASS_SEALED;
155 void abc_class_final(abc_class_t*c)
157 c->flags |= CLASS_FINAL;
159 void abc_class_interface(abc_class_t*c)
161 c->flags |= CLASS_INTERFACE;
163 void abc_class_protectedNS(abc_class_t*c, char*namespace)
165 c->protectedNS = namespace_new_protected(namespace);
166 c->flags |= CLASS_PROTECTED_NS;
168 void abc_class_add_interface(abc_class_t*c, multiname_t*interface)
170 list_append(c->interfaces, multiname_clone(interface));
173 abc_method_t* abc_method_new(abc_file_t*file, multiname_t*returntype, char body)
175 /* construct method object */
177 m->index = array_length(file->methods);
178 array_append(file->methods, NO_KEY, m);
179 m->return_type = returntype;
182 /* construct code (method body) object */
183 NEW(abc_method_body_t,c);
184 array_append(file->method_bodies, NO_KEY, c);
185 c->index = array_length(file->method_bodies);
187 c->traits = list_new();
190 /* crosslink the two objects */
198 abc_method_t* abc_class_getconstructor(abc_class_t*cls, multiname_t*returntype)
200 if(cls->constructor) {
201 return cls->constructor;
203 abc_method_t* m = abc_method_new(cls->file, returntype, 1);
204 cls->constructor = m;
208 abc_method_t* abc_class_getstaticconstructor(abc_class_t*cls, multiname_t*returntype)
210 if(cls->static_constructor) {
211 return cls->static_constructor;
213 abc_method_t* m = abc_method_new(cls->file, returntype, 1);
214 cls->static_constructor = m;
218 trait_t*trait_new(int type, multiname_t*name, int data1, int data2, constant_t*v)
220 trait_t*trait = malloc(sizeof(trait_t));
221 memset(trait, 0, sizeof(trait_t));
222 trait->kind = type&0x0f;
223 trait->attributes = type&0xf0;
225 trait->data1 = data1;
226 trait->data2 = data2;
230 trait_t*trait_new_member(trait_list_t**traits, multiname_t*type, multiname_t*name,constant_t*v)
232 int kind = TRAIT_SLOT;
233 trait_t*trait = malloc(sizeof(trait_t));
234 memset(trait, 0, sizeof(trait_t));
235 trait->kind = kind&0x0f;
236 trait->attributes = kind&0xf0;
238 trait->type_name = type;
240 trait->slot_id = list_length_(traits)+1;
241 list_append_(traits, trait);
244 trait_t*trait_new_method(trait_list_t**traits, multiname_t*name, abc_method_t*m)
246 int type = TRAIT_METHOD;
247 trait_t*trait = malloc(sizeof(trait_t));
248 memset(trait, 0, sizeof(trait_t));
249 trait->kind = type&0x0f;
250 trait->attributes = type&0xf0;
254 /* start assigning traits at position #1.
255 Weird things happen when assigning slot 0- slot 0 and 1 seem
257 trait->slot_id = list_length_(traits)+1;
258 list_append_(traits, trait);
262 abc_method_t* abc_class_method(abc_class_t*cls, multiname_t*returntype, multiname_t*name)
264 abc_file_t*file = cls->file;
265 abc_method_t* m = abc_method_new(cls->file, returntype, !(cls->flags&CLASS_INTERFACE));
266 m->trait = trait_new_method(&cls->traits, multiname_clone(name), m);
269 abc_method_t* abc_class_staticmethod(abc_class_t*cls, multiname_t*returntype, multiname_t*name)
271 abc_file_t*file = cls->file;
272 abc_method_t* m = abc_method_new(cls->file, returntype, !(cls->flags&CLASS_INTERFACE));
273 m->trait = trait_new_method(&cls->static_traits, multiname_clone(name), m);
277 trait_t* abc_class_slot(abc_class_t*cls, multiname_t*name, multiname_t*type)
279 abc_file_t*file = cls->file;
280 multiname_t*m_name = multiname_clone(name);
281 multiname_t*m_type = multiname_clone(type);
282 trait_t*t = trait_new_member(&cls->traits, m_type, m_name, 0);
285 trait_t* abc_class_staticslot(abc_class_t*cls, multiname_t*name, multiname_t*type)
287 abc_file_t*file = cls->file;
288 multiname_t*m_name = multiname_clone(name);
289 multiname_t*m_type = multiname_clone(type);
290 trait_t*t = trait_new_member(&cls->traits, m_type, m_name, 0);
295 trait_t* abc_class_find_slotid(abc_class_t*cls, int slotid)
299 for(l=cls->traits;l;l=l->next) {
300 if(l->trait->slot_id==slotid) {
308 void abc_method_body_addClassTrait(abc_method_body_t*code, char*multiname, int slotid, abc_class_t*cls)
310 abc_file_t*file = code->file;
311 multiname_t*m = multiname_fromstring(multiname);
312 trait_t*trait = trait_new(TRAIT_CLASS, m, slotid, 0, 0);
314 list_append(code->traits, trait);
317 /* notice: traits of a method (body) belonging to an init script
318 and traits of the init script are *not* the same thing */
319 int abc_initscript_addClassTrait(abc_script_t*script, multiname_t*multiname, abc_class_t*cls)
321 abc_file_t*file = script->file;
322 multiname_t*m = multiname_clone(multiname);
323 int slotid = list_length(script->traits)+1;
324 trait_t*trait = trait_new(TRAIT_CLASS, m, slotid, 0, 0);
326 list_append(script->traits, trait);
330 abc_script_t* abc_initscript(abc_file_t*file, multiname_t*returntype)
332 abc_method_t*m = abc_method_new(file, returntype, 1);
333 abc_script_t* s = malloc(sizeof(abc_script_t));
335 s->traits = list_new();
337 array_append(file->scripts, NO_KEY, s);
341 static void traits_dump(FILE*fo, const char*prefix, trait_list_t*traits, abc_file_t*file, dict_t*methods_seen);
343 static void dump_method(FILE*fo, const char*prefix,
347 abc_method_t*m, abc_file_t*file, dict_t*methods_seen)
350 dict_put(methods_seen, m, 0);
352 char*return_type = 0;
354 return_type = multiname_tostring(m->return_type);
356 return_type = strdup("void");
357 char*paramstr = params_tostring(m->parameters);
358 fprintf(fo, "%s%s%s %s %s=%s %s (%d params, %d optional)\n", prefix, attr, type, return_type, name, m->name, paramstr,
359 list_length(m->parameters),
360 list_length(m->optional_parameters)
362 free(paramstr);paramstr=0;
363 free(return_type);return_type=0;
365 abc_method_body_t*c = m->body;
370 fprintf(fo, "%s[stack:%d locals:%d scope:%d-%d flags:",
371 prefix, c->old.max_stack, c->old.local_count, c->old.init_scope_depth,
372 c->old.max_scope_depth);
375 int flags = c->method->flags;
376 if(flags&METHOD_NEED_ARGUMENTS) {fprintf(fo, " need_arguments");flags&=~METHOD_NEED_ARGUMENTS;}
377 if(flags&METHOD_NEED_ACTIVATION) {fprintf(fo, " need_activation");flags&=~METHOD_NEED_ACTIVATION;}
378 if(flags&METHOD_NEED_REST) {fprintf(fo, " need_rest");flags&=~METHOD_NEED_REST;}
379 if(flags&METHOD_HAS_OPTIONAL) {fprintf(fo, " has_optional");flags&=~METHOD_HAS_OPTIONAL;}
380 if(flags&METHOD_SET_DXNS) {fprintf(fo, " set_dxns");flags&=~METHOD_SET_DXNS;}
381 if(flags&METHOD_HAS_PARAM_NAMES) {fprintf(fo, " has_param_names");flags&=~METHOD_HAS_PARAM_NAMES;}
382 if(flags) fprintf(fo, " %02x", flags);
386 fprintf(fo, " slot:%d", m->trait->slot_id);
392 sprintf(prefix2, "%s ", prefix);
394 traits_dump(fo, prefix, c->traits, file, methods_seen);
395 fprintf(fo, "%s{\n", prefix);
396 code_dump(c->code, c->exceptions, file, prefix2, fo);
397 fprintf(fo, "%s}\n\n", prefix);
400 static void traits_free(trait_list_t*traits)
402 trait_list_t*t = traits;
405 multiname_destroy(t->trait->name);t->trait->name = 0;
407 if(t->trait->kind == TRAIT_SLOT || t->trait->kind == TRAIT_CONST) {
408 multiname_destroy(t->trait->type_name);
410 if(t->trait->value) {
411 constant_free(t->trait->value);t->trait->value = 0;
413 free(t->trait);t->trait = 0;
419 static char trait_is_method(trait_t*trait)
421 return (trait->kind == TRAIT_METHOD || trait->kind == TRAIT_GETTER ||
422 trait->kind == TRAIT_SETTER || trait->kind == TRAIT_FUNCTION);
425 static trait_list_t* traits_parse(TAG*tag, pool_t*pool, abc_file_t*file)
427 int num_traits = swf_GetU30(tag);
428 trait_list_t*traits = list_new();
431 DEBUG printf("%d traits\n", num_traits);
434 for(t=0;t<num_traits;t++) {
436 list_append(traits, trait);
438 trait->name = multiname_clone(pool_lookup_multiname(pool, swf_GetU30(tag))); // always a QName (ns,name)
441 DEBUG name = multiname_tostring(trait->name);
442 U8 kind = swf_GetU8(tag);
443 U8 attributes = kind&0xf0;
446 trait->attributes = attributes;
447 DEBUG printf(" trait %d) %s type=%02x\n", t, name, kind);
448 if(kind == TRAIT_METHOD || kind == TRAIT_GETTER || kind == TRAIT_SETTER) { // method / getter / setter
449 trait->disp_id = swf_GetU30(tag);
450 trait->method = (abc_method_t*)array_getvalue(file->methods, swf_GetU30(tag));
451 trait->method->trait = trait;
452 DEBUG printf(" method/getter/setter\n");
453 } else if(kind == TRAIT_FUNCTION) { // function
454 trait->slot_id = swf_GetU30(tag);
455 trait->method = (abc_method_t*)array_getvalue(file->methods, swf_GetU30(tag));
456 trait->method->trait = trait;
457 } else if(kind == TRAIT_CLASS) { // class
458 trait->slot_id = swf_GetU30(tag);
459 trait->cls = (abc_class_t*)array_getvalue(file->classes, swf_GetU30(tag));
460 DEBUG printf(" class %s %d %d\n", name, trait->slot_id, trait->cls);
461 } else if(kind == TRAIT_SLOT || kind == TRAIT_CONST) { // slot, const
462 /* a slot is a variable in a class that is shared amonst all instances
463 of the same type, but which has a unique location in each object
464 (in other words, slots are non-static, traits are static)
466 trait->slot_id = swf_GetU30(tag);
467 trait->type_name = multiname_clone(pool_lookup_multiname(pool, swf_GetU30(tag)));
468 int vindex = swf_GetU30(tag);
470 int vkind = swf_GetU8(tag);
471 trait->value = constant_fromindex(pool, vindex, vkind);
473 DEBUG printf(" slot %s %d %s (%s)\n", name, trait->slot_id, trait->type_name->name, constant_tostring(trait->value));
475 fprintf(stderr, "Can't parse trait type %d\n", kind);
477 if(attributes&0x40) {
478 int num = swf_GetU30(tag);
481 swf_GetU30(tag); //index into metadata array
488 void traits_skip(TAG*tag)
490 int num_traits = swf_GetU30(tag);
492 for(t=0;t<num_traits;t++) {
494 U8 kind = swf_GetU8(tag);
495 U8 attributes = kind&0xf0;
499 if(kind == TRAIT_SLOT || kind == TRAIT_CONST) {
500 if(swf_GetU30(tag)) swf_GetU8(tag);
501 } else if(kind>TRAIT_CONST) {
502 fprintf(stderr, "Can't parse trait type %d\n", kind);
504 if(attributes&0x40) {
505 int s, num = swf_GetU30(tag);
506 for(s=0;s<num;s++) swf_GetU30(tag);
512 static void traits_write(pool_t*pool, TAG*tag, trait_list_t*traits)
518 swf_SetU30(tag, list_length(traits));
522 trait_t*trait = traits->trait;
524 swf_SetU30(tag, pool_register_multiname(pool, trait->name));
525 swf_SetU8(tag, trait->kind|trait->attributes);
527 swf_SetU30(tag, trait->data1);
529 if(trait->kind == TRAIT_CLASS) {
530 swf_SetU30(tag, trait->cls->index);
531 } else if(trait->kind == TRAIT_GETTER ||
532 trait->kind == TRAIT_SETTER ||
533 trait->kind == TRAIT_METHOD) {
534 swf_SetU30(tag, trait->method->index);
535 } else if(trait->kind == TRAIT_SLOT ||
536 trait->kind == TRAIT_CONST) {
537 int index = pool_register_multiname(pool, trait->type_name);
538 swf_SetU30(tag, index);
540 swf_SetU30(tag, trait->data2);
543 if(trait->kind == TRAIT_SLOT || trait->kind == TRAIT_CONST) {
544 int vindex = constant_get_index(pool, trait->value);
545 swf_SetU30(tag, vindex);
547 swf_SetU8(tag, trait->value->type);
550 if(trait->attributes&0x40) {
554 traits = traits->next;
559 static void traits_dump(FILE*fo, const char*prefix, trait_list_t*traits, abc_file_t*file, dict_t*methods_seen)
563 trait_t*trait = traits->trait;
564 char*name = multiname_tostring(trait->name);
565 U8 kind = trait->kind;
566 U8 attributes = trait->attributes;
568 char a = attributes & (TRAIT_ATTR_OVERRIDE|TRAIT_ATTR_FINAL);
570 if(a==TRAIT_ATTR_FINAL)
572 else if(a==TRAIT_ATTR_OVERRIDE)
574 else if(a==(TRAIT_ATTR_OVERRIDE|TRAIT_ATTR_FINAL))
575 type = "final override ";
577 if(attributes&TRAIT_ATTR_METADATA)
578 fprintf(fo, "<metadata>");
580 if(kind == TRAIT_METHOD) {
581 abc_method_t*m = trait->method;
582 dump_method(fo, prefix, type, "method", name, m, file, methods_seen);
583 } else if(kind == TRAIT_GETTER) {
584 abc_method_t*m = trait->method;
585 dump_method(fo, prefix, type, "getter", name, m, file, methods_seen);
586 } else if(kind == TRAIT_SETTER) {
587 abc_method_t*m = trait->method;
588 dump_method(fo, prefix, type, "setter", name, m, file, methods_seen);
589 } else if(kind == TRAIT_FUNCTION) { // function
590 abc_method_t*m = trait->method;
591 dump_method(fo, prefix, type, "function", name, m, file, methods_seen);
592 } else if(kind == TRAIT_CLASS) { // class
593 abc_class_t*cls = trait->cls;
595 fprintf(fo, "%sslot %d: class %s=00000000\n", prefix, trait->slot_id, name);
597 fprintf(fo, "%sslot %d: class %s=%s\n", prefix, trait->slot_id, name, cls->classname->name);
599 } else if(kind == TRAIT_SLOT || kind == TRAIT_CONST) { // slot, const
600 int slot_id = trait->slot_id;
601 char*type_name = multiname_tostring(trait->type_name);
602 char*value = constant_tostring(trait->value);
603 fprintf(fo, "%sslot %d: %s%s %s %s %s\n", prefix, trait->slot_id,
604 kind==TRAIT_CONST?"const ":"", type_name, name,
605 value?"=":"", value);
606 if(value) free(value);
609 fprintf(fo, "%s can't dump trait type %d\n", prefix, kind);
616 void* swf_DumpABC(FILE*fo, void*code, char*prefix)
618 abc_file_t* file = (abc_file_t*)code;
621 fprintf(fo, "%s#\n", prefix);
622 fprintf(fo, "%s#name: %s\n", prefix, file->name);
623 fprintf(fo, "%s#\n", prefix);
627 for(t=0;t<file->metadata->num;t++) {
628 const char*entry_name = array_getkey(file->metadata, t);
629 fprintf(fo, "%s#Metadata \"%s\":\n", prefix, entry_name);
631 array_t*items = (array_t*)array_getvalue(file->metadata, t);
632 for(s=0;s<items->num;s++) {
633 fprintf(fo, "%s# %s=%s\n", prefix, array_getkey(items, s), array_getvalue(items,s));
635 fprintf(fo, "%s#\n", prefix);
638 dict_t*methods_seen = dict_new2(&ptr_type);
639 for(t=0;t<file->classes->num;t++) {
640 abc_class_t*cls = (abc_class_t*)array_getvalue(file->classes, t);
642 sprintf(prefix2, "%s ", prefix);
644 fprintf(fo, "%s", prefix);
645 if(cls->flags&1) fprintf(fo, "sealed ");
646 if(cls->flags&2) fprintf(fo, "final ");
647 if(cls->flags&4) fprintf(fo, "interface ");
649 char*s = namespace_tostring(cls->protectedNS);
650 fprintf(fo, "protectedNS(%s) ", s);
654 char*classname = multiname_tostring(cls->classname);
655 fprintf(fo, "class %s", classname);
657 if(cls->superclass) {
658 char*supername = multiname_tostring(cls->superclass);
659 fprintf(fo, " extends %s", supername);
661 multiname_list_t*ilist = cls->interfaces;
663 fprintf(fo, " implements");
665 char*s = multiname_tostring(ilist->multiname);
666 fprintf(fo, " %s", s);
673 fprintf(fo, "extra flags=%02x\n", cls->flags&0xf0);
674 fprintf(fo, "%s{\n", prefix);
676 dict_put(methods_seen, cls->static_constructor, 0);
677 dict_put(methods_seen, cls->constructor, 0);
679 if(cls->static_constructor) {
680 dump_method(fo, prefix2, "", "staticconstructor", "", cls->static_constructor, file, methods_seen);
682 traits_dump(fo, prefix2, cls->static_traits, file, methods_seen);
684 char*n = multiname_tostring(cls->classname);
686 dump_method(fo, prefix2, "", "constructor", n, cls->constructor, file, methods_seen);
688 traits_dump(fo, prefix2,cls->traits, file, methods_seen);
689 fprintf(fo, "%s}\n", prefix);
691 fprintf(fo, "%s\n", prefix);
693 for(t=0;t<file->scripts->num;t++) {
694 abc_script_t*s = (abc_script_t*)array_getvalue(file->scripts, t);
695 dump_method(fo, prefix, "", "initmethod", "init", s->method, file, methods_seen);
696 traits_dump(fo, prefix, s->traits, file, methods_seen);
700 for(t=0;t<file->methods->num;t++) {
701 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, t);
702 if(!dict_contains(methods_seen, m)) {
706 fprintf(fo, "%s//internal (non-class non-script) methods:\n", prefix);
709 sprintf(name, "%08x ", m);
710 dump_method(fo, prefix, "", "internalmethod", name, m, file, methods_seen);
713 dict_destroy(methods_seen);
718 void* swf_ReadABC(TAG*tag)
720 abc_file_t* file = abc_file_new();
721 pool_t*pool = pool_new();
723 swf_SetTagPos(tag, 0);
725 if(tag->id == ST_DOABC) {
726 U32 abcflags = swf_GetU32(tag);
727 DEBUG printf("flags=%08x\n", abcflags);
728 char*name= swf_GetString(tag);
729 file->name = (name&&name[0])?strdup(name):0;
731 U32 version = swf_GetU32(tag);
732 if(version!=0x002e0010) {
733 fprintf(stderr, "Warning: unknown AVM2 version %08x\n", version);
736 pool_read(pool, tag);
738 int num_methods = swf_GetU30(tag);
739 DEBUG printf("%d methods\n", num_methods);
740 for(t=0;t<num_methods;t++) {
742 int param_count = swf_GetU30(tag);
743 int return_type_index = swf_GetU30(tag);
744 if(return_type_index)
745 m->return_type = multiname_clone(pool_lookup_multiname(pool, return_type_index));
750 for(s=0;s<param_count;s++) {
751 int type_index = swf_GetU30(tag);
753 /* type_index might be 0, which probably means "..." (varargs) */
754 multiname_t*param = type_index?multiname_clone(pool_lookup_multiname(pool, type_index)):0;
755 list_append(m->parameters, param);
758 int namenr = swf_GetU30(tag);
760 m->name = strdup(pool_lookup_string(pool, namenr));
762 m->name = strdup("");
764 m->flags = swf_GetU8(tag);
766 DEBUG printf("method %d) %s %s flags=%02x\n", t, m->name, params_tostring(m->parameters), m->flags);
769 m->optional_parameters = list_new();
770 int num = swf_GetU30(tag);
773 int vindex = swf_GetU30(tag);
774 U8 vkind = swf_GetU8(tag); // specifies index type for "val"
775 constant_t*c = constant_fromindex(pool, vindex, vkind);
776 list_append(m->optional_parameters, c);
780 /* debug information- not used by avm2 */
781 multiname_list_t*l = m->parameters;
783 const char*name = pool_lookup_string(pool, swf_GetU30(tag));
787 m->index = array_length(file->methods);
788 array_append(file->methods, NO_KEY, m);
791 parse_metadata(tag, file, pool);
793 /* skip classes, and scripts for now, and do the real parsing later */
794 int num_classes = swf_GetU30(tag);
795 int classes_pos = tag->pos;
796 DEBUG printf("%d classes\n", num_classes);
797 for(t=0;t<num_classes;t++) {
798 abc_class_t*cls = malloc(sizeof(abc_class_t));
799 memset(cls, 0, sizeof(abc_class_t));
801 swf_GetU30(tag); //classname
802 swf_GetU30(tag); //supername
804 array_append(file->classes, NO_KEY, cls);
806 cls->flags = swf_GetU8(tag);
807 DEBUG printf("class %d %02x\n", t, cls->flags);
809 swf_GetU30(tag); //protectedNS
811 int inum = swf_GetU30(tag); //interface count
813 for(s=0;s<inum;s++) {
814 int interface_index = swf_GetU30(tag);
815 multiname_t* m = multiname_clone(pool_lookup_multiname(pool, interface_index));
816 list_append(cls->interfaces, m);
817 DEBUG printf(" class %d interface: %s\n", t, m->name);
820 int iinit = swf_GetU30(tag); //iinit
821 DEBUG printf("--iinit-->%d\n", iinit);
824 for(t=0;t<num_classes;t++) {
825 abc_class_t*cls = (abc_class_t*)array_getvalue(file->classes, t);
826 int cinit = swf_GetU30(tag);
827 DEBUG printf("--cinit(%d)-->%d\n", t, cinit);
828 cls->static_constructor = (abc_method_t*)array_getvalue(file->methods, cinit);
831 int num_scripts = swf_GetU30(tag);
832 DEBUG printf("%d scripts\n", num_scripts);
833 for(t=0;t<num_scripts;t++) {
834 int init = swf_GetU30(tag);
838 int num_method_bodies = swf_GetU30(tag);
839 DEBUG printf("%d method bodies\n", num_method_bodies);
840 for(t=0;t<num_method_bodies;t++) {
841 int methodnr = swf_GetU30(tag);
842 if(methodnr >= file->methods->num) {
843 printf("Invalid method number: %d\n", methodnr);
846 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, methodnr);
847 abc_method_body_t*c = malloc(sizeof(abc_method_body_t));
848 memset(c, 0, sizeof(abc_method_body_t));
849 c->old.max_stack = swf_GetU30(tag);
850 c->old.local_count = swf_GetU30(tag);
851 c->old.init_scope_depth = swf_GetU30(tag);
852 c->old.max_scope_depth = swf_GetU30(tag);
854 c->init_scope_depth = c->old.init_scope_depth;
855 int code_length = swf_GetU30(tag);
860 int pos = tag->pos + code_length;
861 codelookup_t*codelookup = 0;
862 c->code = code_parse(tag, code_length, file, pool, &codelookup);
865 int exception_count = swf_GetU30(tag);
867 c->exceptions = list_new();
868 for(s=0;s<exception_count;s++) {
869 abc_exception_t*e = malloc(sizeof(abc_exception_t));
871 e->from = code_atposition(codelookup, swf_GetU30(tag));
872 e->to = code_atposition(codelookup, swf_GetU30(tag));
873 e->target = code_atposition(codelookup, swf_GetU30(tag));
875 e->exc_type = multiname_clone(pool_lookup_multiname(pool, swf_GetU30(tag)));
876 e->var_name = multiname_clone(pool_lookup_multiname(pool, swf_GetU30(tag)));
877 //e->var_name = pool_lookup_string(pool, swf_GetU30(tag));
878 //if(e->var_name) e->var_name = strdup(e->var_name);
879 list_append(c->exceptions, e);
881 codelookup_free(codelookup);
882 c->traits = traits_parse(tag, pool, file);
884 DEBUG printf("method_body %d) (method %d), %d bytes of code\n", t, methodnr, code_length);
886 array_append(file->method_bodies, NO_KEY, c);
888 if(tag->len - tag->pos) {
889 fprintf(stderr, "%d unparsed bytes remaining in ABC block\n", tag->len - tag->pos);
893 swf_SetTagPos(tag, classes_pos);
894 for(t=0;t<num_classes;t++) {
895 abc_class_t*cls = (abc_class_t*)array_getvalue(file->classes, t);
897 int classname_index = swf_GetU30(tag);
898 int superclass_index = swf_GetU30(tag);
899 cls->classname = multiname_clone(pool_lookup_multiname(pool, classname_index));
900 cls->superclass = multiname_clone(pool_lookup_multiname(pool, superclass_index));
901 cls->flags = swf_GetU8(tag);
904 int ns_index = swf_GetU30(tag);
905 cls->protectedNS = namespace_clone(pool_lookup_namespace(pool, ns_index));
908 int num_interfaces = swf_GetU30(tag); //interface count
910 for(s=0;s<num_interfaces;s++) {
913 int iinit = swf_GetU30(tag);
914 cls->constructor = (abc_method_t*)array_getvalue(file->methods, iinit);
915 cls->traits = traits_parse(tag, pool, file);
917 for(t=0;t<num_classes;t++) {
918 abc_class_t*cls = (abc_class_t*)array_getvalue(file->classes, t);
920 swf_GetU30(tag); // cindex
921 cls->static_traits = traits_parse(tag, pool, file);
923 int num_scripts2 = swf_GetU30(tag);
924 for(t=0;t<num_scripts2;t++) {
925 int init = swf_GetU30(tag);
926 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, init);
928 abc_script_t*s = malloc(sizeof(abc_script_t));
929 memset(s, 0, sizeof(abc_script_t));
931 s->traits = traits_parse(tag, pool, file);
932 array_append(file->scripts, NO_KEY, s);
939 void swf_WriteABC(TAG*abctag, void*code)
941 abc_file_t*file = (abc_file_t*)code;
942 pool_t*pool = pool_new();
944 TAG*tmp = swf_InsertTag(0,0);
948 /* add method bodies where needed */
949 for(t=0;t<file->classes->num;t++) {
950 abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
951 if(!c->constructor) {
952 if(!(c->flags&CLASS_INTERFACE)) {
953 NEW(abc_method_t,m);array_append(file->methods, NO_KEY, m);
954 NEW(abc_method_body_t,body);array_append(file->method_bodies, NO_KEY, body);
955 // don't bother to set m->index
956 body->method = m; m->body = body;
960 NEW(abc_method_t,m);array_append(file->methods, NO_KEY, m);
964 if(!c->static_constructor) {
965 NEW(abc_method_t,m);array_append(file->methods, NO_KEY, m);
966 NEW(abc_method_body_t,body);array_append(file->method_bodies, NO_KEY, body);
967 body->method = m; m->body = body;
969 c->static_constructor = m;
974 swf_SetU30(tag, file->methods->num);
975 /* enumerate classes, methods and method bodies */
976 for(t=0;t<file->methods->num;t++) {
977 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, t);
980 for(t=0;t<file->classes->num;t++) {
981 abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
984 for(t=0;t<file->method_bodies->num;t++) {
985 abc_method_body_t*m = (abc_method_body_t*)array_getvalue(file->method_bodies, t);
989 /* generate code statistics */
990 for(t=0;t<file->method_bodies->num;t++) {
991 abc_method_body_t*m = (abc_method_body_t*)array_getvalue(file->method_bodies, t);
992 m->stats = code_get_statistics(m->code, m->exceptions);
995 /* level init scope depths: The init scope depth of a method is
996 always as least as high as the init scope depth of it's surrounding
998 A method has it's own init_scope_depth if it's an init method
999 (then its init scope depth is zero), or if it's used as a closure.
1001 Not sure yet what to do with methods which are used at different
1002 locations- e.g. the nullmethod is used all over the place.
1003 EDIT: flashplayer doesn't allow this anyway- a method can only
1006 Also, I have the strong suspicion that flash player uses only
1007 the difference between max_scope_stack and init_scope_stack, anyway.
1009 for(t=0;t<file->classes->num;t++) {
1010 abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
1011 trait_list_t*traits = c->traits;
1012 if(c->constructor && c->constructor->body &&
1013 c->constructor->body->init_scope_depth < c->init_scope_depth) {
1014 c->constructor->body->init_scope_depth = c->init_scope_depth;
1016 if(c->static_constructor && c->static_constructor->body &&
1017 c->static_constructor->body->init_scope_depth < c->init_scope_depth) {
1018 c->static_constructor->body->init_scope_depth = c->init_scope_depth;
1021 trait_t*trait = traits->trait;
1022 if(trait_is_method(trait) && trait->method->body) {
1023 abc_method_body_t*body = trait->method->body;
1024 if(body->init_scope_depth < c->init_scope_depth) {
1025 body->init_scope_depth = c->init_scope_depth;
1028 traits = traits->next;
1032 for(t=0;t<file->methods->num;t++) {
1033 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, t);
1035 multiname_list_t*l = m->parameters;
1036 int num_params = list_length(m->parameters);
1037 swf_SetU30(tag, num_params);
1039 swf_SetU30(tag, pool_register_multiname(pool, m->return_type));
1044 swf_SetU30(tag, pool_register_multiname(pool, l->multiname));
1048 swf_SetU30(tag, pool_register_string(pool, m->name));
1053 U8 flags = m->flags&(METHOD_NEED_REST|METHOD_NEED_ARGUMENTS);
1054 if(m->optional_parameters)
1055 flags |= METHOD_HAS_OPTIONAL;
1057 flags |= m->body->stats->flags;
1060 swf_SetU8(tag, flags);
1061 if(flags&METHOD_HAS_OPTIONAL) {
1062 swf_SetU30(tag, list_length(m->optional_parameters));
1063 constant_list_t*l = m->optional_parameters;
1065 swf_SetU30(tag, constant_get_index(pool, l->constant));
1066 swf_SetU8(tag, l->constant->type);
1072 /* write metadata */
1073 swf_SetU30(tag, file->metadata->num);
1074 for(t=0;t<file->metadata->num;t++) {
1075 const char*entry_name = array_getkey(file->metadata, t);
1076 swf_SetU30(tag, pool_register_string(pool, entry_name));
1077 array_t*items = (array_t*)array_getvalue(file->metadata, t);
1078 swf_SetU30(tag, items->num);
1080 for(s=0;s<items->num;s++) {
1081 int i1 = pool_register_string(pool, array_getkey(items, s));
1082 int i2 = pool_register_string(pool, array_getvalue(items, s));
1083 swf_SetU30(tag, i1);
1084 swf_SetU30(tag, i2);
1088 swf_SetU30(tag, file->classes->num);
1089 for(t=0;t<file->classes->num;t++) {
1090 abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
1092 int classname_index = pool_register_multiname(pool, c->classname);
1093 int superclass_index = pool_register_multiname(pool, c->superclass);
1095 swf_SetU30(tag, classname_index);
1096 swf_SetU30(tag, superclass_index);
1098 swf_SetU8(tag, c->flags); // flags
1100 int ns_index = pool_register_namespace(pool, c->protectedNS);
1101 swf_SetU30(tag, ns_index);
1104 swf_SetU30(tag, list_length(c->interfaces));
1105 multiname_list_t*interface= c->interfaces;
1107 swf_SetU30(tag, pool_register_multiname(pool, interface->multiname));
1108 interface = interface->next;
1111 assert(c->constructor);
1112 swf_SetU30(tag, c->constructor->index);
1114 traits_write(pool, tag, c->traits);
1116 for(t=0;t<file->classes->num;t++) {
1117 abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
1118 assert(c->static_constructor);
1119 swf_SetU30(tag, c->static_constructor->index);
1121 traits_write(pool, tag, c->static_traits);
1124 swf_SetU30(tag, file->scripts->num);
1125 for(t=0;t<file->scripts->num;t++) {
1126 abc_script_t*s = (abc_script_t*)array_getvalue(file->scripts, t);
1127 swf_SetU30(tag, s->method->index); //!=t!
1128 traits_write(pool, tag, s->traits);
1131 swf_SetU30(tag, file->method_bodies->num);
1132 for(t=0;t<file->method_bodies->num;t++) {
1133 abc_method_body_t*c = (abc_method_body_t*)array_getvalue(file->method_bodies, t);
1134 abc_method_t*m = c->method;
1135 swf_SetU30(tag, m->index);
1137 //swf_SetU30(tag, c->old.max_stack);
1138 //swf_SetU30(tag, c->old.local_count);
1139 //swf_SetU30(tag, c->old.init_scope_depth);
1140 //swf_SetU30(tag, c->old.max_scope_depth);
1142 swf_SetU30(tag, c->stats->max_stack);
1144 int param_num = list_length(c->method->parameters)+1;
1145 if(c->method->flags&METHOD_NEED_REST)
1147 if(param_num <= c->stats->local_count)
1148 swf_SetU30(tag, c->stats->local_count);
1150 swf_SetU30(tag, param_num);
1152 swf_SetU30(tag, c->init_scope_depth);
1153 swf_SetU30(tag, c->stats->max_scope_depth+
1154 c->init_scope_depth);
1156 code_write(tag, c->code, pool, file);
1158 swf_SetU30(tag, list_length(c->exceptions));
1159 abc_exception_list_t*l = c->exceptions;
1161 // warning: assumes "pos" in each code_t is up-to-date
1162 swf_SetU30(tag, l->abc_exception->from->pos);
1163 swf_SetU30(tag, l->abc_exception->to->pos);
1164 swf_SetU30(tag, l->abc_exception->target->pos);
1165 swf_SetU30(tag, pool_register_multiname(pool, l->abc_exception->exc_type));
1166 swf_SetU30(tag, pool_register_multiname(pool, l->abc_exception->var_name));
1170 traits_write(pool, tag, c->traits);
1173 /* free temporary codestat data again. Notice: If we were to write this
1174 file multiple times, this can also be shifted to abc_file_free() */
1175 for(t=0;t<file->method_bodies->num;t++) {
1176 abc_method_body_t*m = (abc_method_body_t*)array_getvalue(file->method_bodies, t);
1177 codestats_free(m->stats);m->stats=0;
1180 // --- start to write real tag --
1184 if(tag->id == ST_DOABC) {
1185 swf_SetU32(tag, file->flags); // flags
1186 swf_SetString(tag, file->name);
1189 swf_SetU16(tag, 0x10); //version
1190 swf_SetU16(tag, 0x2e);
1192 pool_write(pool, tag);
1194 swf_SetBlock(tag, tmp->data, tmp->len);
1196 swf_DeleteTag(0, tmp);
1200 void abc_file_free(abc_file_t*file)
1203 if(file->metadata) {
1204 for(t=0;t<file->metadata->num;t++) {
1205 array_t*items = (array_t*)array_getvalue(file->metadata, t);
1207 for(s=0;s<items->num;s++) {
1208 free(array_getvalue(items, s));
1212 array_free(file->metadata);file->metadata=0;
1215 for(t=0;t<file->methods->num;t++) {
1216 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, t);
1218 multiname_list_t*param = m->parameters;
1220 multiname_destroy(param->multiname);param->multiname=0;
1221 param = param->next;
1223 list_free(m->parameters);m->parameters=0;
1225 constant_list_t*opt = m->optional_parameters;
1227 constant_free(opt->constant);opt->constant=0;
1230 list_free(m->optional_parameters);m->optional_parameters=0;
1233 free((void*)m->name);m->name=0;
1235 if(m->return_type) {
1236 multiname_destroy(m->return_type);
1240 array_free(file->methods);file->methods=0;
1242 for(t=0;t<file->classes->num;t++) {
1243 abc_class_t*cls = (abc_class_t*)array_getvalue(file->classes, t);
1244 traits_free(cls->traits);cls->traits=0;
1245 traits_free(cls->static_traits);cls->static_traits=0;
1247 if(cls->classname) {
1248 multiname_destroy(cls->classname);
1250 if(cls->superclass) {
1251 multiname_destroy(cls->superclass);
1254 multiname_list_t*i = cls->interfaces;
1256 multiname_destroy(i->multiname);i->multiname=0;
1259 list_free(cls->interfaces);cls->interfaces=0;
1261 if(cls->protectedNS) {
1262 namespace_destroy(cls->protectedNS);
1266 array_free(file->classes);file->classes=0;
1268 for(t=0;t<file->scripts->num;t++) {
1269 abc_script_t*s = (abc_script_t*)array_getvalue(file->scripts, t);
1270 traits_free(s->traits);s->traits=0;
1273 array_free(file->scripts);file->scripts=0;
1275 for(t=0;t<file->method_bodies->num;t++) {
1276 abc_method_body_t*body = (abc_method_body_t*)array_getvalue(file->method_bodies, t);
1277 code_free(body->code);body->code=0;
1278 traits_free(body->traits);body->traits=0;
1280 abc_exception_list_t*ee = body->exceptions;
1282 abc_exception_t*e=ee->abc_exception;ee->abc_exception=0;
1283 e->from = e->to = e->target = 0;
1284 multiname_destroy(e->exc_type);e->exc_type=0;
1285 multiname_destroy(e->var_name);e->var_name=0;
1289 list_free(body->exceptions);body->exceptions=0;
1293 array_free(file->method_bodies);file->method_bodies=0;
1296 free((void*)file->name);file->name=0;
1302 void swf_FreeABC(void*code)
1304 abc_file_t*file= (abc_file_t*)code;
1305 abc_file_free(file);
1308 void swf_AddButtonLinks(SWF*swf, char stop_each_frame, char events)
1311 int has_buttons = 0;
1312 TAG*tag=swf->firstTag;
1314 if(tag->id == ST_SHOWFRAME)
1316 if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2)
1321 abc_file_t*file = abc_file_new();
1322 abc_method_body_t*c = 0;
1324 abc_class_t*cls = abc_class_new2(file, "rfx::MainTimeline", "flash.display::MovieClip");
1325 abc_class_protectedNS(cls, "rfx:MainTimeline");
1327 TAG*abctag = swf_InsertTagBefore(swf, swf->firstTag, ST_DOABC);
1329 tag = swf_InsertTag(abctag, ST_SYMBOLCLASS);
1332 swf_SetString(tag, "rfx.MainTimeline");
1334 c = abc_class_getstaticconstructor(cls, 0)->body;
1335 c->old.max_stack = 1;
1336 c->old.local_count = 1;
1337 c->old.init_scope_depth = 9;
1338 c->old.max_scope_depth = 10;
1344 c = abc_class_getconstructor(cls, 0)->body;
1345 c->old.max_stack = 3;
1346 c->old.local_count = 1;
1347 c->old.init_scope_depth = 10;
1348 c->old.max_scope_depth = 11;
1350 debugfile(c, "constructor.as");
1356 __ constructsuper(c,0);
1358 __ getlex(c, "[package]flash.system::Security");
1359 __ pushstring(c, "*");
1360 __ callpropvoid(c, "[package]::allowDomain", 1);
1362 if(stop_each_frame || has_buttons) {
1364 tag = swf->firstTag;
1365 abc_method_body_t*f = 0; //frame script
1366 while(tag && tag->id!=ST_END) {
1368 char needs_framescript=0;
1369 char buttonname[80];
1370 char functionname[80];
1371 sprintf(framename, "[packageinternal]rfx::frame%d", frame);
1373 if(!f && (tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2 || stop_each_frame)) {
1374 /* make the contructor add a frame script */
1375 __ findpropstrict(c,"[package]::addFrameScript");
1376 __ pushbyte(c,frame);
1377 __ getlex(c,framename);
1378 __ callpropvoid(c,"[package]::addFrameScript",2);
1380 f = abc_class_method(cls, 0, multiname_fromstring(framename))->body;
1381 f->old.max_stack = 3;
1382 f->old.local_count = 1;
1383 f->old.init_scope_depth = 10;
1384 f->old.max_scope_depth = 11;
1385 __ debugfile(f, "framescript.as");
1389 if(stop_each_frame) {
1390 __ findpropstrict(f, "[package]::stop");
1391 __ callpropvoid(f, "[package]::stop", 0);
1395 if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2) {
1396 U16 id = swf_GetDefineID(tag);
1397 sprintf(buttonname, "::button%d", swf_GetDefineID(tag));
1398 __ getlex(f,buttonname);
1399 __ getlex(f,"flash.events::MouseEvent");
1400 __ getproperty(f, "::CLICK");
1401 sprintf(functionname, "::clickbutton%d", swf_GetDefineID(tag));
1402 __ getlex(f,functionname);
1403 __ callpropvoid(f, "::addEventListener" ,2);
1405 needs_framescript = 1;
1407 abc_method_body_t*h =
1408 abc_class_method(cls, 0, multiname_fromstring(functionname))->body;
1409 list_append(h->method->parameters, multiname_fromstring("flash.events::MouseEvent"));
1411 h->old.max_stack = 6;
1412 h->old.local_count = 2;
1413 h->old.init_scope_depth = 10;
1414 h->old.max_scope_depth = 11;
1418 ActionTAG*oldaction = swf_ButtonGetAction(tag);
1419 if(oldaction && oldaction->op == ACTION__GOTOFRAME) {
1420 int framenr = GET16(oldaction->data);
1422 fprintf(stderr, "Warning: Couldn't translate jump to frame %d to flash 9 actionscript\n", framenr);
1425 __ findpropstrict(h,"[package]::gotoAndStop");
1426 __ pushbyte(h,framenr+1);
1427 __ callpropvoid(h,"[package]::gotoAndStop", 1);
1430 sprintf(framename, "frame%d", framenr);
1431 __ getlocal_0(h); //this
1432 __ findpropstrict(h, "[package]flash.events::TextEvent");
1433 __ pushstring(h, "link");
1436 __ pushstring(h, framename);
1437 __ constructprop(h,"[package]flash.events::TextEvent", 4);
1438 __ callpropvoid(h,"[package]::dispatchEvent", 1);
1440 } else if(oldaction && oldaction->op == ACTION__GETURL) {
1442 __ findpropstrict(h,"flash.net::navigateToURL");
1443 __ findpropstrict(h,"flash.net::URLRequest");
1444 // TODO: target _blank
1445 __ pushstring(h,oldaction->data); //url
1446 __ constructprop(h,"flash.net::URLRequest", 1);
1447 __ callpropvoid(h,"flash.net::navigateToURL", 1);
1449 __ getlocal_0(h); //this
1450 __ findpropstrict(h, "[package]flash.events::TextEvent");
1451 __ pushstring(h, "link");
1454 __ pushstring(h,oldaction->data); //url
1455 __ constructprop(h,"[package]flash.events::TextEvent", 4);
1456 __ callpropvoid(h,"[package]::dispatchEvent", 1);
1458 } else if(oldaction) {
1459 fprintf(stderr, "Warning: Couldn't translate button code of button %d to flash 9 abc action\n", id);
1462 swf_ActionFree(oldaction);
1464 if(tag->id == ST_SHOWFRAME) {
1479 tag = swf->firstTag;
1481 if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2) {
1482 char buttonname[80];
1483 sprintf(buttonname, "::button%d", swf_GetDefineID(tag));
1484 multiname_t*s = multiname_fromstring(buttonname);
1485 abc_class_slot(cls, multiname_fromstring(buttonname), s);
1491 abc_script_t*s = abc_initscript(file, 0);
1492 c = s->method->body;
1493 c->old.max_stack = 2;
1494 c->old.local_count = 1;
1495 c->old.init_scope_depth = 1;
1496 c->old.max_scope_depth = 9;
1500 __ getscopeobject(c, 0);
1501 __ getlex(c,"::Object");
1503 __ getlex(c,"flash.events::EventDispatcher");
1505 __ getlex(c,"flash.display::DisplayObject");
1507 __ getlex(c,"flash.display::InteractiveObject");
1509 __ getlex(c,"flash.display::DisplayObjectContainer");
1511 __ getlex(c,"flash.display::Sprite");
1513 __ getlex(c,"flash.display::MovieClip");
1515 __ getlex(c,"flash.display::MovieClip");
1524 __ initproperty(c,"rfx::MainTimeline");
1527 //abc_method_body_addClassTrait(c, "rfx:MainTimeline", 1, cls);
1528 multiname_t*classname = multiname_fromstring("rfx::MainTimeline");
1529 abc_initscript_addClassTrait(s, classname, cls);
1530 multiname_destroy(classname);
1532 swf_WriteABC(abctag, file);