aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@theqtcompany.com>2016-05-02 15:51:01 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2016-05-10 13:13:39 +0000
commitc0681ec57b7c6a04f1e3fb77ac7c790325828af6 (patch)
treed6f2f532194f5c78bb75eeac2ca70312e9d6b797 /src/lib/corelib/buildgraph/rulesevaluationcontext.cpp
parent54199588ce3c73dea6b6684ffc1b5a19fe343c22 (diff)
Revisit importing JS source code
Import code without access to the activation object. Other script engines do not allow easy access to the activation object. The new import code evaluates the code to be imported in an anonymous function that returns an object containing all variables and functions that are declared on the top level. E.g. importing the following snippet var greeting = 'hey!'; function upperCaseGreeting() { return "HEY!"; } is evaluated as (function () { var greeting = 'hey!'; function upperCaseGreeting() { return "HEY!"; } return { greeting : greeting, upperCaseGreeting : upperCaseGreeting } })() This has the following advantages: - Imported JS files do not see variables/functions anymore that were defined in already imported JS files. - No specialities of QScriptEngine are used. Porting to another JS engine becomes easier. - The clearing of the import cache before evaluation of every rule can be removed which improves the performance of rule execution by 28 % (according to qbs_benchmarker). Change-Id: I2f635c3375a137a96c27abf89d04a27fdf2c3f23 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'src/lib/corelib/buildgraph/rulesevaluationcontext.cpp')
-rw-r--r--src/lib/corelib/buildgraph/rulesevaluationcontext.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp b/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp
index 47088eb17..504e40448 100644
--- a/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp
+++ b/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp
@@ -87,7 +87,6 @@ void RulesEvaluationContext::initScope()
if (m_initScopeCalls++ > 0)
return;
- m_engine->clearImportsCache();
m_scope = m_engine->newObject();
m_scope.setPrototype(m_prepareScriptScope);
m_engine->setGlobalObject(m_scope);