mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Access modifier cleanup.
This commit is contained in:
parent
be885dc3cf
commit
8696598020
24
AST.h
24
AST.h
@ -58,6 +58,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Location const& getLocation() const { return m_location; }
|
Location const& getLocation() const { return m_location; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Location m_location;
|
Location m_location;
|
||||||
};
|
};
|
||||||
@ -69,6 +70,7 @@ public:
|
|||||||
: ASTNode(_location), m_name(_name) {}
|
: ASTNode(_location), m_name(_name) {}
|
||||||
|
|
||||||
const ASTString& getName() const { return *m_name; }
|
const ASTString& getName() const { return *m_name; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<ASTString> m_name;
|
ASTPointer<ASTString> m_name;
|
||||||
};
|
};
|
||||||
@ -92,6 +94,7 @@ public:
|
|||||||
std::vector<ASTPointer<StructDefinition>> const& getDefinedStructs() { return m_definedStructs; }
|
std::vector<ASTPointer<StructDefinition>> const& getDefinedStructs() { return m_definedStructs; }
|
||||||
std::vector<ASTPointer<VariableDeclaration>> const& getStateVariables() { return m_stateVariables; }
|
std::vector<ASTPointer<VariableDeclaration>> const& getStateVariables() { return m_stateVariables; }
|
||||||
std::vector<ASTPointer<FunctionDefinition>> const& getDefinedFunctions() { return m_definedFunctions; }
|
std::vector<ASTPointer<FunctionDefinition>> const& getDefinedFunctions() { return m_definedFunctions; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ASTPointer<StructDefinition>> m_definedStructs;
|
std::vector<ASTPointer<StructDefinition>> m_definedStructs;
|
||||||
std::vector<ASTPointer<VariableDeclaration>> m_stateVariables;
|
std::vector<ASTPointer<VariableDeclaration>> m_stateVariables;
|
||||||
@ -122,6 +125,7 @@ public:
|
|||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
|
|
||||||
std::vector<ASTPointer<VariableDeclaration>> const& getParameters() { return m_parameters; }
|
std::vector<ASTPointer<VariableDeclaration>> const& getParameters() { return m_parameters; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ASTPointer<VariableDeclaration>> m_parameters;
|
std::vector<ASTPointer<VariableDeclaration>> m_parameters;
|
||||||
};
|
};
|
||||||
@ -145,6 +149,7 @@ public:
|
|||||||
ParameterList& getParameterList() { return *m_parameters; }
|
ParameterList& getParameterList() { return *m_parameters; }
|
||||||
ASTPointer<ParameterList> const& getReturnParameterList() const { return m_returnParameters; }
|
ASTPointer<ParameterList> const& getReturnParameterList() const { return m_returnParameters; }
|
||||||
Block& getBody() { return *m_body; }
|
Block& getBody() { return *m_body; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isPublic;
|
bool m_isPublic;
|
||||||
ASTPointer<ParameterList> m_parameters;
|
ASTPointer<ParameterList> m_parameters;
|
||||||
@ -168,6 +173,7 @@ public:
|
|||||||
//! declared and there is no assignment to the variable that fixes the type.
|
//! declared and there is no assignment to the variable that fixes the type.
|
||||||
std::shared_ptr<Type const> const& getType() const { return m_type; }
|
std::shared_ptr<Type const> const& getType() 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; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<TypeName> m_typeName; ///< can be empty ("var")
|
ASTPointer<TypeName> m_typeName; ///< can be empty ("var")
|
||||||
|
|
||||||
@ -196,6 +202,7 @@ public:
|
|||||||
virtual std::shared_ptr<Type> toType() override { return Type::fromElementaryTypeName(m_type); }
|
virtual std::shared_ptr<Type> toType() override { return Type::fromElementaryTypeName(m_type); }
|
||||||
|
|
||||||
Token::Value getType() const { return m_type; }
|
Token::Value getType() const { return m_type; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Token::Value m_type;
|
Token::Value m_type;
|
||||||
};
|
};
|
||||||
@ -211,6 +218,7 @@ public:
|
|||||||
const ASTString& getName() const { return *m_name; }
|
const ASTString& getName() const { return *m_name; }
|
||||||
void setReferencedStruct(StructDefinition& _referencedStruct) { m_referencedStruct = &_referencedStruct; }
|
void setReferencedStruct(StructDefinition& _referencedStruct) { m_referencedStruct = &_referencedStruct; }
|
||||||
StructDefinition const* getReferencedStruct() const { return m_referencedStruct; }
|
StructDefinition const* getReferencedStruct() const { return m_referencedStruct; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<ASTString> m_name;
|
ASTPointer<ASTString> m_name;
|
||||||
|
|
||||||
@ -225,6 +233,7 @@ public:
|
|||||||
: TypeName(_location), m_keyType(_keyType), m_valueType(_valueType) {}
|
: TypeName(_location), m_keyType(_keyType), m_valueType(_valueType) {}
|
||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
virtual std::shared_ptr<Type> toType() override { return Type::fromMapping(*this); }
|
virtual std::shared_ptr<Type> toType() override { return Type::fromMapping(*this); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<ElementaryTypeName> m_keyType;
|
ASTPointer<ElementaryTypeName> m_keyType;
|
||||||
ASTPointer<TypeName> m_valueType;
|
ASTPointer<TypeName> m_valueType;
|
||||||
@ -245,6 +254,7 @@ public:
|
|||||||
//! For expressions, this also returns the inferred type of the expression. For other
|
//! For expressions, this also returns the inferred type of the expression. For other
|
||||||
//! statements, returns the empty pointer.
|
//! statements, returns the empty pointer.
|
||||||
virtual void checkTypeRequirements() = 0;
|
virtual void checkTypeRequirements() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Check that the inferred type for _expression is _expectedType or at least implicitly
|
//! Check that the inferred type for _expression is _expectedType or at least implicitly
|
||||||
//! convertible to _expectedType. If not, throw exception.
|
//! convertible to _expectedType. If not, throw exception.
|
||||||
@ -259,6 +269,7 @@ public:
|
|||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
|
|
||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ASTPointer<Statement>> m_statements;
|
std::vector<ASTPointer<Statement>> m_statements;
|
||||||
};
|
};
|
||||||
@ -272,6 +283,7 @@ public:
|
|||||||
m_trueBody(_trueBody), m_falseBody(_falseBody) {}
|
m_trueBody(_trueBody), m_falseBody(_falseBody) {}
|
||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<Expression> m_condition;
|
ASTPointer<Expression> m_condition;
|
||||||
ASTPointer<Statement> m_trueBody;
|
ASTPointer<Statement> m_trueBody;
|
||||||
@ -293,6 +305,7 @@ public:
|
|||||||
: BreakableStatement(_location), m_condition(_condition), m_body(_body) {}
|
: BreakableStatement(_location), m_condition(_condition), m_body(_body) {}
|
||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<Expression> m_condition;
|
ASTPointer<Expression> m_condition;
|
||||||
ASTPointer<Statement> m_body;
|
ASTPointer<Statement> m_body;
|
||||||
@ -323,6 +336,7 @@ public:
|
|||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override;
|
||||||
|
|
||||||
void setFunctionReturnParameters(ParameterList& _parameters) { m_returnParameters = &_parameters; }
|
void setFunctionReturnParameters(ParameterList& _parameters) { m_returnParameters = &_parameters; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<Expression> m_expression; //< value to return, optional
|
ASTPointer<Expression> m_expression; //< value to return, optional
|
||||||
|
|
||||||
@ -348,6 +362,7 @@ class Expression: public Statement
|
|||||||
public:
|
public:
|
||||||
Expression(Location const& _location): Statement(_location) {}
|
Expression(Location const& _location): Statement(_location) {}
|
||||||
std::shared_ptr<Type const> const& getType() const { return m_type; }
|
std::shared_ptr<Type const> const& getType() const { return m_type; }
|
||||||
|
|
||||||
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;
|
||||||
@ -369,6 +384,7 @@ public:
|
|||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override;
|
||||||
|
|
||||||
Token::Value getAssignmentOperator() const { return m_assigmentOperator; }
|
Token::Value getAssignmentOperator() const { return m_assigmentOperator; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<Expression> m_leftHandSide;
|
ASTPointer<Expression> m_leftHandSide;
|
||||||
Token::Value m_assigmentOperator;
|
Token::Value m_assigmentOperator;
|
||||||
@ -387,6 +403,7 @@ public:
|
|||||||
|
|
||||||
Token::Value getOperator() const { return m_operator; }
|
Token::Value getOperator() const { return m_operator; }
|
||||||
bool isPrefixOperation() const { return m_isPrefix; }
|
bool isPrefixOperation() const { return m_isPrefix; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Token::Value m_operator;
|
Token::Value m_operator;
|
||||||
ASTPointer<Expression> m_subExpression;
|
ASTPointer<Expression> m_subExpression;
|
||||||
@ -403,6 +420,7 @@ public:
|
|||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override;
|
||||||
|
|
||||||
Token::Value getOperator() const { return m_operator; }
|
Token::Value getOperator() const { return m_operator; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<Expression> m_left;
|
ASTPointer<Expression> m_left;
|
||||||
Token::Value m_operator;
|
Token::Value m_operator;
|
||||||
@ -420,6 +438,7 @@ public:
|
|||||||
: Expression(_location), m_expression(_expression), m_arguments(_arguments) {}
|
: Expression(_location), m_expression(_expression), m_arguments(_arguments) {}
|
||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<Expression> m_expression;
|
ASTPointer<Expression> m_expression;
|
||||||
std::vector<ASTPointer<Expression>> m_arguments;
|
std::vector<ASTPointer<Expression>> m_arguments;
|
||||||
@ -434,6 +453,7 @@ public:
|
|||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
const ASTString& getMemberName() const { return *m_memberName; }
|
const ASTString& getMemberName() const { return *m_memberName; }
|
||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<Expression> m_expression;
|
ASTPointer<Expression> m_expression;
|
||||||
ASTPointer<ASTString> m_memberName;
|
ASTPointer<ASTString> m_memberName;
|
||||||
@ -447,6 +467,7 @@ public:
|
|||||||
: Expression(_location), m_base(_base), m_index(_index) {}
|
: Expression(_location), m_base(_base), m_index(_index) {}
|
||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<Expression> m_base;
|
ASTPointer<Expression> m_base;
|
||||||
ASTPointer<Expression> m_index;
|
ASTPointer<Expression> m_index;
|
||||||
@ -469,6 +490,7 @@ public:
|
|||||||
ASTString const& getName() const { return *m_name; }
|
ASTString const& getName() const { return *m_name; }
|
||||||
void setReferencedDeclaration(Declaration& _referencedDeclaration) { m_referencedDeclaration = &_referencedDeclaration; }
|
void setReferencedDeclaration(Declaration& _referencedDeclaration) { m_referencedDeclaration = &_referencedDeclaration; }
|
||||||
Declaration* getReferencedDeclaration() { return m_referencedDeclaration; }
|
Declaration* getReferencedDeclaration() { return m_referencedDeclaration; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<ASTString> m_name;
|
ASTPointer<ASTString> m_name;
|
||||||
|
|
||||||
@ -485,6 +507,7 @@ public:
|
|||||||
virtual void checkTypeRequirements() override;
|
virtual void checkTypeRequirements() override;
|
||||||
|
|
||||||
Token::Value getTypeToken() const { return m_typeToken; }
|
Token::Value getTypeToken() const { return m_typeToken; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Token::Value m_typeToken;
|
Token::Value m_typeToken;
|
||||||
};
|
};
|
||||||
@ -499,6 +522,7 @@ public:
|
|||||||
|
|
||||||
Token::Value getToken() const { return m_token; }
|
Token::Value getToken() const { return m_token; }
|
||||||
ASTString const& getValue() const { return *m_value; }
|
ASTString const& getValue() const { return *m_value; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Token::Value m_token;
|
Token::Value m_token;
|
||||||
ASTPointer<ASTString> m_value;
|
ASTPointer<ASTString> m_value;
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
|
|
||||||
void resolveNamesAndTypes(ContractDefinition& _contract);
|
void resolveNamesAndTypes(ContractDefinition& _contract);
|
||||||
Declaration* getNameFromCurrentScope(ASTString const& _name, bool _recursive = true);
|
Declaration* getNameFromCurrentScope(ASTString const& _name, bool _recursive = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
@ -83,13 +84,14 @@ class ReferencesResolver: private ASTVisitor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ReferencesResolver(ASTNode& _root, NameAndTypeResolver& _resolver, ParameterList* _returnParameters);
|
ReferencesResolver(ASTNode& _root, NameAndTypeResolver& _resolver, ParameterList* _returnParameters);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void endVisit(VariableDeclaration& _variable) override;
|
virtual void endVisit(VariableDeclaration& _variable) override;
|
||||||
virtual bool visit(Identifier& _identifier) override;
|
virtual bool visit(Identifier& _identifier) override;
|
||||||
virtual bool visit(UserDefinedTypeName& _typeName) override;
|
virtual bool visit(UserDefinedTypeName& _typeName) override;
|
||||||
virtual bool visit(Mapping&) override;
|
virtual bool visit(Mapping&) override;
|
||||||
virtual bool visit(Return& _return) override;
|
virtual bool visit(Return& _return) override;
|
||||||
private:
|
|
||||||
NameAndTypeResolver& m_resolver;
|
NameAndTypeResolver& m_resolver;
|
||||||
ParameterList* m_returnParameters;
|
ParameterList* m_returnParameters;
|
||||||
};
|
};
|
||||||
|
@ -77,6 +77,7 @@ public:
|
|||||||
std::string getLineAtPosition(int _position) const;
|
std::string getLineAtPosition(int _position) const;
|
||||||
std::tuple<int, int> translatePositionToLineColumn(int _position) const;
|
std::tuple<int, int> translatePositionToLineColumn(int _position) const;
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_source;
|
std::string m_source;
|
||||||
size_t m_pos;
|
size_t m_pos;
|
||||||
|
Loading…
Reference in New Issue
Block a user