Commit 34093064 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Make evaluator understand expression statements.

Reviewed-by: Erik Verbruggen
parent 93967104
......@@ -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;
......
......@@ -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;
......
......@@ -450,7 +450,7 @@ bool Evaluate::visit(AST::EmptyStatement *)
bool Evaluate::visit(AST::ExpressionStatement *)
{
return false;
return true;
}
bool Evaluate::visit(AST::IfStatement *)
......
......@@ -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);
if (const ObjectValue *target = value_cast<const ObjectValue *>(targetValue)) {
scopeChain.qmlScopeObjects.prepend(target);
} else {
scopeChain.qmlScopeObjects.clear();
}
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();
}
}
}
......
......@@ -43,16 +43,14 @@ static inline const Interpreter::ObjectValue * getPropertyChangesTarget(Node *no
for (UiObjectMemberList *members = initializer->members; members; members = members->next) {
if (UiScriptBinding *scriptBinding = cast<UiScriptBinding *>(members->member)) {
if (scriptBinding->qualifiedId
&& scriptBinding->qualifiedId->name->asString() == QLatin1String("target")
&& ! scriptBinding->qualifiedId->next) {
if (ExpressionStatement *expressionStatement = cast<ExpressionStatement *>(scriptBinding->statement)) {
Evaluate evaluator(lookupContext->context());
const Interpreter::Value *targetValue = evaluator(expressionStatement->expression);
if (const Interpreter::ObjectValue *targetObject = Interpreter::value_cast<const Interpreter::ObjectValue *>(targetValue)) {
return targetObject;
} else {
return 0;
}
&& scriptBinding->qualifiedId->name->asString() == QLatin1String("target")
&& ! scriptBinding->qualifiedId->next) {
Evaluate evaluator(lookupContext->context());
const Interpreter::Value *targetValue = evaluator(scriptBinding->statement);
if (const Interpreter::ObjectValue *targetObject = Interpreter::value_cast<const Interpreter::ObjectValue *>(targetValue)) {
return targetObject;
} else {
return 0;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment