|
@ -132,7 +132,6 @@ private: |
|
|
class Declaration: public ASTNode |
|
|
class Declaration: public ASTNode |
|
|
{ |
|
|
{ |
|
|
public: |
|
|
public: |
|
|
enum class LValueType { None, Local, Storage }; |
|
|
|
|
|
/// Visibility ordered from restricted to unrestricted.
|
|
|
/// Visibility ordered from restricted to unrestricted.
|
|
|
enum class Visibility { Default, Private, Protected, Public, External }; |
|
|
enum class Visibility { Default, Private, Protected, Public, External }; |
|
|
|
|
|
|
|
@ -156,8 +155,7 @@ public: |
|
|
/// The current contract has to be given since this context can change the type, especially of
|
|
|
/// The current contract has to be given since this context can change the type, especially of
|
|
|
/// contract types.
|
|
|
/// contract types.
|
|
|
virtual TypePointer getType(ContractDefinition const* m_currentContract = nullptr) const = 0; |
|
|
virtual TypePointer getType(ContractDefinition const* m_currentContract = nullptr) const = 0; |
|
|
/// @returns the lvalue type of expressions referencing this declaration
|
|
|
virtual bool isLValue() const { return false; } |
|
|
virtual LValueType getLValueType() const { return LValueType::None; } |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
protected: |
|
|
virtual Visibility getDefaultVisibility() const { return Visibility::Public; } |
|
|
virtual Visibility getDefaultVisibility() const { return Visibility::Public; } |
|
@ -448,8 +446,9 @@ public: |
|
|
TypePointer getType(ContractDefinition const* = nullptr) const { return m_type; } |
|
|
TypePointer getType(ContractDefinition const* = nullptr) const { return m_type; } |
|
|
void setType(std::shared_ptr<Type const> const& _type) { m_type = _type; } |
|
|
void setType(std::shared_ptr<Type const> const& _type) { m_type = _type; } |
|
|
|
|
|
|
|
|
virtual LValueType getLValueType() const override; |
|
|
virtual bool isLValue() const override; |
|
|
bool isLocalVariable() const { return !!dynamic_cast<FunctionDefinition const*>(getScope()); } |
|
|
bool isLocalVariable() const { return !!dynamic_cast<FunctionDefinition const*>(getScope()); } |
|
|
|
|
|
bool isFunctionParameter() const; |
|
|
bool isStateVariable() const { return m_isStateVariable; } |
|
|
bool isStateVariable() const { return m_isStateVariable; } |
|
|
bool isIndexed() const { return m_isIndexed; } |
|
|
bool isIndexed() const { return m_isIndexed; } |
|
|
|
|
|
|
|
@ -887,8 +886,7 @@ public: |
|
|
virtual void checkTypeRequirements() = 0; |
|
|
virtual void checkTypeRequirements() = 0; |
|
|
|
|
|
|
|
|
std::shared_ptr<Type const> const& getType() const { return m_type; } |
|
|
std::shared_ptr<Type const> const& getType() const { return m_type; } |
|
|
bool isLValue() const { return m_lvalue != Declaration::LValueType::None; } |
|
|
bool isLValue() const { return m_isLValue; } |
|
|
bool isLocalLValue() const { return m_lvalue == Declaration::LValueType::Local; } |
|
|
|
|
|
|
|
|
|
|
|
/// Helper function, infer the type via @ref checkTypeRequirements and then check that it
|
|
|
/// Helper function, infer the type via @ref checkTypeRequirements and then check that it
|
|
|
/// is implicitly convertible to @a _expectedType. If not, throw exception.
|
|
|
/// is implicitly convertible to @a _expectedType. If not, throw exception.
|
|
@ -903,9 +901,9 @@ public: |
|
|
protected: |
|
|
protected: |
|
|
//! Inferred type of the expression, only filled after a call to checkTypeRequirements().
|
|
|
//! Inferred type of the expression, only filled after a call to checkTypeRequirements().
|
|
|
std::shared_ptr<Type const> m_type; |
|
|
std::shared_ptr<Type const> m_type; |
|
|
//! If this expression is an lvalue (i.e. something that can be assigned to) and is stored
|
|
|
//! If this expression is an lvalue (i.e. something that can be assigned to).
|
|
|
//! locally or in storage. This is set during calls to @a checkTypeRequirements()
|
|
|
//! This is set during calls to @a checkTypeRequirements()
|
|
|
Declaration::LValueType m_lvalue = Declaration::LValueType::None; |
|
|
bool m_isLValue = false; |
|
|
//! Whether the outer expression requested the address (true) or the value (false) of this expression.
|
|
|
//! Whether the outer expression requested the address (true) or the value (false) of this expression.
|
|
|
bool m_lvalueRequested = false; |
|
|
bool m_lvalueRequested = false; |
|
|
}; |
|
|
}; |
|
|