From 02d4198242ec3dacc7af31c9446c83adcf014de9 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 1 Sep 2015 11:19:02 +0200 Subject: removed get prefix style fixes --- libsolidity/AST.cpp | 14 ++++++++++---- libsolidity/ASTJsonConverter.cpp | 22 +++++++++++----------- libsolidity/ASTJsonConverter.h | 2 +- libsolidity/ASTPrinter.cpp | 12 ++++++------ libsolidity/ASTPrinter.h | 2 +- libsolidity/Compiler.h | 4 ++-- libsolidity/CompilerStack.cpp | 8 +++++--- libsolidity/ExpressionCompiler.cpp | 10 ++++++---- libsolidity/GasEstimator.cpp | 2 +- libsolidity/InterfaceHandler.cpp | 4 ++-- libsolidity/Types.cpp | 6 ++++-- 11 files changed, 49 insertions(+), 37 deletions(-) (limited to 'libsolidity') diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index ad413352..a9382031 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -817,10 +817,16 @@ void BinaryOperation::checkTypeRequirements(TypePointers const*) m_right->checkTypeRequirements(nullptr); m_commonType = m_left->type()->binaryOperatorResult(m_operator, m_right->type()); if (!m_commonType) - BOOST_THROW_EXCEPTION(createTypeError("Operator " + string(Token::toString(m_operator)) + - " not compatible with types " + - m_left->type()->toString() + " and " + - m_right->type()->toString())); + BOOST_THROW_EXCEPTION( + createTypeError( + "Operator " + + string(Token::toString(m_operator)) + + " not compatible with types " + + m_left->type()->toString() + + " and " + + m_right->type()->toString() + ) + ); m_type = Token::isCompareOp(m_operator) ? make_shared() : m_commonType; } diff --git a/libsolidity/ASTJsonConverter.cpp b/libsolidity/ASTJsonConverter.cpp index 82c48a73..3d119a4e 100644 --- a/libsolidity/ASTJsonConverter.cpp +++ b/libsolidity/ASTJsonConverter.cpp @@ -209,7 +209,7 @@ bool ASTJsonConverter::visit(Assignment const& _node) { addJsonNode("Assignment", { make_pair("operator", Token::toString(_node.assignmentOperator())), - make_pair("type", getType(_node)) }, + make_pair("type", type(_node)) }, true); return true; } @@ -219,7 +219,7 @@ bool ASTJsonConverter::visit(UnaryOperation const& _node) addJsonNode("UnaryOperation", { make_pair("prefix", boost::lexical_cast(_node.isPrefixOperation())), make_pair("operator", Token::toString(_node.getOperator())), - make_pair("type", getType(_node)) }, + make_pair("type", type(_node)) }, true); return true; } @@ -228,7 +228,7 @@ bool ASTJsonConverter::visit(BinaryOperation const& _node) { addJsonNode("BinaryOperation", { make_pair("operator", Token::toString(_node.getOperator())), - make_pair("type", getType(_node))}, + make_pair("type", type(_node))}, true); return true; } @@ -237,14 +237,14 @@ bool ASTJsonConverter::visit(FunctionCall const& _node) { addJsonNode("FunctionCall", { make_pair("type_conversion", boost::lexical_cast(_node.isTypeConversion())), - make_pair("type", getType(_node)) }, + make_pair("type", type(_node)) }, true); return true; } bool ASTJsonConverter::visit(NewExpression const& _node) { - addJsonNode("NewExpression", { make_pair("type", getType(_node)) }, true); + addJsonNode("NewExpression", { make_pair("type", type(_node)) }, true); return true; } @@ -252,28 +252,28 @@ bool ASTJsonConverter::visit(MemberAccess const& _node) { addJsonNode("MemberAccess", { make_pair("member_name", _node.memberName()), - make_pair("type", getType(_node)) }, + make_pair("type", type(_node)) }, true); return true; } bool ASTJsonConverter::visit(IndexAccess const& _node) { - addJsonNode("IndexAccess", { make_pair("type", getType(_node)) }, true); + addJsonNode("IndexAccess", { make_pair("type", type(_node)) }, true); return true; } bool ASTJsonConverter::visit(Identifier const& _node) { addJsonNode("Identifier", - { make_pair("value", _node.name()), make_pair("type", getType(_node)) }); + { make_pair("value", _node.name()), make_pair("type", type(_node)) }); return true; } bool ASTJsonConverter::visit(ElementaryTypeNameExpression const& _node) { addJsonNode("ElementaryTypenameExpression", - { make_pair("value", Token::toString(_node.typeToken())), make_pair("type", getType(_node)) }); + { make_pair("value", Token::toString(_node.typeToken())), make_pair("type", type(_node)) }); return true; } @@ -283,7 +283,7 @@ bool ASTJsonConverter::visit(Literal const& _node) addJsonNode("Literal", { make_pair("string", (tokenString) ? tokenString : "null"), make_pair("value", _node.value()), - make_pair("type", getType(_node)) }); + make_pair("type", type(_node)) }); return true; } @@ -428,7 +428,7 @@ void ASTJsonConverter::process() processed = true; } -string ASTJsonConverter::getType(Expression const& _expression) +string ASTJsonConverter::type(Expression const& _expression) { return (_expression.type()) ? _expression.type()->toString() : "Unknown"; } diff --git a/libsolidity/ASTJsonConverter.h b/libsolidity/ASTJsonConverter.h index aaa54f7f..09217e97 100644 --- a/libsolidity/ASTJsonConverter.h +++ b/libsolidity/ASTJsonConverter.h @@ -112,7 +112,7 @@ private: void addJsonNode(std::string const& _nodeName, std::initializer_list> _list, bool _hasChildren); - std::string getType(Expression const& _expression); + std::string type(Expression const& _expression); inline void goUp() { solAssert(!m_jsonNodePtrs.empty(), "Uneven json nodes stack. Internal error."); diff --git a/libsolidity/ASTPrinter.cpp b/libsolidity/ASTPrinter.cpp index 9c701766..a64e8490 100644 --- a/libsolidity/ASTPrinter.cpp +++ b/libsolidity/ASTPrinter.cpp @@ -507,11 +507,11 @@ void ASTPrinter::endVisit(Literal const&) void ASTPrinter::printSourcePart(ASTNode const& _node) { if (m_gasCosts.count(&_node)) - *m_ostream << getIndentation() << " Gas costs: " << m_gasCosts.at(&_node) << endl; + *m_ostream << indentation() << " Gas costs: " << m_gasCosts.at(&_node) << endl; if (!m_source.empty()) { SourceLocation const& location(_node.location()); - *m_ostream << getIndentation() << " Source: " + *m_ostream << indentation() << " Source: " << escaped(m_source.substr(location.start, location.end - location.start), false) << endl; } } @@ -519,19 +519,19 @@ void ASTPrinter::printSourcePart(ASTNode const& _node) void ASTPrinter::printType(Expression const& _expression) { if (_expression.type()) - *m_ostream << getIndentation() << " Type: " << _expression.type()->toString() << "\n"; + *m_ostream << indentation() << " Type: " << _expression.type()->toString() << "\n"; else - *m_ostream << getIndentation() << " Type unknown.\n"; + *m_ostream << indentation() << " Type unknown.\n"; } -string ASTPrinter::getIndentation() const +string ASTPrinter::indentation() const { return string(m_indentation * 2, ' '); } void ASTPrinter::writeLine(string const& _line) { - *m_ostream << getIndentation() << _line << endl; + *m_ostream << indentation() << _line << endl; } } diff --git a/libsolidity/ASTPrinter.h b/libsolidity/ASTPrinter.h index cdf651f3..8c8be112 100644 --- a/libsolidity/ASTPrinter.h +++ b/libsolidity/ASTPrinter.h @@ -126,7 +126,7 @@ public: private: void printSourcePart(ASTNode const& _node); void printType(Expression const& _expression); - std::string getIndentation() const; + std::string indentation() const; void writeLine(std::string const& _line); bool goDeeper() { m_indentation++; return true; } diff --git a/libsolidity/Compiler.h b/libsolidity/Compiler.h index f9b12a02..f283683f 100644 --- a/libsolidity/Compiler.h +++ b/libsolidity/Compiler.h @@ -59,9 +59,9 @@ public: return m_context.streamAssembly(_stream, _sourceCodes, _inJsonFormat); } /// @returns Assembly items of the normal compiler context - eth::AssemblyItems const& assemblyItems() const { return m_context.assembly().getItems(); } + eth::AssemblyItems const& assemblyItems() const { return m_context.assembly().items(); } /// @returns Assembly items of the runtime compiler context - eth::AssemblyItems const& runtimeAssemblyItems() const { return m_context.assembly().getSub(m_runtimeSub).getItems(); } + eth::AssemblyItems const& runtimeAssemblyItems() const { return m_context.assembly().sub(m_runtimeSub).items(); } /// @returns the entry label of the given function. Might return an AssemblyItem of type /// UndefinedItem if it does not exist yet. diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index f46febfb..53ac5344 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -339,9 +339,11 @@ void CompilerStack::resolveImports() { string const& id = import->identifier(); if (!m_sources.count(id)) - BOOST_THROW_EXCEPTION(ParserError() - << errinfo_sourceLocation(import->location()) - << errinfo_comment("Source not found.")); + BOOST_THROW_EXCEPTION( + ParserError() + << errinfo_sourceLocation(import->location()) + << errinfo_comment("Source not found.") + ); toposort(&m_sources[id]); } sourceOrder.push_back(_source); diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index f5b8d5dc..449267a7 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -450,8 +450,8 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) arg->accept(*this); argumentTypes.push_back(arg->type()); } - ContractDefinition const& contract = dynamic_cast( - *function.returnParameterTypes().front()).contractDefinition(); + ContractDefinition const& contract = + dynamic_cast(*function.returnParameterTypes().front()).contractDefinition(); // copy the contract's code into memory bytes const& bytecode = m_context.compiledContract(contract); utils().fetchFreeMemoryPointer(); @@ -1087,8 +1087,10 @@ void ExpressionCompiler::appendExternalFunctionCall( vector> const& _arguments ) { - solAssert(_functionType.takesArbitraryParameters() || - _arguments.size() == _functionType.parameterTypes().size(), ""); + solAssert( + _functionType.takesArbitraryParameters() || + _arguments.size() == _functionType.parameterTypes().size(), "" + ); // Assumed stack content here: // diff --git a/libsolidity/GasEstimator.cpp b/libsolidity/GasEstimator.cpp index 5ff6814d..d576561a 100644 --- a/libsolidity/GasEstimator.cpp +++ b/libsolidity/GasEstimator.cpp @@ -52,7 +52,7 @@ GasEstimator::ASTGasConsumptionSelfAccumulated GasEstimator::structuralEstimatio GasMeter meter(block.startState->copy()); auto const end = _items.begin() + block.end; for (auto iter = _items.begin() + block.begin; iter != end; ++iter) - particularCosts[iter->getLocation()] += meter.estimateMax(*iter); + particularCosts[iter->location()] += meter.estimateMax(*iter); } set finestNodes = finestNodesAtLocation(_ast); diff --git a/libsolidity/InterfaceHandler.cpp b/libsolidity/InterfaceHandler.cpp index 0c2a4287..a52357d0 100644 --- a/libsolidity/InterfaceHandler.cpp +++ b/libsolidity/InterfaceHandler.cpp @@ -393,7 +393,7 @@ string::const_iterator InterfaceHandler::appendDocTag( } } -static inline string::const_iterator getFirstSpaceOrNl( +static inline string::const_iterator firstSpaceOrNl( string::const_iterator _pos, string::const_iterator _end ) @@ -416,7 +416,7 @@ void InterfaceHandler::parseDocString(string const& _string, CommentOwner _owner if (tagPos != end && tagPos < nlPos) { // we found a tag - auto tagNameEndPos = getFirstSpaceOrNl(tagPos, end); + auto tagNameEndPos = firstSpaceOrNl(tagPos, end); if (tagNameEndPos == end) BOOST_THROW_EXCEPTION( DocstringParsingError() << diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index ebc7e1b2..d1c59ba5 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -697,8 +697,10 @@ bool ContractType::isImplicitlyConvertibleTo(Type const& _convertTo) const bool ContractType::isExplicitlyConvertibleTo(Type const& _convertTo) const { - return isImplicitlyConvertibleTo(_convertTo) || _convertTo.category() == Category::Integer || - _convertTo.category() == Category::Contract; + return + isImplicitlyConvertibleTo(_convertTo) || + _convertTo.category() == Category::Integer || + _convertTo.category() == Category::Contract; } TypePointer ContractType::unaryOperatorResult(Token::Value _operator) const -- cgit