Qmljs: added scope for blocks in UiScriptBindings and UiPublicMember

correctly insert the scope for code blocks in UiScriptBindings and
UiPublicMember, and improve find usages for types (correctly detecting
variables in the same scope)

Change-Id: Iaaf1a59f041f3831fbe04243b220fb85fde76479
Reviewed-on: http://codereview.qt.nokia.com/335
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
This commit is contained in:
Fawzi Mohamed
2011-06-06 14:13:50 +02:00
parent c54575e670
commit fe564852ad
7 changed files with 119 additions and 20 deletions

View File

@@ -62,11 +62,20 @@ void ScopeBuilder::push(AST::Node *node)
if (qmlObject)
setQmlScopeObject(qmlObject);
// JS scopes (catch both, FunctionExpression and FunctionDeclaration)
if (FunctionExpression *fun = dynamic_cast<FunctionExpression *>(node)) {
ObjectValue *functionScope = _doc->bind()->findFunctionScope(fun);
if (functionScope)
_context->scopeChain().jsScopes += functionScope;
// JS scopes
switch (node->kind) {
case Node::Kind_UiScriptBinding:
case Node::Kind_FunctionDeclaration:
case Node::Kind_FunctionExpression:
case Node::Kind_UiPublicMember:
{
ObjectValue *scope = _doc->bind()->findAttachedJSScope(node);
if (scope)
_context->scopeChain().jsScopes += scope;
break;
}
default:
break;
}
_context->scopeChain().update();
@@ -84,9 +93,19 @@ void ScopeBuilder::pop()
_nodes.removeLast();
// JS scopes
if (FunctionExpression *fun = dynamic_cast<FunctionExpression *>(toRemove)) {
if (_doc->bind()->findFunctionScope(fun))
switch (toRemove->kind) {
case Node::Kind_UiScriptBinding:
case Node::Kind_FunctionDeclaration:
case Node::Kind_FunctionExpression:
case Node::Kind_UiPublicMember:
{
ObjectValue *scope = _doc->bind()->findAttachedJSScope(toRemove);
if (scope)
_context->scopeChain().jsScopes.removeLast();
break;
}
default:
break;
}
// QML scope object