diff options
Diffstat (limited to 'LValue.h')
-rw-r--r-- | LValue.h | 25 |
1 files changed, 20 insertions, 5 deletions
@@ -46,8 +46,8 @@ protected: m_context(_compilerContext), m_dataType(_dataType) {} public: - /// @returns true if this lvalue reference type occupies a slot on the stack. - virtual bool storesReferenceOnStack() const = 0; + /// @returns the number of stack slots occupied by the lvalue reference + virtual unsigned sizeOnStack() const { return 1; } /// Copies the value of the current lvalue to the top of the stack and, if @a _remove is true, /// also removes the reference from the stack. /// @a _location source location of the current expression, used for error reporting. @@ -76,7 +76,7 @@ class StackVariable: public LValue public: StackVariable(CompilerContext& _compilerContext, Declaration const& _declaration); - virtual bool storesReferenceOnStack() const { return false; } + virtual unsigned sizeOnStack() const override { return 0; } virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; virtual void storeValue(Type const& _sourceType, SourceLocation const& _location = SourceLocation(), bool _move = false) const override; @@ -100,7 +100,6 @@ public: StorageItem(CompilerContext& _compilerContext, Declaration const& _declaration); /// Constructs the LValue and assumes that the storage reference is already on the stack. StorageItem(CompilerContext& _compilerContext, Type const& _type); - virtual bool storesReferenceOnStack() const { return true; } virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; virtual void storeValue(Type const& _sourceType, SourceLocation const& _location = SourceLocation(), bool _move = false) const override; @@ -114,6 +113,23 @@ private: }; /** + * Reference to a single byte inside a storage byte array. + * Stack: <storage_ref> <byte_number> + */ +class StorageByteArrayElement: public LValue +{ +public: + /// Constructs the LValue and assumes that the storage reference is already on the stack. + StorageByteArrayElement(CompilerContext& _compilerContext); + virtual unsigned sizeOnStack() const override { return 2; } + virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; + virtual void storeValue(Type const& _sourceType, + SourceLocation const& _location = SourceLocation(), bool _move = false) const override; + virtual void setToZero( + SourceLocation const& _location = SourceLocation(), bool _removeReference = true) const override; +}; + +/** * Reference to the "length" member of a dynamically-sized array. This is an LValue with special * semantics since assignments to it might reduce its length and thus arrays members have to be * deleted. @@ -123,7 +139,6 @@ class StorageArrayLength: public LValue public: /// Constructs the LValue, assumes that the reference to the array head is already on the stack. StorageArrayLength(CompilerContext& _compilerContext, ArrayType const& _arrayType); - virtual bool storesReferenceOnStack() const { return true; } virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; virtual void storeValue(Type const& _sourceType, SourceLocation const& _location = SourceLocation(), bool _move = false) const override; |