diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-22 00:09:31 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-26 10:04:08 +0000 |
commit | 046d1c5db44f409c67244bd70b13077cc03219b2 (patch) | |
tree | fae07993dd3c6be0c4b020d20bf49c01c35cb25e /src/qml/compiler/qv4codegen_p.h | |
parent | 5faf2e9a693d10e1e689c42deec911083a35ddb2 (diff) |
throw a type error when trying to write to a const variable
This makes them really const. The codegen needs some smaller changes
to ensure that writing to the variable when it's being defined is
allowed.
Change-Id: I781b4bc9c0e0397b9d00cad3daf758a062c17600
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen_p.h')
-rw-r--r-- | src/qml/compiler/qv4codegen_p.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h index 5232624f0f..fb69e46e42 100644 --- a/src/qml/compiler/qv4codegen_p.h +++ b/src/qml/compiler/qv4codegen_p.h @@ -212,7 +212,7 @@ public: return false; } } - bool isConst() const { return type == Const; } + bool isConstant() const { return type == Const; } bool isAccumulator() const { return type == Accumulator; } bool isStackSlot() const { return type == StackSlot; } bool isRegister() const { @@ -366,6 +366,7 @@ public: QString name; mutable bool isArgOrEval = false; bool isReadonly = false; + bool isReferenceToConst = false; bool stackSlotIsLocalOrArgument = false; bool isVolatile = false; bool global = false; @@ -520,9 +521,9 @@ protected: void variableDeclarationList(AST::VariableDeclarationList *ast); Reference targetForPatternElement(AST::PatternElement *p); - void initializeAndDestructureBindingElement(AST::PatternElement *e, const Reference &baseRef = Reference()); - void destructurePropertyList(const Reference &object, AST::PatternPropertyList *bindingList); - void destructureElementList(const Reference &array, AST::PatternElementList *bindingList); + void initializeAndDestructureBindingElement(AST::PatternElement *e, const Reference &baseRef = Reference(), bool isDefinition = false); + void destructurePropertyList(const Reference &object, AST::PatternPropertyList *bindingList, bool isDefinition = false); + void destructureElementList(const Reference &array, AST::PatternElementList *bindingList, bool isDefinition = false); void destructurePattern(AST::Pattern *p, const Reference &rhs); Reference referenceForPropertyName(const Codegen::Reference &object, AST::PropertyName *name); |