diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-10-11 13:50:23 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-11 19:38:47 +0200 |
commit | 6adb0693a2e408c388a0939e0a3d711da7b651df (patch) | |
tree | 3f7a2c2d1cf53d8079f5ac8c2e4c6e4e11d69edf /src/qml/compiler/qv4codegen_p.h | |
parent | a4449295c3051e42b1aa80a1c7cc91671ad05765 (diff) |
Fix determination of lookup mode in V4 code generator
In order to determine the type of lookup we need (name or directly in
environment members), we used Codegen::_mode, which is set to the currently
suitable mode depending on the function (parameter to defineFunction). However
that's not quite correct, the look-up mode depends on the function itself, not
where it was called from. This patch corrects that by moving the compilation
mode into the Environment itself.
This is needed by follow-up patches.
Additionally the "bool deletable" parameter to the builtin_declare_vars was
always set to false, because it used mode instead of _mode, which was never set
to Eval or QmlBinding. This will be cleaned up in a future patch.
Change-Id: I878f187945e5de091689ab5d70a0f33eb5a9e38f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4codegen_p.h')
-rw-r--r-- | src/qml/compiler/qv4codegen_p.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h index ea32b5b349..2da65fae79 100644 --- a/src/qml/compiler/qv4codegen_p.h +++ b/src/qml/compiler/qv4codegen_p.h @@ -68,7 +68,7 @@ class Q_QML_EXPORT Codegen: protected AST::Visitor public: Codegen(bool strict); - enum Mode { + enum CompilationMode { GlobalCode, EvalCode, FunctionCode, @@ -79,7 +79,7 @@ public: const QString &sourceCode, AST::Program *ast, V4IR::Module *module, - Mode mode = GlobalCode, + CompilationMode mode = GlobalCode, const QStringList &inheritedLocals = QStringList()); V4IR::Function *generateFromFunctionExpression(const QString &fileName, const QString &sourceCode, @@ -153,7 +153,9 @@ protected: UsesArgumentsObject usesArgumentsObject; - Environment(Environment *parent) + CompilationMode compilationMode; + + Environment(Environment *parent, CompilationMode mode) : parent(parent) , formals(0) , maxNumberOfArguments(0) @@ -162,6 +164,7 @@ protected: , isStrict(false) , isNamedFunctionExpression(false) , usesArgumentsObject(ArgumentsObjectUnknown) + , compilationMode(mode) { if (parent && parent->isStrict) isStrict = true; @@ -216,9 +219,9 @@ protected: } }; - Environment *newEnvironment(AST::Node *node, Environment *parent) + Environment *newEnvironment(AST::Node *node, Environment *parent, CompilationMode compilationMode) { - Environment *env = new Environment(parent); + Environment *env = new Environment(parent, compilationMode); _envMap.insert(node, env); return env; } @@ -283,7 +286,6 @@ protected: V4IR::Function *defineFunction(const QString &name, AST::Node *ast, AST::FormalParameterList *formals, AST::SourceElements *body, - Mode mode = FunctionCode, const QStringList &inheritedLocals = QStringList()); void unwindException(ScopeAndFinally *outest); @@ -427,7 +429,6 @@ protected: V4IR::BasicBlock *_exitBlock; V4IR::BasicBlock *_throwBlock; unsigned _returnAddress; - Mode _mode; Environment *_env; Loop *_loop; AST::LabelledStatement *_labelledStatement; @@ -442,10 +443,10 @@ protected: { typedef QV4::TemporaryAssignment<bool> TemporaryBoolAssignment; public: - ScanFunctions(Codegen *cg, const QString &sourceCode); + ScanFunctions(Codegen *cg, const QString &sourceCode, CompilationMode defaultProgramMode); void operator()(AST::Node *node); - void enterEnvironment(AST::Node *node); + void enterEnvironment(AST::Node *node, CompilationMode compilationMode); void leaveEnvironment(); protected: @@ -500,6 +501,7 @@ protected: QStack<Environment *> _envStack; bool _allowFuncDecls; + CompilationMode defaultProgramMode; }; }; |