aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4instr_moth_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-05-04 15:16:08 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-11 07:17:05 +0000
commit4cf7e80c5740912804383e4d866ba12b2520d0e6 (patch)
tree143d960492aa166a7f3d7111b64151c42234a81f /src/qml/compiler/qv4instr_moth_p.h
parent2fc50421c86134b5b42a4ba68aa7f6b87cfd7d74 (diff)
Ensure we have a lexical scope for global code
This requires a bit more work than simply pushing a new BlockContext for the lexically declared variables, as eval() and the Function constructor operate on the global scope (including the lexically declared names). To fix this introduce Push/PopScriptContext instructions, that create a BlockContext for the lexically declared vars and pushes that one as a global script context that eval and friends use. Change-Id: I0fd0b0f682f82e250545e874fe93978449fe5e46 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4instr_moth_p.h')
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index 546e8fd2de..d12d1a53cc 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -117,6 +117,8 @@ QT_BEGIN_NAMESPACE
#define INSTR_PushCatchContext(op) INSTRUCTION(op, PushCatchContext, 3, reg, index, name)
#define INSTR_PushWithContext(op) INSTRUCTION(op, PushWithContext, 1, reg)
#define INSTR_PushBlockContext(op) INSTRUCTION(op, PushBlockContext, 2, reg, index)
+#define INSTR_PushScriptContext(op) INSTRUCTION(op, PushScriptContext, 1, index)
+#define INSTR_PopScriptContext(op) INSTRUCTION(op, PopScriptContext, 0)
#define INSTR_PopContext(op) INSTRUCTION(op, PopContext, 1, reg)
#define INSTR_GetIterator(op) INSTRUCTION(op, GetIterator, 1, iterator)
#define INSTR_DeleteMember(op) INSTRUCTION(op, DeleteMember, 2, member, base)
@@ -240,6 +242,8 @@ QT_BEGIN_NAMESPACE
F(PushCatchContext) \
F(PushWithContext) \
F(PushBlockContext) \
+ F(PushScriptContext) \
+ F(PopScriptContext) \
F(PopContext) \
F(GetIterator) \
F(DeleteMember) \