aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/qmljs/qmljscheck.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <[email protected]>2010-02-02 15:01:42 +0100
committerRoberto Raggi <[email protected]>2010-02-02 15:02:21 +0100
commitfac977a5bde68b89ab29c964ea87a3007107ed09 (patch)
tree40b2fa6951222be796b3b27a1a7aad2df2449378 /src/libs/qmljs/qmljscheck.cpp
parent2443a4b365bc095ae6650f99b12d29bf46a2d58a (diff)
Try to get the type from a qualified-id.
Diffstat (limited to 'src/libs/qmljs/qmljscheck.cpp')
-rw-r--r--src/libs/qmljs/qmljscheck.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp
index 1dbd12a9076..2f59f7c0aa4 100644
--- a/src/libs/qmljs/qmljscheck.cpp
+++ b/src/libs/qmljs/qmljscheck.cpp
@@ -47,7 +47,7 @@ Check::~Check()
{
}
-const Interpreter::Value *Check::operator()(AST::ExpressionNode *ast, const Interpreter::ObjectValue *scope)
+const Interpreter::Value *Check::operator()(AST::Node *ast, const Interpreter::ObjectValue *scope)
{
const Interpreter::ObjectValue *previousScope = switchScope(scope);
const Interpreter::Value *result = check(ast);
@@ -55,7 +55,7 @@ const Interpreter::Value *Check::operator()(AST::ExpressionNode *ast, const Inte
return result;
}
-const Interpreter::Value *Check::check(AST::ExpressionNode *ast)
+const Interpreter::Value *Check::check(AST::Node *ast)
{
const Value *previousResult = switchResult(0);
accept(ast);
@@ -151,8 +151,31 @@ bool Check::visit(AST::UiArrayMemberList *)
return false;
}
-bool Check::visit(AST::UiQualifiedId *)
+bool Check::visit(AST::UiQualifiedId *ast)
{
+ if (! ast->name)
+ return false;
+
+ const Value *value = _scope->lookup(ast->name->asString());
+ if (! ast->next) {
+ _result = value;
+
+ } else {
+ const ObjectValue *base = value_cast<const ObjectValue *>(value);
+
+ for (AST::UiQualifiedId *it = ast->next; base && it; it = it->next) {
+ NameId *name = it->name;
+ if (! name)
+ break;
+
+ const Value *value = base->property(name->asString());
+ if (! it->next)
+ _result = value;
+ else
+ base = value_cast<const ObjectValue *>(value);
+ }
+ }
+
return false;
}