mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Coding style cleanup: const and vecptr.
This commit is contained in:
parent
646f106a34
commit
f0c334670d
2
AST.cpp
2
AST.cpp
@ -394,7 +394,7 @@ ptr<Type> FunctionCall::checkTypeRequirements()
|
||||
FunctionType* function = dynamic_cast<FunctionType*>(expressionType.get());
|
||||
BOOST_ASSERT(function != nullptr);
|
||||
FunctionDefinition const& fun = function->getFunction();
|
||||
vecptr<VariableDeclaration> const& parameters = fun.getParameters();
|
||||
std::vector<ptr<VariableDeclaration>> const& parameters = fun.getParameters();
|
||||
if (parameters.size() != m_arguments.size())
|
||||
BOOST_THROW_EXCEPTION(TypeError() << errinfo_comment("Wrong argument count for "
|
||||
"function call."));
|
||||
|
40
AST.h
40
AST.h
@ -51,7 +51,7 @@ public:
|
||||
|
||||
virtual void accept(ASTVisitor& _visitor) = 0;
|
||||
template <class T>
|
||||
static void listAccept(vecptr<T>& _list, ASTVisitor& _visitor)
|
||||
static void listAccept(std::vector<ptr<T>>& _list, ASTVisitor& _visitor)
|
||||
{
|
||||
for (ptr<T>& element: _list)
|
||||
element->accept(_visitor);
|
||||
@ -78,9 +78,9 @@ class ContractDefinition: public Declaration
|
||||
public:
|
||||
ContractDefinition(Location const& _location,
|
||||
ptr<ASTString> const& _name,
|
||||
vecptr<StructDefinition> const& _definedStructs,
|
||||
vecptr<VariableDeclaration> const& _stateVariables,
|
||||
vecptr<FunctionDefinition> const& _definedFunctions)
|
||||
std::vector<ptr<StructDefinition>> const& _definedStructs,
|
||||
std::vector<ptr<VariableDeclaration>> const& _stateVariables,
|
||||
std::vector<ptr<FunctionDefinition>> const& _definedFunctions)
|
||||
: Declaration(_location, _name),
|
||||
m_definedStructs(_definedStructs),
|
||||
m_stateVariables(_stateVariables),
|
||||
@ -89,13 +89,13 @@ public:
|
||||
|
||||
virtual void accept(ASTVisitor& _visitor) override;
|
||||
|
||||
vecptr<StructDefinition> const& getDefinedStructs() { return m_definedStructs; }
|
||||
vecptr<VariableDeclaration> const& getStateVariables() { return m_stateVariables; }
|
||||
vecptr<FunctionDefinition> const& getDefinedFunctions() { return m_definedFunctions; }
|
||||
std::vector<ptr<StructDefinition>> const& getDefinedStructs() { return m_definedStructs; }
|
||||
std::vector<ptr<VariableDeclaration>> const& getStateVariables() { return m_stateVariables; }
|
||||
std::vector<ptr<FunctionDefinition>> const& getDefinedFunctions() { return m_definedFunctions; }
|
||||
private:
|
||||
vecptr<StructDefinition> m_definedStructs;
|
||||
vecptr<VariableDeclaration> m_stateVariables;
|
||||
vecptr<FunctionDefinition> m_definedFunctions;
|
||||
std::vector<ptr<StructDefinition>> m_definedStructs;
|
||||
std::vector<ptr<VariableDeclaration>> m_stateVariables;
|
||||
std::vector<ptr<FunctionDefinition>> m_definedFunctions;
|
||||
};
|
||||
|
||||
class StructDefinition: public Declaration
|
||||
@ -103,12 +103,12 @@ class StructDefinition: public Declaration
|
||||
public:
|
||||
StructDefinition(Location const& _location,
|
||||
ptr<ASTString> const& _name,
|
||||
vecptr<VariableDeclaration> const& _members)
|
||||
std::vector<ptr<VariableDeclaration>> const& _members)
|
||||
: Declaration(_location, _name), m_members(_members) {}
|
||||
virtual void accept(ASTVisitor& _visitor) override;
|
||||
|
||||
private:
|
||||
vecptr<VariableDeclaration> m_members;
|
||||
std::vector<ptr<VariableDeclaration>> m_members;
|
||||
};
|
||||
|
||||
/// Used as function parameter list and return list
|
||||
@ -117,13 +117,13 @@ private:
|
||||
class ParameterList: public ASTNode
|
||||
{
|
||||
public:
|
||||
ParameterList(Location const& _location, vecptr<VariableDeclaration> const& _parameters)
|
||||
ParameterList(Location const& _location, std::vector<ptr<VariableDeclaration>> const& _parameters)
|
||||
: ASTNode(_location), m_parameters(_parameters) {}
|
||||
virtual void accept(ASTVisitor& _visitor) override;
|
||||
|
||||
vecptr<VariableDeclaration> const& getParameters() { return m_parameters; }
|
||||
std::vector<ptr<VariableDeclaration>> const& getParameters() { return m_parameters; }
|
||||
private:
|
||||
vecptr<VariableDeclaration> m_parameters;
|
||||
std::vector<ptr<VariableDeclaration>> m_parameters;
|
||||
};
|
||||
|
||||
class FunctionDefinition: public Declaration
|
||||
@ -141,7 +141,7 @@ public:
|
||||
|
||||
bool isPublic() const { return m_isPublic; }
|
||||
bool isDeclaredConst() const { return m_isDeclaredConst; }
|
||||
vecptr<VariableDeclaration> const& getParameters() const { return m_parameters->getParameters(); }
|
||||
std::vector<ptr<VariableDeclaration>> const& getParameters() const { return m_parameters->getParameters(); }
|
||||
ParameterList& getParameterList() { return *m_parameters; }
|
||||
ptr<ParameterList> const& getReturnParameterList() const { return m_returnParameters; }
|
||||
Block& getBody() { return *m_body; }
|
||||
@ -254,13 +254,13 @@ protected:
|
||||
class Block: public Statement
|
||||
{
|
||||
public:
|
||||
Block(Location const& _location, vecptr<Statement> const& _statements)
|
||||
Block(Location const& _location, std::vector<ptr<Statement>> const& _statements)
|
||||
: Statement(_location), m_statements(_statements) {}
|
||||
virtual void accept(ASTVisitor& _visitor) override;
|
||||
|
||||
virtual ptr<Type> checkTypeRequirements() override;
|
||||
private:
|
||||
vecptr<Statement> m_statements;
|
||||
std::vector<ptr<Statement>> m_statements;
|
||||
};
|
||||
|
||||
class IfStatement: public Statement
|
||||
@ -415,13 +415,13 @@ class FunctionCall: public Expression
|
||||
{
|
||||
public:
|
||||
FunctionCall(Location const& _location, ptr<Expression> const& _expression,
|
||||
vecptr<Expression> const& _arguments)
|
||||
std::vector<ptr<Expression>> const& _arguments)
|
||||
: Expression(_location), m_expression(_expression), m_arguments(_arguments) {}
|
||||
virtual void accept(ASTVisitor& _visitor) override;
|
||||
virtual ptr<Type> checkTypeRequirements() override;
|
||||
private:
|
||||
ptr<Expression> m_expression;
|
||||
vecptr<Expression> m_arguments;
|
||||
std::vector<ptr<Expression>> m_arguments;
|
||||
};
|
||||
|
||||
class MemberAccess: public Expression
|
||||
|
@ -70,8 +70,6 @@ class Literal;
|
||||
// explicitly.
|
||||
template <class T>
|
||||
using ptr = std::shared_ptr<T>;
|
||||
template <class T>
|
||||
using vecptr = std::vector<ptr<T>>;
|
||||
|
||||
using ASTString = std::string;
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace dev
|
||||
namespace solidity
|
||||
{
|
||||
|
||||
ASTPrinter::ASTPrinter(ptr<ASTNode> _ast, const std::string& _source)
|
||||
ASTPrinter::ASTPrinter(ptr<ASTNode> _ast, std::string const& _source)
|
||||
: m_indentation(0), m_source(_source), m_ast(_ast)
|
||||
{
|
||||
}
|
||||
@ -242,7 +242,7 @@ bool ASTPrinter::visit(ElementaryTypeNameExpression& _node)
|
||||
|
||||
bool ASTPrinter::visit(Literal& _node)
|
||||
{
|
||||
const char* tokenString = Token::toString(_node.getToken());
|
||||
char const* tokenString = Token::toString(_node.getToken());
|
||||
if (tokenString == nullptr)
|
||||
tokenString = "[no token]";
|
||||
writeLine(std::string("Literal, token: ") + tokenString + " value: " + _node.getValue());
|
||||
@ -415,7 +415,7 @@ std::string ASTPrinter::getIndentation() const
|
||||
return std::string(m_indentation * 2, ' ');
|
||||
}
|
||||
|
||||
void ASTPrinter::writeLine(const std::string& _line)
|
||||
void ASTPrinter::writeLine(std::string const& _line)
|
||||
{
|
||||
*m_ostream << getIndentation() << _line << '\n';
|
||||
}
|
||||
|
30
Parser.cpp
30
Parser.cpp
@ -43,12 +43,12 @@ ptr<ContractDefinition> Parser::parse(std::shared_ptr<Scanner> const& _scanner)
|
||||
class Parser::ASTNodeFactory
|
||||
{
|
||||
public:
|
||||
ASTNodeFactory(const Parser& _parser) : m_parser(_parser), m_location(_parser.getPosition(), -1) {}
|
||||
ASTNodeFactory(Parser const& _parser) : m_parser(_parser), m_location(_parser.getPosition(), -1) {}
|
||||
|
||||
void markEndPosition() { m_location.end = m_parser.getEndPosition(); }
|
||||
void setLocationEmpty() { m_location.end = m_location.start; }
|
||||
/// Set the end position to the one of the given node.
|
||||
void setEndPositionFromNode(const ptr<ASTNode>& _node) { m_location.end = _node->getLocation().end; }
|
||||
void setEndPositionFromNode(ptr<ASTNode> const& _node) { m_location.end = _node->getLocation().end; }
|
||||
|
||||
template <class NodeType, typename... Args>
|
||||
ptr<NodeType> createNode(Args&& ... _args)
|
||||
@ -59,7 +59,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const Parser& m_parser;
|
||||
Parser const& m_parser;
|
||||
Location m_location;
|
||||
};
|
||||
|
||||
@ -80,9 +80,9 @@ ptr<ContractDefinition> Parser::parseContractDefinition()
|
||||
expectToken(Token::CONTRACT);
|
||||
ptr<ASTString> name = expectIdentifierToken();
|
||||
expectToken(Token::LBRACE);
|
||||
vecptr<StructDefinition> structs;
|
||||
vecptr<VariableDeclaration> stateVariables;
|
||||
vecptr<FunctionDefinition> functions;
|
||||
std::vector<ptr<StructDefinition>> structs;
|
||||
std::vector<ptr<VariableDeclaration>> stateVariables;
|
||||
std::vector<ptr<FunctionDefinition>> functions;
|
||||
bool visibilityIsPublic = true;
|
||||
while (true)
|
||||
{
|
||||
@ -130,7 +130,7 @@ ptr<FunctionDefinition> Parser::parseFunctionDefinition(bool _isPublic)
|
||||
ptr<ParameterList> returnParameters;
|
||||
if (m_scanner->getCurrentToken() == Token::RETURNS)
|
||||
{
|
||||
const bool permitEmptyParameterList = false;
|
||||
bool const permitEmptyParameterList = false;
|
||||
m_scanner->next();
|
||||
returnParameters = parseParameterList(permitEmptyParameterList);
|
||||
}
|
||||
@ -139,7 +139,7 @@ ptr<FunctionDefinition> Parser::parseFunctionDefinition(bool _isPublic)
|
||||
// create an empty parameter list at a zero-length location
|
||||
ASTNodeFactory nodeFactory(*this);
|
||||
nodeFactory.setLocationEmpty();
|
||||
returnParameters = nodeFactory.createNode<ParameterList>(vecptr<VariableDeclaration>());
|
||||
returnParameters = nodeFactory.createNode<ParameterList>(std::vector<ptr<VariableDeclaration>>());
|
||||
}
|
||||
ptr<Block> block = parseBlock();
|
||||
nodeFactory.setEndPositionFromNode(block);
|
||||
@ -152,7 +152,7 @@ ptr<StructDefinition> Parser::parseStructDefinition()
|
||||
ASTNodeFactory nodeFactory(*this);
|
||||
expectToken(Token::STRUCT);
|
||||
ptr<ASTString> name = expectIdentifierToken();
|
||||
vecptr<VariableDeclaration> members;
|
||||
std::vector<ptr<VariableDeclaration>> members;
|
||||
expectToken(Token::LBRACE);
|
||||
while (m_scanner->getCurrentToken() != Token::RBRACE)
|
||||
{
|
||||
@ -224,7 +224,7 @@ ptr<Mapping> Parser::parseMapping()
|
||||
ptr<ParameterList> Parser::parseParameterList(bool _allowEmpty)
|
||||
{
|
||||
ASTNodeFactory nodeFactory(*this);
|
||||
vecptr<VariableDeclaration> parameters;
|
||||
std::vector<ptr<VariableDeclaration>> parameters;
|
||||
expectToken(Token::LPAREN);
|
||||
if (!_allowEmpty || m_scanner->getCurrentToken() != Token::RPAREN)
|
||||
{
|
||||
@ -245,7 +245,7 @@ ptr<Block> Parser::parseBlock()
|
||||
{
|
||||
ASTNodeFactory nodeFactory(*this);
|
||||
expectToken(Token::LBRACE);
|
||||
vecptr<Statement> statements;
|
||||
std::vector<ptr<Statement>> statements;
|
||||
while (m_scanner->getCurrentToken() != Token::RBRACE)
|
||||
statements.push_back(parseStatement());
|
||||
nodeFactory.markEndPosition();
|
||||
@ -433,7 +433,7 @@ ptr<Expression> Parser::parseLeftHandSideExpression()
|
||||
case Token::LPAREN:
|
||||
{
|
||||
m_scanner->next();
|
||||
vecptr<Expression> arguments = parseFunctionCallArguments();
|
||||
std::vector<ptr<Expression>> arguments = parseFunctionCallArguments();
|
||||
nodeFactory.markEndPosition();
|
||||
expectToken(Token::RPAREN);
|
||||
expression = nodeFactory.createNode<FunctionCall>(expression, arguments);
|
||||
@ -490,9 +490,9 @@ ptr<Expression> Parser::parsePrimaryExpression()
|
||||
return expression;
|
||||
}
|
||||
|
||||
vecptr<Expression> Parser::parseFunctionCallArguments()
|
||||
std::vector<ptr<Expression>> Parser::parseFunctionCallArguments()
|
||||
{
|
||||
vecptr<Expression> arguments;
|
||||
std::vector<ptr<Expression>> arguments;
|
||||
if (m_scanner->getCurrentToken() != Token::RPAREN)
|
||||
{
|
||||
arguments.push_back(parseExpression());
|
||||
@ -535,7 +535,7 @@ ptr<ASTString> Parser::getLiteralAndAdvance()
|
||||
return identifier;
|
||||
}
|
||||
|
||||
void Parser::throwExpectationError(const std::string& _description)
|
||||
void Parser::throwExpectationError(std::string const& _description)
|
||||
{
|
||||
//@todo put some of this stuff into ParserError
|
||||
int line, column;
|
||||
|
4
Parser.h
4
Parser.h
@ -63,7 +63,7 @@ private:
|
||||
ptr<Expression> parseUnaryExpression();
|
||||
ptr<Expression> parseLeftHandSideExpression();
|
||||
ptr<Expression> parsePrimaryExpression();
|
||||
vecptr<Expression> parseFunctionCallArguments();
|
||||
std::vector<ptr<Expression>> parseFunctionCallArguments();
|
||||
/// @}
|
||||
|
||||
/// Helper functions
|
||||
@ -73,7 +73,7 @@ private:
|
||||
Token::Value expectAssignmentOperator();
|
||||
ptr<ASTString> expectIdentifierToken();
|
||||
ptr<ASTString> getLiteralAndAdvance();
|
||||
void throwExpectationError(const std::string& _description);
|
||||
void throwExpectationError(std::string const& _description);
|
||||
/// @}
|
||||
|
||||
std::shared_ptr<Scanner> m_scanner;
|
||||
|
16
Scanner.cpp
16
Scanner.cpp
@ -88,12 +88,12 @@ int HexValue(char c)
|
||||
}
|
||||
}
|
||||
|
||||
Scanner::Scanner(const CharStream& _source)
|
||||
Scanner::Scanner(CharStream const& _source)
|
||||
{
|
||||
reset(_source);
|
||||
}
|
||||
|
||||
void Scanner::reset(const CharStream& _source)
|
||||
void Scanner::reset(CharStream const& _source)
|
||||
{
|
||||
m_source = _source;
|
||||
m_char = m_source.get();
|
||||
@ -145,7 +145,7 @@ Token::Value Scanner::selectToken(char _next, Token::Value _then, Token::Value _
|
||||
|
||||
bool Scanner::skipWhitespace()
|
||||
{
|
||||
const int start_position = getSourcePos();
|
||||
int const start_position = getSourcePos();
|
||||
while (IsWhiteSpace(m_char))
|
||||
advance();
|
||||
// Return whether or not we skipped any characters.
|
||||
@ -425,7 +425,7 @@ bool Scanner::scanEscape()
|
||||
|
||||
Token::Value Scanner::scanString()
|
||||
{
|
||||
const char quote = m_char;
|
||||
char const quote = m_char;
|
||||
advance(); // consume quote
|
||||
LiteralScope literal(this);
|
||||
while (m_char != quote && !isSourcePastEndOfInput() && !IsLineTerminator(m_char))
|
||||
@ -592,11 +592,11 @@ Token::Value Scanner::scanNumber(bool _periodSeen)
|
||||
KEYWORD("while", Token::WHILE) \
|
||||
|
||||
|
||||
static Token::Value KeywordOrIdentifierToken(const std::string& input)
|
||||
static Token::Value KeywordOrIdentifierToken(std::string const& input)
|
||||
{
|
||||
BOOST_ASSERT(!input.empty());
|
||||
const int kMinLength = 2;
|
||||
const int kMaxLength = 10;
|
||||
int const kMinLength = 2;
|
||||
int const kMaxLength = 10;
|
||||
if (input.size() < kMinLength || input.size() > kMaxLength)
|
||||
return Token::IDENTIFIER;
|
||||
switch (input[0])
|
||||
@ -609,7 +609,7 @@ case ch:
|
||||
{ \
|
||||
/* 'keyword' is a char array, so sizeof(keyword) is */ \
|
||||
/* strlen(keyword) plus 1 for the NUL char. */ \
|
||||
const int keyword_length = sizeof(keyword) - 1; \
|
||||
int const keyword_length = sizeof(keyword) - 1; \
|
||||
BOOST_STATIC_ASSERT(keyword_length >= kMinLength); \
|
||||
BOOST_STATIC_ASSERT(keyword_length <= kMaxLength); \
|
||||
if (input == keyword) { \
|
||||
|
@ -64,7 +64,7 @@ class CharStream
|
||||
{
|
||||
public:
|
||||
CharStream() : m_pos(0) {}
|
||||
explicit CharStream(const std::string& _source): m_source(_source), m_pos(0) {}
|
||||
explicit CharStream(std::string const& _source): m_source(_source), m_pos(0) {}
|
||||
int getPos() const { return m_pos; }
|
||||
bool isPastEndOfInput() const { return m_pos >= m_source.size(); }
|
||||
char get() const { return m_source[m_pos]; }
|
||||
@ -100,10 +100,10 @@ public:
|
||||
bool complete_;
|
||||
};
|
||||
|
||||
explicit Scanner(const CharStream& _source);
|
||||
explicit Scanner(CharStream const& _source);
|
||||
|
||||
/// Resets the scanner as if newly constructed with _input as input.
|
||||
void reset(const CharStream& _source);
|
||||
void reset(CharStream const& _source);
|
||||
|
||||
/// Returns the next token and advances input.
|
||||
Token::Value next();
|
||||
|
@ -48,7 +48,7 @@ namespace solidity
|
||||
{
|
||||
|
||||
#define T(name, string, precedence) #name,
|
||||
const char* const Token::m_name[NUM_TOKENS] =
|
||||
char const* const Token::m_name[NUM_TOKENS] =
|
||||
{
|
||||
TOKEN_LIST(T, T)
|
||||
};
|
||||
@ -56,7 +56,7 @@ const char* const Token::m_name[NUM_TOKENS] =
|
||||
|
||||
|
||||
#define T(name, string, precedence) string,
|
||||
const char* const Token::m_string[NUM_TOKENS] =
|
||||
char const* const Token::m_string[NUM_TOKENS] =
|
||||
{
|
||||
TOKEN_LIST(T, T)
|
||||
};
|
||||
@ -64,7 +64,7 @@ const char* const Token::m_string[NUM_TOKENS] =
|
||||
|
||||
|
||||
#define T(name, string, precedence) precedence,
|
||||
const int8_t Token::m_precedence[NUM_TOKENS] =
|
||||
int8_t const Token::m_precedence[NUM_TOKENS] =
|
||||
{
|
||||
TOKEN_LIST(T, T)
|
||||
};
|
||||
@ -73,7 +73,7 @@ const int8_t Token::m_precedence[NUM_TOKENS] =
|
||||
|
||||
#define KT(a, b, c) 'T',
|
||||
#define KK(a, b, c) 'K',
|
||||
const char Token::m_tokenType[] =
|
||||
char const Token::m_tokenType[] =
|
||||
{
|
||||
TOKEN_LIST(KT, KK)
|
||||
};
|
||||
|
12
Token.h
12
Token.h
@ -223,7 +223,7 @@ public:
|
||||
|
||||
// Returns a string corresponding to the C++ token name
|
||||
// (e.g. "LT" for the token LT).
|
||||
static const char* getName(Value tok)
|
||||
static char const* getName(Value tok)
|
||||
{
|
||||
BOOST_ASSERT(tok < NUM_TOKENS); // tok is unsigned
|
||||
return m_name[tok];
|
||||
@ -309,7 +309,7 @@ public:
|
||||
// Returns a string corresponding to the JS token string
|
||||
// (.e., "<" for the token LT) or NULL if the token doesn't
|
||||
// have a (unique) string (e.g. an IDENTIFIER).
|
||||
static const char* toString(Value tok)
|
||||
static char const* toString(Value tok)
|
||||
{
|
||||
BOOST_ASSERT(tok < NUM_TOKENS); // tok is unsigned.
|
||||
return m_string[tok];
|
||||
@ -324,10 +324,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static const char* const m_name[NUM_TOKENS];
|
||||
static const char* const m_string[NUM_TOKENS];
|
||||
static const int8_t m_precedence[NUM_TOKENS];
|
||||
static const char m_tokenType[NUM_TOKENS];
|
||||
static char const* const m_name[NUM_TOKENS];
|
||||
static char const* const m_string[NUM_TOKENS];
|
||||
static int8_t const m_precedence[NUM_TOKENS];
|
||||
static char const m_tokenType[NUM_TOKENS];
|
||||
};
|
||||
|
||||
}
|
||||
|
14
Types.cpp
14
Types.cpp
@ -52,18 +52,18 @@ ptr<Type> Type::fromElementaryTypeName(Token::Value _typeToken)
|
||||
BOOST_ASSERT(false); // @todo add other tyes
|
||||
}
|
||||
|
||||
ptr<Type> Type::fromUserDefinedTypeName(const UserDefinedTypeName& _typeName)
|
||||
ptr<Type> Type::fromUserDefinedTypeName(UserDefinedTypeName const& _typeName)
|
||||
{
|
||||
return std::make_shared<StructType>(*_typeName.getReferencedStruct());
|
||||
}
|
||||
|
||||
ptr<Type> Type::fromMapping(const Mapping&)
|
||||
ptr<Type> Type::fromMapping(Mapping const&)
|
||||
{
|
||||
BOOST_ASSERT(false); //@todo not yet implemented
|
||||
return ptr<Type>();
|
||||
}
|
||||
|
||||
ptr<Type> Type::forLiteral(const Literal& _literal)
|
||||
ptr<Type> Type::forLiteral(Literal const& _literal)
|
||||
{
|
||||
switch (_literal.getToken())
|
||||
{
|
||||
@ -110,7 +110,7 @@ bool IntegerType::isImplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
return !convertTo.isSigned() || convertTo.m_bits > m_bits;
|
||||
}
|
||||
|
||||
bool IntegerType::isExplicitlyConvertibleTo(const Type& _convertTo) const
|
||||
bool IntegerType::isExplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
{
|
||||
return _convertTo.getCategory() == Category::INTEGER;
|
||||
}
|
||||
@ -130,7 +130,7 @@ bool IntegerType::acceptsUnaryOperator(Token::Value _operator) const
|
||||
return _operator == Token::DELETE || (!isAddress() && _operator == Token::BIT_NOT);
|
||||
}
|
||||
|
||||
bool BoolType::isExplicitlyConvertibleTo(const Type& _convertTo) const
|
||||
bool BoolType::isExplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
{
|
||||
// conversion to integer is fine, but not to address
|
||||
// this is an example of explicit conversions being not transitive (though implicit should be)
|
||||
@ -143,7 +143,7 @@ bool BoolType::isExplicitlyConvertibleTo(const Type& _convertTo) const
|
||||
return isImplicitlyConvertibleTo(_convertTo);
|
||||
}
|
||||
|
||||
bool ContractType::isImplicitlyConvertibleTo(const Type& _convertTo) const
|
||||
bool ContractType::isImplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
{
|
||||
if (_convertTo.getCategory() != Category::CONTRACT)
|
||||
return false;
|
||||
@ -151,7 +151,7 @@ bool ContractType::isImplicitlyConvertibleTo(const Type& _convertTo) const
|
||||
return &m_contract == &convertTo.m_contract;
|
||||
}
|
||||
|
||||
bool StructType::isImplicitlyConvertibleTo(const Type& _convertTo) const
|
||||
bool StructType::isImplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
{
|
||||
if (_convertTo.getCategory() != Category::STRUCT)
|
||||
return false;
|
||||
|
10
Types.h
10
Types.h
@ -64,8 +64,8 @@ public:
|
||||
static ptr<Type> forLiteral(Literal const& _literal);
|
||||
|
||||
virtual Category getCategory() const = 0;
|
||||
virtual bool isImplicitlyConvertibleTo(const Type&) const { return false; }
|
||||
virtual bool isExplicitlyConvertibleTo(const Type& _convertTo) const
|
||||
virtual bool isImplicitlyConvertibleTo(Type const&) const { return false; }
|
||||
virtual bool isExplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
{
|
||||
return isImplicitlyConvertibleTo(_convertTo);
|
||||
}
|
||||
@ -87,7 +87,7 @@ public:
|
||||
explicit IntegerType(int _bits, Modifier _modifier = Modifier::UNSIGNED);
|
||||
|
||||
virtual bool isImplicitlyConvertibleTo(Type const& _convertTo) const override;
|
||||
virtual bool isExplicitlyConvertibleTo(const Type& _convertTo) const override;
|
||||
virtual bool isExplicitlyConvertibleTo(Type const& _convertTo) const override;
|
||||
virtual bool acceptsBinaryOperator(Token::Value _operator) const override;
|
||||
virtual bool acceptsUnaryOperator(Token::Value _operator) const override;
|
||||
|
||||
@ -104,11 +104,11 @@ class BoolType: public Type
|
||||
{
|
||||
public:
|
||||
virtual Category getCategory() const { return Category::BOOL; }
|
||||
virtual bool isImplicitlyConvertibleTo(const Type& _convertTo) const override
|
||||
virtual bool isImplicitlyConvertibleTo(Type const& _convertTo) const override
|
||||
{
|
||||
return _convertTo.getCategory() == Category::BOOL;
|
||||
}
|
||||
virtual bool isExplicitlyConvertibleTo(const Type& _convertTo) const override;
|
||||
virtual bool isExplicitlyConvertibleTo(Type const& _convertTo) const override;
|
||||
virtual bool acceptsBinaryOperator(Token::Value _operator) const override
|
||||
{
|
||||
return _operator == Token::AND || _operator == Token::OR;
|
||||
|
Loading…
Reference in New Issue
Block a user