QmlJS: Make evaluator understand expression statements.

Reviewed-by: Erik Verbruggen
This commit is contained in:
Christian Kamm
2010-11-23 14:15:50 +01:00
parent 93967104f3
commit 34093064fe
5 changed files with 15 additions and 30 deletions

View File

@@ -197,14 +197,6 @@ QString Bind::toString(UiQualifiedId *qualifiedId, QChar delimiter)
return result;
}
ExpressionNode *Bind::expression(UiScriptBinding *ast) const
{
if (ExpressionStatement *statement = cast<ExpressionStatement *>(ast->statement))
return statement->expression;
return 0;
}
ObjectValue *Bind::bindObject(UiQualifiedId *qualifiedTypeNameId, UiObjectInitializer *initializer)
{
ObjectValue *parentObjectValue = 0;

View File

@@ -91,8 +91,6 @@ protected:
Interpreter::ObjectValue *switchObjectValue(Interpreter::ObjectValue *newObjectValue);
Interpreter::ObjectValue *bindObject(AST::UiQualifiedId *qualifiedTypeNameId, AST::UiObjectInitializer *initializer);
AST::ExpressionNode *expression(AST::UiScriptBinding *ast) const;
private:
Document *_doc;
Interpreter::Engine _engine;

View File

@@ -450,7 +450,7 @@ bool Evaluate::visit(AST::EmptyStatement *)
bool Evaluate::visit(AST::ExpressionStatement *)
{
return false;
return true;
}
bool Evaluate::visit(AST::IfStatement *)

View File

@@ -238,16 +238,13 @@ void ScopeBuilder::setQmlScopeObject(Node *node)
if (scriptBinding->qualifiedId && scriptBinding->qualifiedId->name
&& scriptBinding->qualifiedId->name->asString() == QLatin1String("target")
&& ! scriptBinding->qualifiedId->next) {
// ### make Evaluate understand statements.
if (ExpressionStatement *expStmt = cast<ExpressionStatement *>(scriptBinding->statement)) {
Evaluate evaluator(_context);
const Value *targetValue = evaluator(expStmt->expression);
Evaluate evaluator(_context);
const Value *targetValue = evaluator(scriptBinding->statement);
if (const ObjectValue *target = value_cast<const ObjectValue *>(targetValue)) {
scopeChain.qmlScopeObjects.prepend(target);
} else {
scopeChain.qmlScopeObjects.clear();
}
if (const ObjectValue *target = value_cast<const ObjectValue *>(targetValue)) {
scopeChain.qmlScopeObjects.prepend(target);
} else {
scopeChain.qmlScopeObjects.clear();
}
}
}