[new compiler] Fix local variable declarations in binding expressions

Always look up locals by name

Change-Id: I2fa14499f6d8749f450bfe2b8a53d684b93bd1dc
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Simon Hausmann 2013-09-20 15:46:28 +02:00 committed by The Qt Project
parent 5d7480aff0
commit 1c29d63d60
1 changed files with 4 additions and 1 deletions

View File

@ -805,7 +805,7 @@ void Codegen::variableDeclaration(VariableDeclaration *ast)
assert(expr.code); assert(expr.code);
initializer = *expr; initializer = *expr;
if (! _env->parent || _function->insideWithOrCatch) { if (! _env->parent || _function->insideWithOrCatch || _mode == QmlBinding) {
// it's global code. // it's global code.
move(_block->NAME(ast->name.toString(), ast->identifierToken.startLine, ast->identifierToken.startColumn), initializer); move(_block->NAME(ast->name.toString(), ast->identifierToken.startLine, ast->identifierToken.startColumn), initializer);
} else { } else {
@ -1344,6 +1344,9 @@ V4IR::Expr *Codegen::identifier(const QString &name, int line, int col)
Environment *e = _env; Environment *e = _env;
V4IR::Function *f = _function; V4IR::Function *f = _function;
if (_mode == QmlBinding)
return _block->NAME(name, line, col);
while (f && e->parent) { while (f && e->parent) {
if (f->insideWithOrCatch || (f->isNamedExpression && f->name == name)) if (f->insideWithOrCatch || (f->isNamedExpression && f->name == name))
return _block->NAME(name, line, col); return _block->NAME(name, line, col);