QmlJS: Split Context and ScopeChain.

Context is created by Link and has information about imports
for all Documents in a Snapshot.

ScopeChain represents how lookup is done at a specific place in
a Document.

Change-Id: I874102d57bbaf1a497fa3f27633bed6ee75dcf10
Reviewed-on: http://codereview.qt.nokia.com/1694
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Christian Kamm
2011-07-12 14:55:27 +02:00
parent ed1321a4f9
commit f87dc61986
22 changed files with 671 additions and 416 deletions

View File

@@ -33,15 +33,17 @@
#include "qmljsevaluate.h"
#include "qmljscontext.h"
#include "qmljsvalueowner.h"
#include "qmljsscopechain.h"
#include "parser/qmljsast_p.h"
#include <QtCore/QDebug>
using namespace QmlJS;
using namespace QmlJS::Interpreter;
Evaluate::Evaluate(const Context *context)
: _valueOwner(context->valueOwner()),
_context(context),
Evaluate::Evaluate(const ScopeChain *scopeChain)
: _valueOwner(scopeChain->context()->valueOwner()),
_context(scopeChain->context()),
_scopeChain(scopeChain),
_scope(_valueOwner->globalObject()),
_result(0)
{
@@ -165,7 +167,7 @@ bool Evaluate::visit(AST::UiQualifiedId *ast)
if (! ast->name)
return false;
const Value *value = _context->lookup(ast->name->asString());
const Value *value = _scopeChain->lookup(ast->name->asString());
if (! ast->next) {
_result = value;
@@ -213,7 +215,7 @@ bool Evaluate::visit(AST::IdentifierExpression *ast)
if (! ast->name)
return false;
_result = _context->lookup(ast->name->asString());
_result = _scopeChain->lookup(ast->name->asString());
return false;
}