X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Finitcode.c;h=eebfa132a4a9b80e0420d4f65620e54c9aea3831;hb=c63b2bf21dc1df9a736f0b4c08f6cba828cdab92;hp=ad2dbc0aeae4cc50a323c3a8a7846a062477656b;hpb=8384058f169f17c67c30f29aa30a285ed1e36b1b;p=swftools.git diff --git a/lib/as3/initcode.c b/lib/as3/initcode.c index ad2dbc0..eebfa13 100644 --- a/lib/as3/initcode.c +++ b/lib/as3/initcode.c @@ -1,3 +1,26 @@ +/* initcode.c + + Routines for handling/compiling Flash2 AVM2 ABC Actionscript + + Extension module for the rfxswf library. + Part of the swftools package. + + Copyright (c) 2008,2009 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include #include "../q.h" #include "abc.h" @@ -18,6 +41,7 @@ int compare_parsedclass(const void *_v1, const void *_v2) assert(!c1 || !c2); // otherwise we would have a loop assert(!c1 || c1==p1->cls); assert(!c2 || c2==p2->cls); + if(c1) { return -1; } @@ -36,10 +60,11 @@ int compare_parsedclass(const void *_v1, const void *_v2) if(c2) { return 1; } + return 0; } -void add_parent(parsedclass_t*p, classinfo_t*c, dict_t*s2p, char soft) +static void add_parent(parsedclass_t*p, classinfo_t*c, dict_t*s2p, char soft) { dict_t*parents = soft?(&p->usedclasses_deep):(&p->parents); int t; @@ -118,12 +143,44 @@ parsedclass_t** initcode_sort_classlist(parsedclass_list_t*classes) list[i++] = l->parsedclass; } - /* sort and flatten */ - qsort(list, count, sizeof(void**), compare_parsedclass); + /* sort and flatten. + We unfortunately need to do insertion sort O(n^2) as + our dependencies are only partially ordered */ + int j; + for(i=0;i0) { + parsedclass_t*p1 = list[i]; + parsedclass_t*p2 = list[j]; + list[i] = p2; + list[j] = p1; + } + } + } parsedclass_t**list2 = malloc(sizeof(parsedclass_t*)*(count+1)); for(i=0;icls->name); + if(p->cls->superclass) + printf(" extends %s\n", p->cls->superclass->name); + int t; + for(t=0;p->cls->interfaces[t];t++) + printf(" interface %s\n", p->cls->interfaces[t]->name); + DICT_ITERATE_KEY(&p->usedclasses, classinfo_t*, c) { + printf(" uses %s\n", c->name); + } + DICT_ITERATE_KEY(&p->parents, parsedclass_t*, pp) { + printf(" depends on (deep) %s\n", pp->cls->name); + } + DICT_ITERATE_KEY(&p->usedclasses_deep, parsedclass_t*, px) { + printf(" uses (deep) %s\n", px->cls->name); + } + printf("\n"); +#endif } list2[count]=0; free(list); @@ -160,10 +217,6 @@ void initcode_add_classlist(abc_script_t*init, parsedclass_list_t*_classes) MULTINAME(classname2,cls); trait_t*trait = abc_initscript_addClassTrait(init, &classname2, abc); - c = abc_findpropstrict(c, "trace"); - c = abc_pushstring(c, allocprintf("initialize class %s", cls->name)); - c = abc_callpropvoid(c, "trace", 1); - c = abc_getglobalscope(c); classinfo_t*s = cls->superclass; @@ -216,4 +269,3 @@ void initcode_add_classlist(abc_script_t*init, parsedclass_list_t*_classes) init->method->body->code = c; } -