aboutsummaryrefslogtreecommitdiffstats
path: root/AST.h
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-12-02 00:32:10 +0800
committerChristian <c@ethdev.com>2014-12-02 00:33:21 +0800
commita2ad47441eeff3c8cac063670dc51e81e32c9005 (patch)
treec396716d2632656e25e2e49b2ce1e6f9d7739207 /AST.h
parent9e91596c8d5683e79314fcd53a18e0e3df7b3390 (diff)
downloaddexon-solidity-a2ad47441eeff3c8cac063670dc51e81e32c9005.tar.gz
dexon-solidity-a2ad47441eeff3c8cac063670dc51e81e32c9005.tar.zst
dexon-solidity-a2ad47441eeff3c8cac063670dc51e81e32c9005.zip
Disallow assignments to structs and mappings.
Diffstat (limited to 'AST.h')
-rw-r--r--AST.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/AST.h b/AST.h
index 68b5c8b8..87bc3cd4 100644
--- a/AST.h
+++ b/AST.h
@@ -242,6 +242,8 @@ public:
std::shared_ptr<Type const> const& getType() const { return m_type; }
void setType(std::shared_ptr<Type const> const& _type) { m_type = _type; }
+ bool isLocalVariable() const { return !!dynamic_cast<FunctionDefinition*>(getScope()); }
+
private:
ASTPointer<TypeName> m_typeName; ///< can be empty ("var")
@@ -526,12 +528,16 @@ private:
*/
class Expression: public ASTNode
{
+protected:
+ enum class LValueType { NONE, LOCAL, STORAGE };
+
public:
- Expression(Location const& _location): ASTNode(_location), m_isLvalue(false), m_lvalueRequested(false) {}
+ Expression(Location const& _location): ASTNode(_location), m_lvalue(LValueType::NONE), m_lvalueRequested(false) {}
virtual void checkTypeRequirements() = 0;
std::shared_ptr<Type const> const& getType() const { return m_type; }
- bool isLvalue() const { return m_isLvalue; }
+ bool isLValue() const { return m_lvalue != LValueType::NONE; }
+ bool isLocalLValue() const { return m_lvalue == LValueType::LOCAL; }
/// Helper function, infer the type via @ref checkTypeRequirements and then check that it
/// is implicitly convertible to @a _expectedType. If not, throw exception.
@@ -546,9 +552,9 @@ public:
protected:
//! Inferred type of the expression, only filled after a call to checkTypeRequirements().
std::shared_ptr<Type const> m_type;
- //! Whether or not this expression is an lvalue, i.e. something that can be assigned to.
- //! This is set during calls to @a checkTypeRequirements()
- bool m_isLvalue;
+ //! If this expression is an lvalue (i.e. something that can be assigned to) and is stored
+ //! locally or in storage. This is set during calls to @a checkTypeRequirements()
+ LValueType m_lvalue;
//! Whether the outer expression requested the address (true) or the value (false) of this expression.
bool m_lvalueRequested;
};