diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-07-19 09:19:00 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-07-27 05:23:21 +0800 |
commit | 80980309867ce8cdc70ebb5bb36bbe01cfd01361 (patch) | |
tree | 57d9905ce01be0c17ac9598da344ba713911bcb6 | |
parent | a605e4eb957f65ab172015bd4f03ee56445a9f91 (diff) | |
download | dexon-solidity-80980309867ce8cdc70ebb5bb36bbe01cfd01361.tar.gz dexon-solidity-80980309867ce8cdc70ebb5bb36bbe01cfd01361.tar.zst dexon-solidity-80980309867ce8cdc70ebb5bb36bbe01cfd01361.zip |
Use solAssert instead of boost throw where possible
-rw-r--r-- | libsolidity/ast/AST.h | 4 | ||||
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.cpp | 10 | ||||
-rw-r--r-- | libsolidity/ast/Types.cpp | 32 | ||||
-rw-r--r-- | libsolidity/ast/Types.h | 5 | ||||
-rw-r--r-- | libsolidity/codegen/CompilerContext.cpp | 3 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 23 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.cpp | 10 |
7 files changed, 36 insertions, 51 deletions
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 81ddc754..38396c43 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -791,11 +791,11 @@ public: Declaration(SourceLocation(), std::make_shared<ASTString>(_name)), m_type(_type) {} virtual void accept(ASTVisitor&) override { - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("MagicVariableDeclaration used inside real AST.")); + solAssert(false, "MagicVariableDeclaration used inside real AST."); } virtual void accept(ASTConstVisitor&) const override { - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("MagicVariableDeclaration used inside real AST.")); + solAssert(false, "MagicVariableDeclaration used inside real AST."); } virtual TypePointer type() const override { return m_type; } diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index a90debb2..eda70b63 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -743,7 +743,7 @@ string ASTJsonConverter::visibility(Declaration::Visibility const& _visibility) case Declaration::Visibility::External: return "external"; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown declaration visibility.")); + solAssert(false, "Unknown declaration visibility."); } } @@ -758,7 +758,7 @@ string ASTJsonConverter::location(VariableDeclaration::Location _location) case VariableDeclaration::Location::Memory: return "memory"; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown declaration location.")); + solAssert(false, "Unknown declaration location."); } } @@ -773,7 +773,7 @@ string ASTJsonConverter::contractKind(ContractDefinition::ContractKind _kind) case ContractDefinition::ContractKind::Library: return "library"; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of contract.")); + solAssert(false, "Unknown kind of contract."); } } @@ -788,7 +788,7 @@ string ASTJsonConverter::functionCallKind(FunctionCallKind _kind) case FunctionCallKind::StructConstructorCall: return "structConstructorCall"; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of function call .")); + solAssert(false, "Unknown kind of function call."); } } @@ -804,7 +804,7 @@ string ASTJsonConverter::literalTokenKind(Token::Value _token) case dev::solidity::Token::FalseLiteral: return "bool"; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of literal token.")); + solAssert(false, "Unknown kind of literal token."); } } diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index bcfccc3e..84e4a077 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -211,9 +211,10 @@ TypePointer Type::fromElementaryTypeName(ElementaryTypeNameToken const& _type) return make_shared<ArrayType>(DataLocation::Storage, true); //no types found default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment( + solAssert( + false, "Unable to convert elementary typename " + _type.toString() + " to type." - )); + ); } } @@ -1176,7 +1177,7 @@ u256 BoolType::literalValue(Literal const* _literal) const else if (_literal->token() == Token::FalseLiteral) return u256(0); else - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Bool type constructed from non-boolean literal.")); + solAssert(false, "Bool type constructed from non-boolean literal."); } TypePointer BoolType::unaryOperatorResult(Token::Value _operator) const @@ -1938,10 +1939,7 @@ string TupleType::toString(bool _short) const u256 TupleType::storageSize() const { - BOOST_THROW_EXCEPTION( - InternalCompilerError() << - errinfo_comment("Storage size of non-storable tuple type requested.") - ); + solAssert(false, "Storage size of non-storable tuple type requested."); } unsigned TupleType::sizeOnStack() const @@ -2323,9 +2321,7 @@ u256 FunctionType::storageSize() const if (m_kind == Kind::External || m_kind == Kind::Internal) return 1; else - BOOST_THROW_EXCEPTION( - InternalCompilerError() - << errinfo_comment("Storage size of non-storable function type requested.")); + solAssert(false, "Storage size of non-storable function type requested."); } unsigned FunctionType::storageBytes() const @@ -2335,9 +2331,7 @@ unsigned FunctionType::storageBytes() const else if (m_kind == Kind::Internal) return 8; // it should really not be possible to create larger programs else - BOOST_THROW_EXCEPTION( - InternalCompilerError() - << errinfo_comment("Storage size of non-storable function type requested.")); + solAssert(false, "Storage size of non-storable function type requested."); } unsigned FunctionType::sizeOnStack() const @@ -2695,9 +2689,7 @@ bool TypeType::operator==(Type const& _other) const u256 TypeType::storageSize() const { - BOOST_THROW_EXCEPTION( - InternalCompilerError() - << errinfo_comment("Storage size of non-storable type type requested.")); + solAssert(false, "Storage size of non-storable type type requested."); } unsigned TypeType::sizeOnStack() const @@ -2764,9 +2756,7 @@ ModifierType::ModifierType(const ModifierDefinition& _modifier) u256 ModifierType::storageSize() const { - BOOST_THROW_EXCEPTION( - InternalCompilerError() - << errinfo_comment("Storage size of non-storable type type requested.")); + solAssert(false, "Storage size of non-storable type type requested."); } string ModifierType::identifier() const @@ -2875,7 +2865,7 @@ MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const*) const {"gasprice", make_shared<IntegerType>(256)} }); default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of magic.")); + solAssert(false, "Unknown kind of magic."); } } @@ -2890,6 +2880,6 @@ string MagicType::toString(bool) const case Kind::Transaction: return "tx"; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of magic.")); + solAssert(false, "Unknown kind of magic."); } } diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 3d7dad16..1db46355 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -245,10 +245,7 @@ public: virtual std::string canonicalName(bool /*_addDataLocation*/) const { return toString(true); } virtual u256 literalValue(Literal const*) const { - BOOST_THROW_EXCEPTION( - InternalCompilerError() << - errinfo_comment("Literal value requested for type without literals.") - ); + solAssert(false, "Literal value requested for type without literals."); } /// @returns a (simpler) type that is encoded in the same way for external function calls. diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 6875bda1..2110b93d 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -196,8 +196,7 @@ ModifierDefinition const& CompilerContext::functionModifier(string const& _name) for (ModifierDefinition const* modifier: contract->functionModifiers()) if (modifier->name() == _name) return *modifier; - BOOST_THROW_EXCEPTION(InternalCompilerError() - << errinfo_comment("Function modifier " + _name + " not found.")); + solAssert(false, "Function modifier " + _name + " not found."); } unsigned CompilerContext::baseStackOffsetOfVariable(Declaration const& _declaration) const diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 82518e8c..1e6dffe1 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -373,8 +373,7 @@ bool ExpressionCompiler::visit(UnaryOperation const& _unaryOperation) m_context << u256(0) << Instruction::SUB; break; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid unary operator: " + - string(Token::toString(_unaryOperation.getOperator())))); + solAssert(false, "Invalid unary operator: " + string(Token::toString(_unaryOperation.getOperator()))); } return false; } @@ -895,7 +894,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) break; } default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid function type.")); + solAssert(false, "Invalid function type."); } } return false; @@ -1061,7 +1060,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) true ); else - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid member access to integer.")); + solAssert(false, "Invalid member access to integer"); break; case Type::Category::Function: solAssert(!!_memberAccess.expression().annotation().type->memberType(member), @@ -1095,7 +1094,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) m_context << u256(0) << Instruction::CALLDATALOAD << (u256(0xffffffff) << (256 - 32)) << Instruction::AND; else - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown magic member.")); + solAssert(false, "Unknown magic member."); break; case Type::Category::Struct: { @@ -1172,7 +1171,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) break; } default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Member access to unknown type.")); + solAssert(false, "Member access to unknown type."); } return false; } @@ -1327,7 +1326,7 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier) } else { - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Identifier type not expected in expression context.")); + solAssert(false, "Identifier type not expected in expression context."); } } @@ -1410,7 +1409,7 @@ void ExpressionCompiler::appendCompareOperatorCode(Token::Value _operator, Type m_context << (isSigned ? Instruction::SLT : Instruction::LT); break; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown comparison operator.")); + solAssert(false, "Unknown comparison operator."); } } } @@ -1422,7 +1421,7 @@ void ExpressionCompiler::appendOrdinaryBinaryOperatorCode(Token::Value _operator else if (Token::isBitOp(_operator)) appendBitOperatorCode(_operator); else - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown binary operator.")); + solAssert(false, "Unknown binary operator."); } void ExpressionCompiler::appendArithmeticOperatorCode(Token::Value _operator, Type const& _type) @@ -1461,7 +1460,7 @@ void ExpressionCompiler::appendArithmeticOperatorCode(Token::Value _operator, Ty m_context << Instruction::EXP; break; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown arithmetic operator.")); + solAssert(false, "Unknown arithmetic operator."); } } @@ -1479,7 +1478,7 @@ void ExpressionCompiler::appendBitOperatorCode(Token::Value _operator) m_context << Instruction::XOR; break; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown bit operator.")); + solAssert(false, "Unknown bit operator."); } } @@ -1523,7 +1522,7 @@ void ExpressionCompiler::appendShiftOperatorCode(Token::Value _operator, Type co break; case Token::SHR: default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown shift operator.")); + solAssert(false, "Unknown shift operator."); } } diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index d5a4e554..d7763928 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -435,7 +435,7 @@ Json::Value const& CompilerStack::natspec(Contract const& _contract, Documentati doc->reset(new Json::Value(Natspec::devDocumentation(*_contract.contract))); break; default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Illegal documentation type.")); + solAssert(false, "Illegal documentation type."); } return *(*doc); @@ -665,11 +665,11 @@ void CompilerStack::compileContract( } catch(eth::OptimizerException const&) { - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Assembly optimizer exception for bytecode")); + solAssert(false, "Assembly optimizer exception for bytecode"); } catch(eth::AssemblyException const&) { - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Assembly exception for bytecode")); + solAssert(false, "Assembly exception for bytecode"); } try @@ -678,11 +678,11 @@ void CompilerStack::compileContract( } catch(eth::OptimizerException const&) { - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Assembly optimizer exception for deployed bytecode")); + solAssert(false, "Assembly optimizer exception for deployed bytecode"); } catch(eth::AssemblyException const&) { - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Assembly exception for deployed bytecode")); + solAssert(false, "Assembly exception for deployed bytecode"); } compiledContract.metadata = metadata; |