aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2017-06-29 12:48:47 +0200
committerLars Knoll <lars.knoll@qt.io>2017-06-29 10:50:40 +0000
commit05557e7fbd123f20a3da845545d5b0228fc37060 (patch)
treec059d92fd753a68b306965f853ca8be045e2b5b5 /src
parent2ac3eaee7f613201690f7b73a234363372f13247 (diff)
Mark QML id objects as read-only
Change-Id: I39510d59ee6f05a6e45718fd33a1815fb7c46d81 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp1
-rw-r--r--src/qml/compiler/qv4codegen.cpp6
-rw-r--r--src/qml/compiler/qv4codegen_p.h6
3 files changed, 8 insertions, 5 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index f8165b2acd..6aa57a6390 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -1970,6 +1970,7 @@ QQmlJS::Codegen::Reference JSCodeGen::fallbackNameLookup(const QString &name)
load.index = mapping.idIndex;
load.result = result.asLValue();
bytecodeGenerator->addInstruction(load);
+ result.isReadonly = true;
#if 0
if (mapping.type) {
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 394568fbb8..d3129c983d 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2279,7 +2279,7 @@ bool Codegen::visit(RegExpLiteral *ast)
return false;
_expr.result = Reference::fromTemp(this);
- _expr.result.isLiteral = true;
+ _expr.result.isReadonly = true;
Instruction::LoadRegExp instr;
instr.result = _expr.result.asLValue();
@@ -2294,7 +2294,7 @@ bool Codegen::visit(StringLiteral *ast)
return false;
_expr.result = Reference::fromTemp(this);
- _expr.result.isLiteral = true;
+ _expr.result.isReadonly = true;
Instruction::LoadRuntimeString instr;
instr.result = _expr.result.asLValue();
@@ -3308,7 +3308,7 @@ Codegen::Reference &Codegen::Reference::operator =(const Reference &other)
needsWriteBack = false;
isArgOrEval = other.isArgOrEval;
codegen = other.codegen;
- isLiteral = other.isLiteral;
+ isReadonly = other.isReadonly;
global = other.global;
return *this;
}
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h
index dbce9fb2a5..9e6f4d666c 100644
--- a/src/qml/compiler/qv4codegen_p.h
+++ b/src/qml/compiler/qv4codegen_p.h
@@ -134,7 +134,7 @@ public:
This
} type = Invalid;
- bool isLValue() const { return type <= LastLValue && !isLiteral; }
+ bool isLValue() const { return !isReadonly; }
Reference(Codegen *cg, Type type = Invalid) : type(type), codegen(cg) {}
Reference()
@@ -189,6 +189,7 @@ public:
static Reference fromConst(Codegen *cg, QV4::ReturnedValue constant) {
Reference r(cg, Const);
r.constant = constant;
+ r.isReadonly = true;
return r;
}
static Reference fromClosure(Codegen *cg, int functionId) {
@@ -210,6 +211,7 @@ public:
}
static Reference fromThis(Codegen *cg) {
Reference r(cg, This);
+ r.isReadonly = true;
return r;
}
@@ -245,7 +247,7 @@ public:
mutable int tempIndex = -1;
mutable bool needsWriteBack = false;
mutable bool isArgOrEval = false;
- bool isLiteral = false;
+ bool isReadonly = false;
bool global = false;
Codegen *codegen;