free: (free_func)dummy_destroy,
};
+// ----------------------- resolving ----------------------------------
+slotinfo_t* registry_resolve(slotinfo_t*_s)
+{
+ if(!_s || _s->kind != INFOTYPE_UNRESOLVED)
+ return _s;
+ unresolvedinfo_t*s = (unresolvedinfo_t*)_s;
+
+ if(s->package)
+ return registry_find(s->package, s->name);
+
+ namespace_list_t*l = s->nsset;
+ while(l) {
+ slotinfo_t* n = registry_find(l->namespace->name, s->name);
+ if(n) return n;
+ l = l->next;
+ }
+ return 0;
+}
+
+static slotinfo_list_t*unresolved = 0;
+static void schedule_for_resolve(slotinfo_t*s)
+{
+ list_append(unresolved, s);
+}
+static void resolve_on_slot(slotinfo_t*_member)
+{
+ if(_member->kind == INFOTYPE_SLOT) {
+ varinfo_t*member = (varinfo_t*)_member;
+ member->type = (classinfo_t*)registry_resolve((slotinfo_t*)member->type);
+ } else if(_member->kind == INFOTYPE_METHOD) {
+ methodinfo_t*member = (methodinfo_t*)_member;
+ member->return_type = (classinfo_t*)registry_resolve((slotinfo_t*)member->return_type);
+ classinfo_list_t*l = member->params;
+ while(l) {
+ l->classinfo = (classinfo_t*)registry_resolve((slotinfo_t*)l->classinfo);
+ l = l->next;
+ }
+ } else fprintf(stderr, "Internal Error: bad slot %s", _member->name);
+}
+static void resolve_on_class(slotinfo_t*_cls)
+{
+ classinfo_t*cls = (classinfo_t*)_cls;
+ cls->superclass = (classinfo_t*)registry_resolve((slotinfo_t*)cls->superclass);
+ DICT_ITERATE_DATA(&cls->members,slotinfo_t*,m) {
+ resolve_on_slot(m);
+ }
+ int t=0;
+ while(cls->interfaces[t]) {
+ cls->interfaces[t] = (classinfo_t*)registry_resolve((slotinfo_t*)cls->interfaces[t]);
+ t++;
+ }
+}
+void registry_resolve_all()
+{
+ while(unresolved) {
+ slotinfo_t*_s = unresolved->slotinfo;
+ if(_s->kind == INFOTYPE_CLASS) {
+ resolve_on_class(_s);
+ } else if(_s->kind == INFOTYPE_METHOD || _s->kind == INFOTYPE_SLOT) {
+ resolve_on_slot(_s);
+ } else {
+ fprintf(stderr, "Internal Error: object %s.%s has bad type\n", _s->package, _s->name);
+ }
+ slotinfo_list_t*tofree = unresolved;
+ unresolved = unresolved->next;
+ free(tofree);
+ }
+}
// ------------------------- constructors --------------------------------
#define AVERAGE_NUMBER_OF_MEMBERS 8
c->package = package;
c->name = name;
dict_put(registry_classes, c, c);
- dict_init(&c->members,AVERAGE_NUMBER_OF_MEMBERS);
+ dict_init2(&c->members, &slotinfo_type, AVERAGE_NUMBER_OF_MEMBERS);
+
+ schedule_for_resolve((slotinfo_t*)c);
return c;
}
-methodinfo_t* methodinfo_register_onclass(classinfo_t*cls, U8 access, const char*name)
+methodinfo_t* methodinfo_register_onclass(classinfo_t*cls, U8 access, const char*ns, const char*name)
{
NEW(methodinfo_t,m);
m->kind = INFOTYPE_METHOD;
m->access = access;
m->name = name;
+ m->package = ns;
m->parent = cls;
- dict_put(&cls->members, name, m);
+ dict_put(&cls->members, m, m);
return m;
}
-varinfo_t* varinfo_register_onclass(classinfo_t*cls, U8 access, const char*name)
+varinfo_t* varinfo_register_onclass(classinfo_t*cls, U8 access, const char*ns, const char*name)
{
NEW(varinfo_t,m);
m->kind = INFOTYPE_SLOT;
m->access = access;
m->name = name;
+ m->package = ns;
m->parent = cls;
- dict_put(&cls->members, name, m);
+ dict_put(&cls->members, m, m);
return m;
}
methodinfo_t* methodinfo_register_global(U8 access, const char*package, const char*name)
m->name = name;
m->parent = 0;
dict_put(registry_classes, m, m);
+
+ schedule_for_resolve((slotinfo_t*)m);
return m;
}
varinfo_t* varinfo_register_global(U8 access, const char*package, const char*name)
m->name = name;
m->parent = 0;
dict_put(registry_classes, m, m);
+
+ schedule_for_resolve((slotinfo_t*)m);
return m;
}
}
}
-memberinfo_t* registry_findmember(classinfo_t*cls, const char*name, char recursive)
+memberinfo_t* registry_findmember(classinfo_t*cls, const char*ns, const char*name, char recursive)
{
+ memberinfo_t tmp;
+ tmp.name = name;
+ tmp.package = ns?ns:"";
+
if(!recursive) {
- return (memberinfo_t*)dict_lookup(&cls->members, name);
+ return (memberinfo_t*)dict_lookup(&cls->members, &tmp);
}
/* look at classes directly extended by this class */
slotinfo_t*m = 0;
s = s->superclass;
while(s) {
- m = (slotinfo_t*)dict_lookup(&s->members, name);
+ m = (slotinfo_t*)dict_lookup(&s->members, &tmp);
if(m) {
return (memberinfo_t*)m;
}
int t=0;
while(cls->interfaces[t]) {
classinfo_t*s = cls->interfaces[t];
- while(s) {
- m = (slotinfo_t*)dict_lookup(&s->members, name);
- if(m) {
- return (memberinfo_t*)m;
+ if(s->kind != INFOTYPE_UNRESOLVED) {
+ while(s) {
+ m = (slotinfo_t*)dict_lookup(&s->members, &tmp);
+ if(m) {
+ return (memberinfo_t*)m;
+ }
+ s = s->superclass;
}
- s = s->superclass;
}
t++;
}
return 0;
+}
+memberinfo_t* registry_findmember_nsset(classinfo_t*cls, namespace_list_t*ns, const char*name, char superclasses)
+{
+ while(ns) {
+ memberinfo_t*m = registry_findmember(cls, ns->namespace->name, name, superclasses);
+ if(m) return m;
+ ns = ns->next;
+ }
+ return registry_findmember(cls, "", name, superclasses);
}
+
+
void registry_fill_multiname(multiname_t*m, namespace_t*n, slotinfo_t*c)
{
m->type = QNAME;
c->name = "undefined";
}
- dict_init(&c->members,1);
+ dict_init2(&c->members, &slotinfo_type, 1);
c->data = f;
dict_put(functionobjects, f, c);
return c;
if(!c) c = (classinfo_t*)registry_safefind("", "RegExp");
return c;
}
+classinfo_t* registry_getnamespaceclass() {
+ static classinfo_t*c = 0;
+ if(!c) c = (classinfo_t*)registry_safefind("", "Namespace");
+ return c;
+}
classinfo_t* registry_getMovieClip() {
static classinfo_t*c = 0;
if(!c) c = (classinfo_t*)registry_safefind("flash.display", "MovieClip");