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;
231 trait_t*trait_new_member(trait_list_t**traits, multiname_t*type, multiname_t*name,constant_t*v)
233 int kind = TRAIT_SLOT;
234 trait_t*trait = malloc(sizeof(trait_t));
235 memset(trait, 0, sizeof(trait_t));
236 trait->kind = kind&0x0f;
237 trait->attributes = kind&0xf0;
239 trait->type_name = type;
241 trait->slot_id = list_length(*traits)+1;
242 trait_list_t*l = *traits;
243 list_append_(traits, trait);
246 trait_t*trait_new_method(trait_list_t**traits, multiname_t*name, abc_method_t*m)
248 int type = TRAIT_METHOD;
249 trait_t*trait = malloc(sizeof(trait_t));
250 memset(trait, 0, sizeof(trait_t));
251 trait->kind = type&0x0f;
252 trait->attributes = type&0xf0;
256 /* start assigning traits at position #1.
257 Weird things happen when assigning slot 0- slot 0 and 1 seem
259 trait->slot_id = list_length(*traits)+1;
260 list_append_(traits, trait);
264 abc_method_t* abc_class_method(abc_class_t*cls, multiname_t*returntype, multiname_t*name)
266 abc_file_t*file = cls->file;
267 abc_method_t* m = abc_method_new(cls->file, returntype, !(cls->flags&CLASS_INTERFACE));
268 m->trait = trait_new_method(&cls->traits, multiname_clone(name), m);
271 abc_method_t* abc_class_staticmethod(abc_class_t*cls, multiname_t*returntype, multiname_t*name)
273 abc_file_t*file = cls->file;
274 abc_method_t* m = abc_method_new(cls->file, returntype, !(cls->flags&CLASS_INTERFACE));
275 m->trait = trait_new_method(&cls->static_traits, multiname_clone(name), m);
279 trait_t* abc_class_slot(abc_class_t*cls, multiname_t*name, multiname_t*type)
281 abc_file_t*file = cls->file;
282 multiname_t*m_name = multiname_clone(name);
283 multiname_t*m_type = multiname_clone(type);
284 trait_t*t = trait_new_member(&cls->traits, m_type, m_name, 0);
287 trait_t* abc_class_staticslot(abc_class_t*cls, multiname_t*name, multiname_t*type)
289 abc_file_t*file = cls->file;
290 multiname_t*m_name = multiname_clone(name);
291 multiname_t*m_type = multiname_clone(type);
292 trait_t*t = trait_new_member(&cls->traits, m_type, m_name, 0);
297 trait_t* abc_class_find_slotid(abc_class_t*cls, int slotid)
301 for(l=cls->traits;l;l=l->next) {
302 if(l->trait->slot_id==slotid) {
310 void abc_method_body_addClassTrait(abc_method_body_t*code, char*multiname, int slotid, abc_class_t*cls)
312 abc_file_t*file = code->file;
313 multiname_t*m = multiname_fromstring(multiname);
314 trait_t*trait = trait_new(TRAIT_CLASS, m, slotid, 0, 0);
316 list_append(code->traits, trait);
319 /* notice: traits of a method (body) belonging to an init script
320 and traits of the init script are *not* the same thing */
321 int abc_initscript_addClassTrait(abc_script_t*script, multiname_t*multiname, abc_class_t*cls)
323 abc_file_t*file = script->file;
324 multiname_t*m = multiname_clone(multiname);
325 int slotid = list_length(script->traits)+1;
326 trait_t*trait = trait_new(TRAIT_CLASS, m, slotid, 0, 0);
328 list_append(script->traits, trait);
332 abc_script_t* abc_initscript(abc_file_t*file, multiname_t*returntype)
334 abc_method_t*m = abc_method_new(file, returntype, 1);
335 abc_script_t* s = malloc(sizeof(abc_script_t));
337 s->traits = list_new();
339 array_append(file->scripts, NO_KEY, s);
343 static void traits_dump(FILE*fo, const char*prefix, trait_list_t*traits, abc_file_t*file, dict_t*methods_seen);
345 static void dump_method(FILE*fo, const char*prefix,
349 abc_method_t*m, abc_file_t*file, dict_t*methods_seen)
352 dict_put(methods_seen, m, 0);
354 char*return_type = 0;
356 return_type = multiname_tostring(m->return_type);
358 return_type = strdup("void");
359 char*paramstr = params_tostring(m->parameters);
360 fprintf(fo, "%s%s%s %s %s=%s %s (%d params, %d optional)\n", prefix, attr, type, return_type, name, m->name, paramstr,
361 list_length(m->parameters),
362 list_length(m->optional_parameters)
364 free(paramstr);paramstr=0;
365 free(return_type);return_type=0;
367 abc_method_body_t*c = m->body;
372 fprintf(fo, "%s[stack:%d locals:%d scope:%d-%d flags:",
373 prefix, c->old.max_stack, c->old.local_count, c->old.init_scope_depth,
374 c->old.max_scope_depth);
377 int flags = c->method->flags;
378 if(flags&METHOD_NEED_ARGUMENTS) {fprintf(fo, " need_arguments");flags&=~METHOD_NEED_ARGUMENTS;}
379 if(flags&METHOD_NEED_ACTIVATION) {fprintf(fo, " need_activation");flags&=~METHOD_NEED_ACTIVATION;}
380 if(flags&METHOD_NEED_REST) {fprintf(fo, " need_rest");flags&=~METHOD_NEED_REST;}
381 if(flags&METHOD_HAS_OPTIONAL) {fprintf(fo, " has_optional");flags&=~METHOD_HAS_OPTIONAL;}
382 if(flags&METHOD_SET_DXNS) {fprintf(fo, " set_dxns");flags&=~METHOD_SET_DXNS;}
383 if(flags&METHOD_HAS_PARAM_NAMES) {fprintf(fo, " has_param_names");flags&=~METHOD_HAS_PARAM_NAMES;}
384 if(flags) fprintf(fo, " %02x", flags);
388 fprintf(fo, " slot:%d", m->trait->slot_id);
394 sprintf(prefix2, "%s ", prefix);
396 traits_dump(fo, prefix, c->traits, file, methods_seen);
397 fprintf(fo, "%s{\n", prefix);
398 code_dump(c->code, c->exceptions, file, prefix2, fo);
399 fprintf(fo, "%s}\n\n", prefix);
402 static void traits_free(trait_list_t*traits)
404 trait_list_t*t = traits;
407 multiname_destroy(t->trait->name);t->trait->name = 0;
409 if(t->trait->kind == TRAIT_SLOT || t->trait->kind == TRAIT_CONST) {
410 multiname_destroy(t->trait->type_name);
412 if(t->trait->value) {
413 constant_free(t->trait->value);t->trait->value = 0;
415 free(t->trait);t->trait = 0;
421 static char trait_is_method(trait_t*trait)
423 return (trait->kind == TRAIT_METHOD || trait->kind == TRAIT_GETTER ||
424 trait->kind == TRAIT_SETTER || trait->kind == TRAIT_FUNCTION);
427 static trait_list_t* traits_parse(TAG*tag, pool_t*pool, abc_file_t*file)
429 int num_traits = swf_GetU30(tag);
430 trait_list_t*traits = list_new();
433 DEBUG printf("%d traits\n", num_traits);
436 for(t=0;t<num_traits;t++) {
438 list_append(traits, trait);
440 trait->name = multiname_clone(pool_lookup_multiname(pool, swf_GetU30(tag))); // always a QName (ns,name)
443 DEBUG name = multiname_tostring(trait->name);
444 U8 kind = swf_GetU8(tag);
445 U8 attributes = kind&0xf0;
448 trait->attributes = attributes;
449 DEBUG printf(" trait %d) %s type=%02x\n", t, name, kind);
450 if(kind == TRAIT_METHOD || kind == TRAIT_GETTER || kind == TRAIT_SETTER) { // method / getter / setter
451 trait->disp_id = swf_GetU30(tag);
452 trait->method = (abc_method_t*)array_getvalue(file->methods, swf_GetU30(tag));
453 trait->method->trait = trait;
454 DEBUG printf(" method/getter/setter\n");
455 } else if(kind == TRAIT_FUNCTION) { // function
456 trait->slot_id = swf_GetU30(tag);
457 trait->method = (abc_method_t*)array_getvalue(file->methods, swf_GetU30(tag));
458 trait->method->trait = trait;
459 } else if(kind == TRAIT_CLASS) { // class
460 trait->slot_id = swf_GetU30(tag);
461 trait->cls = (abc_class_t*)array_getvalue(file->classes, swf_GetU30(tag));
462 DEBUG printf(" class %s %d %d\n", name, trait->slot_id, trait->cls);
463 } else if(kind == TRAIT_SLOT || kind == TRAIT_CONST) { // slot, const
464 /* a slot is a variable in a class that is shared amonst all instances
465 of the same type, but which has a unique location in each object
466 (in other words, slots are non-static, traits are static)
468 trait->slot_id = swf_GetU30(tag);
469 trait->type_name = multiname_clone(pool_lookup_multiname(pool, swf_GetU30(tag)));
470 int vindex = swf_GetU30(tag);
472 int vkind = swf_GetU8(tag);
473 trait->value = constant_fromindex(pool, vindex, vkind);
475 DEBUG printf(" slot %s %d %s (%s)\n", name, trait->slot_id, trait->type_name->name, constant_tostring(trait->value));
477 fprintf(stderr, "Can't parse trait type %d\n", kind);
479 if(attributes&0x40) {
480 int num = swf_GetU30(tag);
483 swf_GetU30(tag); //index into metadata array
490 void traits_skip(TAG*tag)
492 int num_traits = swf_GetU30(tag);
494 for(t=0;t<num_traits;t++) {
496 U8 kind = swf_GetU8(tag);
497 U8 attributes = kind&0xf0;
501 if(kind == TRAIT_SLOT || kind == TRAIT_CONST) {
502 if(swf_GetU30(tag)) swf_GetU8(tag);
503 } else if(kind>TRAIT_CONST) {
504 fprintf(stderr, "Can't parse trait type %d\n", kind);
506 if(attributes&0x40) {
507 int s, num = swf_GetU30(tag);
508 for(s=0;s<num;s++) swf_GetU30(tag);
514 static void traits_write(pool_t*pool, TAG*tag, trait_list_t*traits)
520 swf_SetU30(tag, list_length(traits));
524 trait_t*trait = traits->trait;
526 swf_SetU30(tag, pool_register_multiname(pool, trait->name));
527 swf_SetU8(tag, trait->kind|trait->attributes);
529 swf_SetU30(tag, trait->data1);
531 if(trait->kind == TRAIT_CLASS) {
532 swf_SetU30(tag, trait->cls->index);
533 } else if(trait->kind == TRAIT_GETTER ||
534 trait->kind == TRAIT_SETTER ||
535 trait->kind == TRAIT_METHOD) {
536 swf_SetU30(tag, trait->method->index);
537 } else if(trait->kind == TRAIT_SLOT ||
538 trait->kind == TRAIT_CONST) {
539 int index = pool_register_multiname(pool, trait->type_name);
540 swf_SetU30(tag, index);
542 swf_SetU30(tag, trait->data2);
545 if(trait->kind == TRAIT_SLOT || trait->kind == TRAIT_CONST) {
546 int vindex = constant_get_index(pool, trait->value);
547 swf_SetU30(tag, vindex);
549 swf_SetU8(tag, trait->value->type);
552 if(trait->attributes&0x40) {
556 traits = traits->next;
561 static void traits_dump(FILE*fo, const char*prefix, trait_list_t*traits, abc_file_t*file, dict_t*methods_seen)
565 trait_t*trait = traits->trait;
566 char*name = multiname_tostring(trait->name);
567 U8 kind = trait->kind;
568 U8 attributes = trait->attributes;
570 char a = attributes & (TRAIT_ATTR_OVERRIDE|TRAIT_ATTR_FINAL);
572 if(a==TRAIT_ATTR_FINAL)
574 else if(a==TRAIT_ATTR_OVERRIDE)
576 else if(a==(TRAIT_ATTR_OVERRIDE|TRAIT_ATTR_FINAL))
577 type = "final override ";
579 if(attributes&TRAIT_ATTR_METADATA)
580 fprintf(fo, "<metadata>");
582 if(kind == TRAIT_METHOD) {
583 abc_method_t*m = trait->method;
584 dump_method(fo, prefix, type, "method", name, m, file, methods_seen);
585 } else if(kind == TRAIT_GETTER) {
586 abc_method_t*m = trait->method;
587 dump_method(fo, prefix, type, "getter", name, m, file, methods_seen);
588 } else if(kind == TRAIT_SETTER) {
589 abc_method_t*m = trait->method;
590 dump_method(fo, prefix, type, "setter", name, m, file, methods_seen);
591 } else if(kind == TRAIT_FUNCTION) { // function
592 abc_method_t*m = trait->method;
593 dump_method(fo, prefix, type, "function", name, m, file, methods_seen);
594 } else if(kind == TRAIT_CLASS) { // class
595 abc_class_t*cls = trait->cls;
597 fprintf(fo, "%sslot %d: class %s=00000000\n", prefix, trait->slot_id, name);
599 fprintf(fo, "%sslot %d: class %s=%s\n", prefix, trait->slot_id, name, cls->classname->name);
601 } else if(kind == TRAIT_SLOT || kind == TRAIT_CONST) { // slot, const
602 int slot_id = trait->slot_id;
603 char*type_name = multiname_tostring(trait->type_name);
604 char*value = constant_tostring(trait->value);
605 fprintf(fo, "%sslot %d: %s%s %s %s %s\n", prefix, trait->slot_id,
606 kind==TRAIT_CONST?"const ":"", type_name, name,
607 value?"=":"", value);
608 if(value) free(value);
611 fprintf(fo, "%s can't dump trait type %d\n", prefix, kind);
618 void* swf_DumpABC(FILE*fo, void*code, char*prefix)
620 abc_file_t* file = (abc_file_t*)code;
623 fprintf(fo, "%s#\n", prefix);
624 fprintf(fo, "%s#name: %s\n", prefix, file->name);
625 fprintf(fo, "%s#\n", prefix);
629 for(t=0;t<file->metadata->num;t++) {
630 const char*entry_name = array_getkey(file->metadata, t);
631 fprintf(fo, "%s#Metadata \"%s\":\n", prefix, entry_name);
633 array_t*items = (array_t*)array_getvalue(file->metadata, t);
634 for(s=0;s<items->num;s++) {
635 fprintf(fo, "%s# %s=%s\n", prefix, array_getkey(items, s), array_getvalue(items,s));
637 fprintf(fo, "%s#\n", prefix);
640 dict_t*methods_seen = dict_new2(&ptr_type);
641 for(t=0;t<file->classes->num;t++) {
642 abc_class_t*cls = (abc_class_t*)array_getvalue(file->classes, t);
644 sprintf(prefix2, "%s ", prefix);
646 fprintf(fo, "%s", prefix);
647 if(cls->flags&1) fprintf(fo, "sealed ");
648 if(cls->flags&2) fprintf(fo, "final ");
649 if(cls->flags&4) fprintf(fo, "interface ");
651 char*s = namespace_tostring(cls->protectedNS);
652 fprintf(fo, "protectedNS(%s) ", s);
656 char*classname = multiname_tostring(cls->classname);
657 fprintf(fo, "class %s", classname);
659 if(cls->superclass) {
660 char*supername = multiname_tostring(cls->superclass);
661 fprintf(fo, " extends %s", supername);
663 multiname_list_t*ilist = cls->interfaces;
665 fprintf(fo, " implements");
667 char*s = multiname_tostring(ilist->multiname);
668 fprintf(fo, " %s", s);
675 fprintf(fo, "extra flags=%02x\n", cls->flags&0xf0);
676 fprintf(fo, "%s{\n", prefix);
678 dict_put(methods_seen, cls->static_constructor, 0);
679 dict_put(methods_seen, cls->constructor, 0);
681 if(cls->static_constructor) {
682 dump_method(fo, prefix2, "", "staticconstructor", "", cls->static_constructor, file, methods_seen);
684 traits_dump(fo, prefix2, cls->static_traits, file, methods_seen);
686 char*n = multiname_tostring(cls->classname);
688 dump_method(fo, prefix2, "", "constructor", n, cls->constructor, file, methods_seen);
690 traits_dump(fo, prefix2,cls->traits, file, methods_seen);
691 fprintf(fo, "%s}\n", prefix);
693 fprintf(fo, "%s\n", prefix);
695 for(t=0;t<file->scripts->num;t++) {
696 abc_script_t*s = (abc_script_t*)array_getvalue(file->scripts, t);
697 dump_method(fo, prefix, "", "initmethod", "init", s->method, file, methods_seen);
698 traits_dump(fo, prefix, s->traits, file, methods_seen);
702 for(t=0;t<file->methods->num;t++) {
703 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, t);
704 if(!dict_contains(methods_seen, m)) {
708 fprintf(fo, "%s//internal (non-class non-script) methods:\n", prefix);
711 sprintf(name, "%08x ", m);
712 dump_method(fo, prefix, "", "internalmethod", name, m, file, methods_seen);
715 dict_destroy(methods_seen);
720 void* swf_ReadABC(TAG*tag)
722 abc_file_t* file = abc_file_new();
723 pool_t*pool = pool_new();
725 swf_SetTagPos(tag, 0);
727 if(tag->id == ST_DOABC) {
728 U32 abcflags = swf_GetU32(tag);
729 DEBUG printf("flags=%08x\n", abcflags);
730 char*name= swf_GetString(tag);
731 file->name = (name&&name[0])?strdup(name):0;
733 U32 version = swf_GetU32(tag);
734 if(version!=0x002e0010) {
735 fprintf(stderr, "Warning: unknown AVM2 version %08x\n", version);
738 pool_read(pool, tag);
740 int num_methods = swf_GetU30(tag);
741 DEBUG printf("%d methods\n", num_methods);
742 for(t=0;t<num_methods;t++) {
744 int param_count = swf_GetU30(tag);
745 int return_type_index = swf_GetU30(tag);
746 if(return_type_index)
747 m->return_type = multiname_clone(pool_lookup_multiname(pool, return_type_index));
752 for(s=0;s<param_count;s++) {
753 int type_index = swf_GetU30(tag);
755 /* type_index might be 0, which probably means "..." (varargs) */
756 multiname_t*param = type_index?multiname_clone(pool_lookup_multiname(pool, type_index)):0;
757 list_append(m->parameters, param);
760 int namenr = swf_GetU30(tag);
762 m->name = strdup(pool_lookup_string(pool, namenr));
764 m->name = strdup("");
766 m->flags = swf_GetU8(tag);
768 DEBUG printf("method %d) %s %s flags=%02x\n", t, m->name, params_tostring(m->parameters), m->flags);
771 m->optional_parameters = list_new();
772 int num = swf_GetU30(tag);
775 int vindex = swf_GetU30(tag);
776 U8 vkind = swf_GetU8(tag); // specifies index type for "val"
777 constant_t*c = constant_fromindex(pool, vindex, vkind);
778 list_append(m->optional_parameters, c);
782 /* debug information- not used by avm2 */
783 multiname_list_t*l = m->parameters;
785 const char*name = pool_lookup_string(pool, swf_GetU30(tag));
789 m->index = array_length(file->methods);
790 array_append(file->methods, NO_KEY, m);
793 parse_metadata(tag, file, pool);
795 /* skip classes, and scripts for now, and do the real parsing later */
796 int num_classes = swf_GetU30(tag);
797 int classes_pos = tag->pos;
798 DEBUG printf("%d classes\n", num_classes);
799 for(t=0;t<num_classes;t++) {
800 abc_class_t*cls = malloc(sizeof(abc_class_t));
801 memset(cls, 0, sizeof(abc_class_t));
803 swf_GetU30(tag); //classname
804 swf_GetU30(tag); //supername
806 array_append(file->classes, NO_KEY, cls);
808 cls->flags = swf_GetU8(tag);
809 DEBUG printf("class %d %02x\n", t, cls->flags);
811 swf_GetU30(tag); //protectedNS
813 int inum = swf_GetU30(tag); //interface count
815 for(s=0;s<inum;s++) {
816 int interface_index = swf_GetU30(tag);
817 multiname_t* m = multiname_clone(pool_lookup_multiname(pool, interface_index));
818 list_append(cls->interfaces, m);
819 DEBUG printf(" class %d interface: %s\n", t, m->name);
822 int iinit = swf_GetU30(tag); //iinit
823 DEBUG printf("--iinit-->%d\n", iinit);
826 for(t=0;t<num_classes;t++) {
827 abc_class_t*cls = (abc_class_t*)array_getvalue(file->classes, t);
828 int cinit = swf_GetU30(tag);
829 DEBUG printf("--cinit(%d)-->%d\n", t, cinit);
830 cls->static_constructor = (abc_method_t*)array_getvalue(file->methods, cinit);
833 int num_scripts = swf_GetU30(tag);
834 DEBUG printf("%d scripts\n", num_scripts);
835 for(t=0;t<num_scripts;t++) {
836 int init = swf_GetU30(tag);
840 int num_method_bodies = swf_GetU30(tag);
841 DEBUG printf("%d method bodies\n", num_method_bodies);
842 for(t=0;t<num_method_bodies;t++) {
843 int methodnr = swf_GetU30(tag);
844 if(methodnr >= file->methods->num) {
845 printf("Invalid method number: %d\n", methodnr);
848 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, methodnr);
849 abc_method_body_t*c = malloc(sizeof(abc_method_body_t));
850 memset(c, 0, sizeof(abc_method_body_t));
851 c->old.max_stack = swf_GetU30(tag);
852 c->old.local_count = swf_GetU30(tag);
853 c->old.init_scope_depth = swf_GetU30(tag);
854 c->old.max_scope_depth = swf_GetU30(tag);
856 c->init_scope_depth = c->old.init_scope_depth;
857 int code_length = swf_GetU30(tag);
862 int pos = tag->pos + code_length;
863 codelookup_t*codelookup = 0;
864 c->code = code_parse(tag, code_length, file, pool, &codelookup);
867 int exception_count = swf_GetU30(tag);
869 c->exceptions = list_new();
870 for(s=0;s<exception_count;s++) {
871 abc_exception_t*e = malloc(sizeof(abc_exception_t));
873 e->from = code_atposition(codelookup, swf_GetU30(tag));
874 e->to = code_atposition(codelookup, swf_GetU30(tag));
875 e->target = code_atposition(codelookup, swf_GetU30(tag));
877 e->exc_type = multiname_clone(pool_lookup_multiname(pool, swf_GetU30(tag)));
878 e->var_name = multiname_clone(pool_lookup_multiname(pool, swf_GetU30(tag)));
879 //e->var_name = pool_lookup_string(pool, swf_GetU30(tag));
880 //if(e->var_name) e->var_name = strdup(e->var_name);
881 list_append(c->exceptions, e);
883 codelookup_free(codelookup);
884 c->traits = traits_parse(tag, pool, file);
886 DEBUG printf("method_body %d) (method %d), %d bytes of code\n", t, methodnr, code_length);
888 array_append(file->method_bodies, NO_KEY, c);
890 if(tag->len - tag->pos) {
891 fprintf(stderr, "%d unparsed bytes remaining in ABC block\n", tag->len - tag->pos);
895 swf_SetTagPos(tag, classes_pos);
896 for(t=0;t<num_classes;t++) {
897 abc_class_t*cls = (abc_class_t*)array_getvalue(file->classes, t);
899 int classname_index = swf_GetU30(tag);
900 int superclass_index = swf_GetU30(tag);
901 cls->classname = multiname_clone(pool_lookup_multiname(pool, classname_index));
902 cls->superclass = multiname_clone(pool_lookup_multiname(pool, superclass_index));
903 cls->flags = swf_GetU8(tag);
906 int ns_index = swf_GetU30(tag);
907 cls->protectedNS = namespace_clone(pool_lookup_namespace(pool, ns_index));
910 int num_interfaces = swf_GetU30(tag); //interface count
912 for(s=0;s<num_interfaces;s++) {
915 int iinit = swf_GetU30(tag);
916 cls->constructor = (abc_method_t*)array_getvalue(file->methods, iinit);
917 cls->traits = traits_parse(tag, pool, file);
919 for(t=0;t<num_classes;t++) {
920 abc_class_t*cls = (abc_class_t*)array_getvalue(file->classes, t);
922 swf_GetU30(tag); // cindex
923 cls->static_traits = traits_parse(tag, pool, file);
925 int num_scripts2 = swf_GetU30(tag);
926 for(t=0;t<num_scripts2;t++) {
927 int init = swf_GetU30(tag);
928 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, init);
930 abc_script_t*s = malloc(sizeof(abc_script_t));
931 memset(s, 0, sizeof(abc_script_t));
933 s->traits = traits_parse(tag, pool, file);
934 array_append(file->scripts, NO_KEY, s);
941 void swf_WriteABC(TAG*abctag, void*code)
943 abc_file_t*file = (abc_file_t*)code;
944 pool_t*pool = pool_new();
946 TAG*tmp = swf_InsertTag(0,0);
950 /* add method bodies where needed */
951 for(t=0;t<file->classes->num;t++) {
952 abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
953 if(!c->constructor) {
954 if(!(c->flags&CLASS_INTERFACE)) {
955 NEW(abc_method_t,m);array_append(file->methods, NO_KEY, m);
956 NEW(abc_method_body_t,body);array_append(file->method_bodies, NO_KEY, body);
957 // don't bother to set m->index
958 body->method = m; m->body = body;
962 NEW(abc_method_t,m);array_append(file->methods, NO_KEY, m);
966 if(!c->static_constructor) {
967 NEW(abc_method_t,m);array_append(file->methods, NO_KEY, m);
968 NEW(abc_method_body_t,body);array_append(file->method_bodies, NO_KEY, body);
969 body->method = m; m->body = body;
971 c->static_constructor = m;
976 swf_SetU30(tag, file->methods->num);
977 /* enumerate classes, methods and method bodies */
978 for(t=0;t<file->methods->num;t++) {
979 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, t);
982 for(t=0;t<file->classes->num;t++) {
983 abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
986 for(t=0;t<file->method_bodies->num;t++) {
987 abc_method_body_t*m = (abc_method_body_t*)array_getvalue(file->method_bodies, t);
991 /* generate code statistics */
992 for(t=0;t<file->method_bodies->num;t++) {
993 abc_method_body_t*m = (abc_method_body_t*)array_getvalue(file->method_bodies, t);
994 m->stats = code_get_statistics(m->code, m->exceptions);
997 /* level init scope depths: The init scope depth of a method is
998 always as least as high as the init scope depth of it's surrounding
1000 A method has it's own init_scope_depth if it's an init method
1001 (then its init scope depth is zero), or if it's used as a closure.
1003 Not sure yet what to do with methods which are used at different
1004 locations- e.g. the nullmethod is used all over the place.
1005 EDIT: flashplayer doesn't allow this anyway- a method can only
1008 Also, I have the strong suspicion that flash player uses only
1009 the difference between max_scope_stack and init_scope_stack, anyway.
1011 for(t=0;t<file->classes->num;t++) {
1012 abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
1013 trait_list_t*traits = c->traits;
1014 if(c->constructor && c->constructor->body &&
1015 c->constructor->body->init_scope_depth < c->init_scope_depth) {
1016 c->constructor->body->init_scope_depth = c->init_scope_depth;
1018 if(c->static_constructor && c->static_constructor->body &&
1019 c->static_constructor->body->init_scope_depth < c->init_scope_depth) {
1020 c->static_constructor->body->init_scope_depth = c->init_scope_depth;
1023 trait_t*trait = traits->trait;
1024 if(trait_is_method(trait) && trait->method->body) {
1025 abc_method_body_t*body = trait->method->body;
1026 if(body->init_scope_depth < c->init_scope_depth) {
1027 body->init_scope_depth = c->init_scope_depth;
1030 traits = traits->next;
1034 for(t=0;t<file->methods->num;t++) {
1035 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, t);
1037 multiname_list_t*l = m->parameters;
1038 int num_params = list_length(m->parameters);
1039 swf_SetU30(tag, num_params);
1041 swf_SetU30(tag, pool_register_multiname(pool, m->return_type));
1046 swf_SetU30(tag, pool_register_multiname(pool, l->multiname));
1050 swf_SetU30(tag, pool_register_string(pool, m->name));
1055 U8 flags = m->flags&(METHOD_NEED_REST|METHOD_NEED_ARGUMENTS);
1056 if(m->optional_parameters)
1057 flags |= METHOD_HAS_OPTIONAL;
1059 flags |= m->body->stats->flags;
1062 swf_SetU8(tag, flags);
1063 if(flags&METHOD_HAS_OPTIONAL) {
1064 swf_SetU30(tag, list_length(m->optional_parameters));
1065 constant_list_t*l = m->optional_parameters;
1067 swf_SetU30(tag, constant_get_index(pool, l->constant));
1068 swf_SetU8(tag, l->constant->type);
1074 /* write metadata */
1075 swf_SetU30(tag, file->metadata->num);
1076 for(t=0;t<file->metadata->num;t++) {
1077 const char*entry_name = array_getkey(file->metadata, t);
1078 swf_SetU30(tag, pool_register_string(pool, entry_name));
1079 array_t*items = (array_t*)array_getvalue(file->metadata, t);
1080 swf_SetU30(tag, items->num);
1082 for(s=0;s<items->num;s++) {
1083 int i1 = pool_register_string(pool, array_getkey(items, s));
1084 int i2 = pool_register_string(pool, array_getvalue(items, s));
1085 swf_SetU30(tag, i1);
1086 swf_SetU30(tag, i2);
1090 swf_SetU30(tag, file->classes->num);
1091 for(t=0;t<file->classes->num;t++) {
1092 abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
1094 int classname_index = pool_register_multiname(pool, c->classname);
1095 int superclass_index = pool_register_multiname(pool, c->superclass);
1097 swf_SetU30(tag, classname_index);
1098 swf_SetU30(tag, superclass_index);
1100 swf_SetU8(tag, c->flags); // flags
1102 int ns_index = pool_register_namespace(pool, c->protectedNS);
1103 swf_SetU30(tag, ns_index);
1106 swf_SetU30(tag, list_length(c->interfaces));
1107 multiname_list_t*interface= c->interfaces;
1109 swf_SetU30(tag, pool_register_multiname(pool, interface->multiname));
1110 interface = interface->next;
1113 assert(c->constructor);
1114 swf_SetU30(tag, c->constructor->index);
1116 traits_write(pool, tag, c->traits);
1118 for(t=0;t<file->classes->num;t++) {
1119 abc_class_t*c = (abc_class_t*)array_getvalue(file->classes, t);
1120 assert(c->static_constructor);
1121 swf_SetU30(tag, c->static_constructor->index);
1123 traits_write(pool, tag, c->static_traits);
1126 swf_SetU30(tag, file->scripts->num);
1127 for(t=0;t<file->scripts->num;t++) {
1128 abc_script_t*s = (abc_script_t*)array_getvalue(file->scripts, t);
1129 swf_SetU30(tag, s->method->index); //!=t!
1130 traits_write(pool, tag, s->traits);
1133 swf_SetU30(tag, file->method_bodies->num);
1134 for(t=0;t<file->method_bodies->num;t++) {
1135 abc_method_body_t*c = (abc_method_body_t*)array_getvalue(file->method_bodies, t);
1136 abc_method_t*m = c->method;
1137 swf_SetU30(tag, m->index);
1139 //swf_SetU30(tag, c->old.max_stack);
1140 //swf_SetU30(tag, c->old.local_count);
1141 //swf_SetU30(tag, c->old.init_scope_depth);
1142 //swf_SetU30(tag, c->old.max_scope_depth);
1144 swf_SetU30(tag, c->stats->max_stack);
1146 int param_num = list_length(c->method->parameters)+1;
1147 if(c->method->flags&METHOD_NEED_REST)
1149 if(param_num <= c->stats->local_count)
1150 swf_SetU30(tag, c->stats->local_count);
1152 swf_SetU30(tag, param_num);
1154 swf_SetU30(tag, c->init_scope_depth);
1155 swf_SetU30(tag, c->stats->max_scope_depth+
1156 c->init_scope_depth);
1158 code_write(tag, c->code, pool, file);
1160 swf_SetU30(tag, list_length(c->exceptions));
1161 abc_exception_list_t*l = c->exceptions;
1163 // warning: assumes "pos" in each code_t is up-to-date
1164 swf_SetU30(tag, l->abc_exception->from->pos);
1165 swf_SetU30(tag, l->abc_exception->to->pos);
1166 swf_SetU30(tag, l->abc_exception->target->pos);
1167 swf_SetU30(tag, pool_register_multiname(pool, l->abc_exception->exc_type));
1168 swf_SetU30(tag, pool_register_multiname(pool, l->abc_exception->var_name));
1172 traits_write(pool, tag, c->traits);
1175 /* free temporary codestat data again. Notice: If we were to write this
1176 file multiple times, this can also be shifted to abc_file_free() */
1177 for(t=0;t<file->method_bodies->num;t++) {
1178 abc_method_body_t*m = (abc_method_body_t*)array_getvalue(file->method_bodies, t);
1179 codestats_free(m->stats);m->stats=0;
1182 // --- start to write real tag --
1186 if(tag->id == ST_DOABC) {
1187 swf_SetU32(tag, file->flags); // flags
1188 swf_SetString(tag, file->name);
1191 swf_SetU16(tag, 0x10); //version
1192 swf_SetU16(tag, 0x2e);
1194 pool_write(pool, tag);
1196 swf_SetBlock(tag, tmp->data, tmp->len);
1198 swf_DeleteTag(0, tmp);
1202 void abc_file_free(abc_file_t*file)
1205 if(file->metadata) {
1206 for(t=0;t<file->metadata->num;t++) {
1207 array_t*items = (array_t*)array_getvalue(file->metadata, t);
1209 for(s=0;s<items->num;s++) {
1210 free(array_getvalue(items, s));
1214 array_free(file->metadata);file->metadata=0;
1217 for(t=0;t<file->methods->num;t++) {
1218 abc_method_t*m = (abc_method_t*)array_getvalue(file->methods, t);
1220 multiname_list_t*param = m->parameters;
1222 multiname_destroy(param->multiname);param->multiname=0;
1223 param = param->next;
1225 list_free(m->parameters);m->parameters=0;
1227 constant_list_t*opt = m->optional_parameters;
1229 constant_free(opt->constant);opt->constant=0;
1232 list_free(m->optional_parameters);m->optional_parameters=0;
1235 free((void*)m->name);m->name=0;
1237 if(m->return_type) {
1238 multiname_destroy(m->return_type);
1242 array_free(file->methods);file->methods=0;
1244 for(t=0;t<file->classes->num;t++) {
1245 abc_class_t*cls = (abc_class_t*)array_getvalue(file->classes, t);
1246 traits_free(cls->traits);cls->traits=0;
1247 traits_free(cls->static_traits);cls->static_traits=0;
1249 if(cls->classname) {
1250 multiname_destroy(cls->classname);
1252 if(cls->superclass) {
1253 multiname_destroy(cls->superclass);
1256 multiname_list_t*i = cls->interfaces;
1258 multiname_destroy(i->multiname);i->multiname=0;
1261 list_free(cls->interfaces);cls->interfaces=0;
1263 if(cls->protectedNS) {
1264 namespace_destroy(cls->protectedNS);
1268 array_free(file->classes);file->classes=0;
1270 for(t=0;t<file->scripts->num;t++) {
1271 abc_script_t*s = (abc_script_t*)array_getvalue(file->scripts, t);
1272 traits_free(s->traits);s->traits=0;
1275 array_free(file->scripts);file->scripts=0;
1277 for(t=0;t<file->method_bodies->num;t++) {
1278 abc_method_body_t*body = (abc_method_body_t*)array_getvalue(file->method_bodies, t);
1279 code_free(body->code);body->code=0;
1280 traits_free(body->traits);body->traits=0;
1282 abc_exception_list_t*ee = body->exceptions;
1284 abc_exception_t*e=ee->abc_exception;ee->abc_exception=0;
1285 e->from = e->to = e->target = 0;
1286 multiname_destroy(e->exc_type);e->exc_type=0;
1287 multiname_destroy(e->var_name);e->var_name=0;
1291 list_free(body->exceptions);body->exceptions=0;
1295 array_free(file->method_bodies);file->method_bodies=0;
1298 free((void*)file->name);file->name=0;
1304 void swf_FreeABC(void*code)
1306 abc_file_t*file= (abc_file_t*)code;
1307 abc_file_free(file);
1310 void swf_AddButtonLinks(SWF*swf, char stop_each_frame, char events)
1313 int has_buttons = 0;
1314 TAG*tag=swf->firstTag;
1316 if(tag->id == ST_SHOWFRAME)
1318 if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2)
1323 abc_file_t*file = abc_file_new();
1324 abc_method_body_t*c = 0;
1326 abc_class_t*cls = abc_class_new2(file, "rfx::MainTimeline", "flash.display::MovieClip");
1327 abc_class_protectedNS(cls, "rfx:MainTimeline");
1329 TAG*abctag = swf_InsertTagBefore(swf, swf->firstTag, ST_DOABC);
1331 tag = swf_InsertTag(abctag, ST_SYMBOLCLASS);
1334 swf_SetString(tag, "rfx.MainTimeline");
1336 c = abc_class_getstaticconstructor(cls, 0)->body;
1337 c->old.max_stack = 1;
1338 c->old.local_count = 1;
1339 c->old.init_scope_depth = 9;
1340 c->old.max_scope_depth = 10;
1346 c = abc_class_getconstructor(cls, 0)->body;
1347 c->old.max_stack = 3;
1348 c->old.local_count = 1;
1349 c->old.init_scope_depth = 10;
1350 c->old.max_scope_depth = 11;
1352 debugfile(c, "constructor.as");
1358 __ constructsuper(c,0);
1360 __ getlex(c, "[package]flash.system::Security");
1361 __ pushstring(c, "*");
1362 __ callpropvoid(c, "[package]::allowDomain", 1);
1364 if(stop_each_frame || has_buttons) {
1366 tag = swf->firstTag;
1367 abc_method_body_t*f = 0; //frame script
1368 while(tag && tag->id!=ST_END) {
1370 char needs_framescript=0;
1371 char buttonname[80];
1372 char functionname[80];
1373 sprintf(framename, "[packageinternal]rfx::frame%d", frame);
1375 if(!f && (tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2 || stop_each_frame)) {
1376 /* make the contructor add a frame script */
1377 __ findpropstrict(c,"[package]::addFrameScript");
1378 __ pushbyte(c,frame);
1379 __ getlex(c,framename);
1380 __ callpropvoid(c,"[package]::addFrameScript",2);
1382 f = abc_class_method(cls, 0, multiname_fromstring(framename))->body;
1383 f->old.max_stack = 3;
1384 f->old.local_count = 1;
1385 f->old.init_scope_depth = 10;
1386 f->old.max_scope_depth = 11;
1387 __ debugfile(f, "framescript.as");
1391 if(stop_each_frame) {
1392 __ findpropstrict(f, "[package]::stop");
1393 __ callpropvoid(f, "[package]::stop", 0);
1397 if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2) {
1398 U16 id = swf_GetDefineID(tag);
1399 sprintf(buttonname, "::button%d", swf_GetDefineID(tag));
1400 __ getlex(f,buttonname);
1401 __ getlex(f,"flash.events::MouseEvent");
1402 __ getproperty(f, "::CLICK");
1403 sprintf(functionname, "::clickbutton%d", swf_GetDefineID(tag));
1404 __ getlex(f,functionname);
1405 __ callpropvoid(f, "::addEventListener" ,2);
1407 needs_framescript = 1;
1409 abc_method_body_t*h =
1410 abc_class_method(cls, 0, multiname_fromstring(functionname))->body;
1411 list_append(h->method->parameters, multiname_fromstring("flash.events::MouseEvent"));
1413 h->old.max_stack = 6;
1414 h->old.local_count = 2;
1415 h->old.init_scope_depth = 10;
1416 h->old.max_scope_depth = 11;
1420 ActionTAG*oldaction = swf_ButtonGetAction(tag);
1421 if(oldaction && oldaction->op == ACTION__GOTOFRAME) {
1422 int framenr = GET16(oldaction->data);
1424 fprintf(stderr, "Warning: Couldn't translate jump to frame %d to flash 9 actionscript\n", framenr);
1427 __ findpropstrict(h,"[package]::gotoAndStop");
1428 __ pushbyte(h,framenr+1);
1429 __ callpropvoid(h,"[package]::gotoAndStop", 1);
1432 sprintf(framename, "frame%d", framenr);
1433 __ getlocal_0(h); //this
1434 __ findpropstrict(h, "[package]flash.events::TextEvent");
1435 __ pushstring(h, "link");
1438 __ pushstring(h, framename);
1439 __ constructprop(h,"[package]flash.events::TextEvent", 4);
1440 __ callpropvoid(h,"[package]::dispatchEvent", 1);
1442 } else if(oldaction && oldaction->op == ACTION__GETURL) {
1444 __ findpropstrict(h,"flash.net::navigateToURL");
1445 __ findpropstrict(h,"flash.net::URLRequest");
1446 // TODO: target _blank
1447 __ pushstring(h,oldaction->data); //url
1448 __ constructprop(h,"flash.net::URLRequest", 1);
1449 __ callpropvoid(h,"flash.net::navigateToURL", 1);
1451 __ getlocal_0(h); //this
1452 __ findpropstrict(h, "[package]flash.events::TextEvent");
1453 __ pushstring(h, "link");
1456 __ pushstring(h,oldaction->data); //url
1457 __ constructprop(h,"[package]flash.events::TextEvent", 4);
1458 __ callpropvoid(h,"[package]::dispatchEvent", 1);
1460 } else if(oldaction) {
1461 fprintf(stderr, "Warning: Couldn't translate button code of button %d to flash 9 abc action\n", id);
1464 swf_ActionFree(oldaction);
1466 if(tag->id == ST_SHOWFRAME) {
1481 tag = swf->firstTag;
1483 if(tag->id == ST_DEFINEBUTTON || tag->id == ST_DEFINEBUTTON2) {
1484 char buttonname[80];
1485 sprintf(buttonname, "::button%d", swf_GetDefineID(tag));
1486 multiname_t*s = multiname_fromstring(buttonname);
1487 abc_class_slot(cls, multiname_fromstring(buttonname), s);
1493 abc_script_t*s = abc_initscript(file, 0);
1494 c = s->method->body;
1495 c->old.max_stack = 2;
1496 c->old.local_count = 1;
1497 c->old.init_scope_depth = 1;
1498 c->old.max_scope_depth = 9;
1502 __ getscopeobject(c, 0);
1503 __ getlex(c,"::Object");
1505 __ getlex(c,"flash.events::EventDispatcher");
1507 __ getlex(c,"flash.display::DisplayObject");
1509 __ getlex(c,"flash.display::InteractiveObject");
1511 __ getlex(c,"flash.display::DisplayObjectContainer");
1513 __ getlex(c,"flash.display::Sprite");
1515 __ getlex(c,"flash.display::MovieClip");
1517 __ getlex(c,"flash.display::MovieClip");
1526 __ initproperty(c,"rfx::MainTimeline");
1529 //abc_method_body_addClassTrait(c, "rfx:MainTimeline", 1, cls);
1530 multiname_t*classname = multiname_fromstring("rfx::MainTimeline");
1531 abc_initscript_addClassTrait(s, classname, cls);
1532 multiname_destroy(classname);
1534 swf_WriteABC(abctag, file);