git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed some compiler warnings, fixed as3compile spec for-in.as
[swftools.git]
/
lib
/
as3
/
parser.y
diff --git
a/lib/as3/parser.y
b/lib/as3/parser.y
index
02a968d
..
e93f73b
100644
(file)
--- a/
lib/as3/parser.y
+++ b/
lib/as3/parser.y
@@
-919,7
+919,7
@@
static namespace_t modifiers2access(modifiers_t*mod)
syntaxerror("invalid combination of access levels and namespaces");
ns.access = ACCESS_NAMESPACE;
state_t*s = state;
syntaxerror("invalid combination of access levels and namespaces");
ns.access = ACCESS_NAMESPACE;
state_t*s = state;
- const char*url = (const char*)trie_lookup(active_namespaces, mod->ns);
+ const char*url = (const char*)trie_lookup(active_namespaces, (unsigned char*)mod->ns);
if(!url) {
/* shouldn't happen- the tokenizer only reports something as a namespace
if it was already registered */
if(!url) {
/* shouldn't happen- the tokenizer only reports something as a namespace
if it was already registered */
@@
-2223,10
+2223,9
@@
FOR : FOR_START FOR_INIT ';' EXPRESSION ';' VOIDEXPRESSION ')' IF_CODEBLOCK {
}
FOR_IN : FOR_START FOR_IN_INIT "in" EXPRESSION ')' IF_CODEBLOCK {
}
FOR_IN : FOR_START FOR_IN_INIT "in" EXPRESSION ')' IF_CODEBLOCK {
- variable_t*var = find_variable(state, $2);
- if(!var) {
- syntaxerror("variable %s not known in this scope", $2);
- }
+ node_t*n = resolve_identifier($2);
+ typedcode_t w = node_write(n);
+
int it = alloc_local();
int array = alloc_local();
int it = alloc_local();
int array = alloc_local();
@@
-2247,8
+2246,9
@@
FOR_IN : FOR_START FOR_IN_INIT "in" EXPRESSION ')' IF_CODEBLOCK {
$$ = abc_nextname($$);
else
$$ = abc_nextvalue($$);
$$ = abc_nextname($$);
else
$$ = abc_nextvalue($$);
- $$ = converttype($$, 0, var->type);
- $$ = abc_setlocal($$, var->index);
+
+ $$ = converttype($$, 0, w.t);
+ $$ = code_append($$, w.c);
$$ = code_append($$, $6);
$$ = abc_jump($$, loopstart);
$$ = code_append($$, $6);
$$ = abc_jump($$, loopstart);
@@
-3129,6
+3129,9
@@
NEW : "new" E XX MAYBE_PARAM_VALUES {
$$.c = code_append($$.c, paramcode);
$$.c = abc_constructprop2($$.c, name, $4.number);
multiname_destroy(name);
$$.c = code_append($$.c, paramcode);
$$.c = abc_constructprop2($$.c, name, $4.number);
multiname_destroy(name);
+ } else if(is_getlocal($$.c)) {
+ $$.c = code_append($$.c, paramcode);
+ $$.c = abc_construct($$.c, $4.number);
} else if(TYPE_IS_CLASS(v.t) && v.t->data) {
code_free($$.c);
classinfo_t*c = v.t->data;
} else if(TYPE_IS_CLASS(v.t) && v.t->data) {
code_free($$.c);
classinfo_t*c = v.t->data;
@@
-3650,6
+3653,14
@@
MEMBER : E '.' SUBNODE {
}
%code {
}
%code {
+ node_t* var_read(variable_t*v)
+ {
+ typedcode_t o;
+ o.c = abc_getlocal(0, v->index);
+ o.t = v->type;
+ return mkcodenode(o);
+ }
+
node_t* resolve_identifier(char*name)
{
typedcode_t o;
node_t* resolve_identifier(char*name)
{
typedcode_t o;
@@
-3663,9
+3674,7
@@
MEMBER : E '.' SUBNODE {
/* look at variables */
if((v = find_variable(state, name))) {
// name is a local variable
/* look at variables */
if((v = find_variable(state, name))) {
// name is a local variable
- o.c = abc_getlocal(o.c, v->index);
- o.t = v->type;
- return mkcodenode(o);
+ return var_read(v);
}
if((v = find_slot(state->method, name))) {
o.c = abc_getscopeobject(o.c, 1);
}
if((v = find_slot(state->method, name))) {
o.c = abc_getscopeobject(o.c, 1);
@@
-3821,7
+3830,7
@@
NAMESPACE_ID : "namespace" T_IDENTIFIER '=' T_STRING {
}
NAMESPACE_DECLARATION : MAYBE_MODIFIERS NAMESPACE_ID {
PASS12
}
NAMESPACE_DECLARATION : MAYBE_MODIFIERS NAMESPACE_ID {
PASS12
- trie_put(active_namespaces, $2->name, (void*)$2->url);
+ trie_put(active_namespaces, (unsigned char*)$2->name, (void*)$2->url);
namespace_t access = modifiers2access(&$1);
varinfo_t* var = varinfo_register_global(access.access, state->package, $2->name);
namespace_t access = modifiers2access(&$1);
varinfo_t* var = varinfo_register_global(access.access, state->package, $2->name);
@@
-3864,7
+3873,7
@@
USE_NAMESPACE : "use" "namespace" CLASS_SPEC {
syntaxerror("%s.%s is not a namespace", $3->package, $3->name);
url = s->value->ns->name;
syntaxerror("%s.%s is not a namespace", $3->package, $3->name);
url = s->value->ns->name;
- trie_put(active_namespaces, $3->name, (void*)url);
+ trie_put(active_namespaces, (unsigned char*)$3->name, (void*)url);
add_active_url(url);
$$=0;
}
add_active_url(url);
$$=0;
}