+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;
+ if(dict_contains(parents, p)) {
+ if(soft) {
+ as3_warning("circular reference: class %s references self (through static code)", p->cls->name);
+ return;
+ } else {
+ syntaxerror("circular reference: class %s references self", p->cls->name);
+ }
+ }
+
+ if(c) {
+ parsedclass_t*n = dict_lookup(s2p, c);
+ if(n && !dict_contains(parents, n)) {
+ assert(n->cls == c);
+ dict_put(parents, n, c);
+ }
+ } else {
+ c = p->cls;
+ }
+
+ if(soft && dict_contains(s2p, c)) {
+ parsedclass_t*pp = dict_lookup(s2p, c);
+ DICT_ITERATE_KEY(&pp->usedclasses, classinfo_t*, cc) {
+ add_parent(p, cc, s2p, soft);
+ }
+ }
+ if(c->superclass) {
+ add_parent(p, c->superclass, s2p, soft);
+ }
+ for(t=0;c->interfaces[t];t++) {
+ add_parent(p, c->interfaces[t], s2p, soft);
+ }
+}
+
+parsedclass_t* parsedclass_new(classinfo_t*cls, abc_class_t*abc)
+{
+ NEW(parsedclass_t,p);
+ p->cls = cls;
+ p->abc = abc;
+ dict_init2(&p->parents, &ptr_type, 1);
+ dict_init2(&p->usedclasses, &ptr_type, 1);
+ dict_init2(&p->usedclasses_deep, &ptr_type, 1);
+ return p;
+}
+