char uses_parent_function;
int uses_slots;
dict_t*slots;
+ int activation_var;
abc_method_t*abc;
int var_index; // for inner methods
int index;
classinfo_t*type;
char init;
+ char is_parameter;
methodstate_t*is_inner_method;
} variable_t;
}
-static code_t* add_scope_code(code_t*c, methodstate_t*m)
+static code_t* add_scope_code(code_t*c, methodstate_t*m, char init)
{
- if(m->uses_slots || (m->late_binding && !m->inner)) {
+ if(m->uses_slots || (m->late_binding && !m->inner)) { //???? especially inner functions need the pushscope
c = abc_getlocal_0(c);
c = abc_pushscope(c);
}
if(m->uses_slots) {
- /* FIXME: does this need to be the same activation object as
- in the function header? */
- c = abc_newactivation(c);
- c = abc_pushscope(c);
+ /* FIXME: this alloc_local() causes variable indexes to be
+ different in pass2 than in pass1 */
+ if(!m->activation_var)
+ m->activation_var = alloc_local();
+ if(init) {
+ c = abc_newactivation(c);
+ c = abc_dup(c);
+ c = abc_pushscope(c);
+ c = abc_setlocal(c, m->activation_var);
+ } else {
+ c = abc_getlocal(c, m->activation_var);
+ c = abc_pushscope(c);
+ }
}
return c;
}
{
code_t*c = 0;
- c = add_scope_code(c, m);
+ c = add_scope_code(c, m, 1);
methodstate_list_t*l = m->innerfunctions;
while(l) {
c = abc_getlocal_0(c);
c = abc_constructsuper(c, 0);
}
+
+ if(m->slots) {
+ /* all parameters that are used by inner functions
+ need to be copied from local to slot */
+ parserassert(m->activation_var);
+ DICT_ITERATE_ITEMS(m->slots,char*,name,variable_t*,v) {
+ if(v->is_parameter) {
+ c = abc_getlocal(c, m->activation_var);
+ c = abc_getlocal(c, v->index);
+ c = abc_setslot(c, v->index);
+ }
+ }
+ }
list_free(m->innerfunctions);
m->innerfunctions = 0;
return c;
if(params) {
param_list_t*p=0;
for(p=params->list;p;p=p->next) {
- new_variable(p->param->name, p->param->type, 0, 1);
+ variable_t*v = new_variable2(p->param->name, p->param->type, 0, 1);
+ v->is_parameter = 1;
}
}
-
- if(as3_pass==2) {
- m->scope_code = add_scope_code(m->scope_code, m);
+ if(m->uses_slots) {
+ dict_dump(m->slots, stdout, "");
}
-
methodstate_list_t*l = m->innerfunctions;
while(l) {
methodstate_t*m = l->methodstate;
l = l->next;
}
+ if(as3_pass==2) {
+ m->scope_code = add_scope_code(m->scope_code, m, 0);
+ }
+
if(as3_pass==2 && m->slots) {
/* exchange unresolved identifiers with the actual objects */
DICT_ITERATE_ITEMS(m->slots, char*, name, variable_t*, v) {
if(v->type && v->type->kind == INFOTYPE_UNRESOLVED) {
- v->type = (classinfo_t*)registry_resolve((slotinfo_t*)v->type);
- if(!v->type || v->type->kind != INFOTYPE_CLASS) {
- syntaxerror("Couldn't find class %s", v->type->name);
+ classinfo_t*type = (classinfo_t*)registry_resolve((slotinfo_t*)v->type);
+ if(!type || type->kind != INFOTYPE_CLASS) {
+ syntaxerror("Couldn't find class %s::%s (%s)", v->type->package, v->type->name, name);
}
+ v->type = type;
}
}
}
if(!s && as3_pass==1) {// || !(s->flags&FLAG_BUILTIN)) {
as3_schedule_class($2->package, $2->name);
}
-
- PASS2
classinfo_t*c = $2;
if(!c)
syntaxerror("Couldn't import class\n");
as3_schedule_package($2);
}
- PASS2
NEW(import_t,i);
i->package = $2;
state_has_imports();
c->nsset = get_current_imports();
/* make the compiler look for this class in the current directory,
just in case: */
- //as3_schedule_class_noerror(state->package, $1);
+ as3_schedule_class_noerror(state->package, $1);
}
$$ = (classinfo_t*)c;
PASS2
// ----------------------- expression evaluation -------------------------------------
E : INNERFUNCTION %prec prec_none {$$ = $1;}
-//V : CONSTANT {$$ = 0;}
E : CONSTANT
-//V : VAR_READ %prec T_IDENTIFIER {$$ = 0;}
E : VAR_READ %prec T_IDENTIFIER {$$ = $1;}
-//V : NEW {$$ = $1.c;}
E : NEW {$$ = $1;}
-//V : DELETE {$$ = $1.c;}
E : DELETE {$$ = $1;}
E : FUNCTIONCALL
as3_warning("ignored .() operator");
}
-//VARIABLE : VARIABLE "::" '[' EXPRESSION ']' // qualified expression
-
+//E : E "::" '[' E ']' {
+// // qualified expression TODO
+// $$.c = abc_pushundefined(0);
+// $$.t = 0;
+// as3_warning("ignored ::[] operator");
+// }
E : E '.' T_IDENTIFIER {
if(f && f->slot && !noslot) {
$$.c = abc_getslot($$.c, f->slot);
} else {
+ if(!f)
+ as3_warning("Access of undefined property '%s' in %s", $3, t->name);
+
MEMBER_MULTINAME(m, f, $3);
$$.c = abc_getproperty2($$.c, &m);
}
/* when resolving a property on an unknown type, we do know the
name of the property (and don't seem to need the package), but
we need to make avm2 try out all access modes */
+ as3_warning("Resolving %s on unknown type", $3);
multiname_t m = {MULTINAME, 0, &nopackage_namespace_set, $3};
$$.c = abc_getproperty2($$.c, &m);
$$.c = abc_coerce_a($$.c);
/* let the compiler know that it might want to check the current directory/package
for this identifier- maybe there's a file $1.as defining $1. */
- //as3_schedule_class_noerror(state->package, $1);
+ as3_schedule_class_noerror(state->package, $1);
PASS2
$$.t = 0;
int i_am_static = (state->method && state->method->info)?(state->method->info->flags&FLAG_STATIC):FLAG_STATIC;
/* look at current class' members */
- if(state->cls && (f = findmember_nsset(state->cls->info, $1, 1)) &&
- (f->flags&FLAG_STATIC) >= i_am_static) {
+ if(!state->method->inner &&
+ state->cls &&
+ (f = findmember_nsset(state->cls->info, $1, 1)) &&
+ (f->flags&FLAG_STATIC) >= i_am_static)
+ {
// $1 is a function in this class
int var_is_static = (f->flags&FLAG_STATIC);
static properties of a class */
state->method->late_binding = 1;
$$.t = f->type;
- namespace_t ns = {f->access, ""};
+ namespace_t ns = {f->access, f->package};
multiname_t m = {QNAME, &ns, 0, $1};
$$.c = abc_findpropstrict2($$.c, &m);
$$.c = abc_getproperty2($$.c, &m);
$$.c = abc_getslot($$.c, f->slot);
break;
} else {
- namespace_t ns = {f->access, ""};
+ namespace_t ns = {f->access, f->package};
multiname_t m = {QNAME, &ns, 0, $1};
$$.c = abc_getlocal_0($$.c);
$$.c = abc_getproperty2($$.c, &m);
}
USE_NAMESPACE : "use" "namespace" CLASS_SPEC {
-
+ PASS12
const char*url = $3->name;
+
varinfo_t*s = (varinfo_t*)$3;
+ if(s->kind == INFOTYPE_UNRESOLVED) {
+ s = (varinfo_t*)registry_resolve((slotinfo_t*)s);
+ if(!s)
+ syntaxerror("Couldn't resolve namespace %s", $3->name);
+ }
+
if(!s || s->kind != INFOTYPE_SLOT)
syntaxerror("%s.%s is not a public namespace (%d)", $3->package, $3->name, s?s->kind:-1);
if(!s->value || !NS_TYPE(s->value->type))