diff options
author | Christian <c@ethdev.com> | 2015-03-04 00:55:28 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-03-05 20:19:59 +0800 |
commit | b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9 (patch) | |
tree | c775f78562d5775487ba8b884d0499023734a7db /LValue.h | |
parent | a4d772315d814408c057a9473c2c1fefa351a5b4 (diff) | |
download | dexon-solidity-b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9.tar dexon-solidity-b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9.tar.gz dexon-solidity-b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9.tar.bz2 dexon-solidity-b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9.tar.lz dexon-solidity-b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9.tar.xz dexon-solidity-b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9.tar.zst dexon-solidity-b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9.zip |
Index access for calldata arrays.
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; |