+/* 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 <kramm@quiss.org>
+
+ 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 <assert.h>
#include "../q.h"
#include "abc.h"
assert(!c1 || !c2); // otherwise we would have a loop
assert(!c1 || c1==p1->cls);
assert(!c2 || c2==p2->cls);
+
if(c1) {
return -1;
}
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;
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;i<count;i++) {
+ for(j=i+1;j<count;j++) {
+ int r = compare_parsedclass(list+i,list+j);
+ if(r>0) {
+ 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;i<count;i++) {
list2[i] = (parsedclass_t*)list[i];
+#ifdef DEBUG
+ parsedclass_t*p = list[i];
+ printf("%s\n", p->cls->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);
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;
init->method->body->code = c;
}
-