|
|
@ -156,6 +156,7 @@ public: |
|
|
|
/// contract types.
|
|
|
|
virtual TypePointer getType(ContractDefinition const* m_currentContract = nullptr) const = 0; |
|
|
|
virtual bool isLValue() const { return false; } |
|
|
|
virtual bool isPartOfExternalInterface() const { return false; }; |
|
|
|
|
|
|
|
protected: |
|
|
|
virtual Visibility getDefaultVisibility() const { return Visibility::Public; } |
|
|
@ -415,6 +416,7 @@ public: |
|
|
|
getVisibility() >= Visibility::Internal; |
|
|
|
} |
|
|
|
virtual TypePointer getType(ContractDefinition const*) const override; |
|
|
|
virtual bool isPartOfExternalInterface() const override { return isPublic() && !m_isConstructor && !getName().empty(); } |
|
|
|
|
|
|
|
/// Checks that all parameters have allowed types and calls checkTypeRequirements on the body.
|
|
|
|
void checkTypeRequirements(); |
|
|
@ -440,13 +442,23 @@ private: |
|
|
|
class VariableDeclaration: public Declaration |
|
|
|
{ |
|
|
|
public: |
|
|
|
VariableDeclaration(SourceLocation const& _location, ASTPointer<TypeName> const& _type, |
|
|
|
ASTPointer<ASTString> const& _name, ASTPointer<Expression> _value, |
|
|
|
Visibility _visibility, |
|
|
|
bool _isStateVar = false, bool _isIndexed = false): |
|
|
|
Declaration(_location, _name, _visibility), |
|
|
|
m_typeName(_type), m_value(_value), |
|
|
|
m_isStateVariable(_isStateVar), m_isIndexed(_isIndexed) {} |
|
|
|
VariableDeclaration( |
|
|
|
SourceLocation const& _location, |
|
|
|
ASTPointer<TypeName> const& _type, |
|
|
|
ASTPointer<ASTString> const& _name, |
|
|
|
ASTPointer<Expression> _value, |
|
|
|
Visibility _visibility, |
|
|
|
bool _isStateVar = false, |
|
|
|
bool _isIndexed = false, |
|
|
|
bool _isConstant = false |
|
|
|
): |
|
|
|
Declaration(_location, _name, _visibility), |
|
|
|
m_typeName(_type), |
|
|
|
m_value(_value), |
|
|
|
m_isStateVariable(_isStateVar), |
|
|
|
m_isIndexed(_isIndexed), |
|
|
|
m_isConstant(_isConstant){} |
|
|
|
|
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual void accept(ASTConstVisitor& _visitor) const override; |
|
|
|
|
|
|
@ -459,21 +471,24 @@ public: |
|
|
|
void setType(std::shared_ptr<Type const> const& _type) { m_type = _type; } |
|
|
|
|
|
|
|
virtual bool isLValue() const override; |
|
|
|
virtual bool isPartOfExternalInterface() const override { return isPublic() && !m_isConstant; } |
|
|
|
|
|
|
|
void checkTypeRequirements(); |
|
|
|
bool isLocalVariable() const { return !!dynamic_cast<FunctionDefinition const*>(getScope()); } |
|
|
|
bool isExternalFunctionParameter() const; |
|
|
|
bool isStateVariable() const { return m_isStateVariable; } |
|
|
|
bool isIndexed() const { return m_isIndexed; } |
|
|
|
bool isConstant() const { return m_isConstant; } |
|
|
|
|
|
|
|
protected: |
|
|
|
Visibility getDefaultVisibility() const override { return Visibility::Internal; } |
|
|
|
|
|
|
|
private: |
|
|
|
ASTPointer<TypeName> m_typeName; ///< can be empty ("var")
|
|
|
|
ASTPointer<Expression> m_value; ///< the assigned value, can be missing
|
|
|
|
ASTPointer<Expression> m_value; ///< the assigned value, can be missing
|
|
|
|
bool m_isStateVariable; ///< Whether or not this is a contract state variable
|
|
|
|
bool m_isIndexed; ///< Whether this is an indexed variable (used by events).
|
|
|
|
bool m_isConstant; ///< Whether the variable is a compile-time constant.
|
|
|
|
|
|
|
|
std::shared_ptr<Type const> m_type; ///< derived type, initially empty
|
|
|
|
}; |
|
|
|