diff options
-rw-r--r-- | libdevcore/UTF8.cpp | 2 | ||||
-rw-r--r-- | libdevcore/UTF8.h | 8 | ||||
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.cpp | 3 | ||||
-rw-r--r-- | libsolidity/ast/Types.cpp | 5 | ||||
-rw-r--r-- | libsolidity/codegen/ArrayUtils.cpp | 2 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 4 |
6 files changed, 14 insertions, 10 deletions
diff --git a/libdevcore/UTF8.cpp b/libdevcore/UTF8.cpp index d742fe66..1c7ed17c 100644 --- a/libdevcore/UTF8.cpp +++ b/libdevcore/UTF8.cpp @@ -28,7 +28,7 @@ namespace dev { -bool validate(std::string const& _input, size_t& _invalidPosition) +bool validateUTF8(std::string const& _input, size_t& _invalidPosition) { const size_t length = _input.length(); bool valid = true; diff --git a/libdevcore/UTF8.h b/libdevcore/UTF8.h index 9bdc2b4f..753914e3 100644 --- a/libdevcore/UTF8.h +++ b/libdevcore/UTF8.h @@ -30,6 +30,12 @@ namespace dev /// Validate an input for UTF8 encoding /// @returns false if it is invalid and the first invalid position in invalidPosition -bool validate(std::string const& _input, size_t& _invalidPosition); +bool validateUTF8(std::string const& _input, size_t& _invalidPosition); + +inline bool validateUTF8(std::string const& _input) +{ + size_t invalidPos; + return validateUTF8(_input, invalidPos); +} } diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 030b32ba..f6b06be6 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -417,9 +417,8 @@ bool ASTJsonConverter::visit(ElementaryTypeNameExpression const& _node) bool ASTJsonConverter::visit(Literal const& _node) { char const* tokenString = Token::toString(_node.token()); - size_t invalidPos = 0; Json::Value value{_node.value()}; - if (!dev::validate(_node.value(), invalidPos)) + if (!dev::validateUTF8(_node.value())) value = Json::nullValue; Token::Value subdenomination = Token::Value(_node.subDenomination()); addJsonNode(_node, "Literal", { diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index b22f3c08..d9660bc0 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -896,7 +896,7 @@ std::string StringLiteralType::toString(bool) const { size_t invalidSequence; - if (!dev::validate(m_value, invalidSequence)) + if (!dev::validateUTF8(m_value, invalidSequence)) return "literal_string (contains invalid UTF-8 sequence at position " + dev::toString(invalidSequence) + ")"; return "literal_string \"" + m_value + "\""; @@ -909,8 +909,7 @@ TypePointer StringLiteralType::mobileType() const bool StringLiteralType::isValidUTF8() const { - size_t dontCare {}; - return dev::validate(m_value, dontCare); + return dev::validateUTF8(m_value); } shared_ptr<FixedBytesType> FixedBytesType::smallestTypeForLiteral(string const& _literal) diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index c0eb736a..2c982982 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -200,7 +200,7 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons else if (sourceBaseType->isValueType()) CompilerUtils(m_context).loadFromMemoryDynamic(*sourceBaseType, fromCalldata, true, false); else - solAssert(false, "Copying of type " + _sourceType.toString(false) + " to storage not yet supported."); + solUnimplemented("Copying of type " + _sourceType.toString(false) + " to storage not yet supported."); // stack: target_ref target_data_end source_data_pos target_data_pos source_data_end [target_byte_offset] [source_byte_offset] <source_value>... solAssert( 2 + byteOffsetSize + sourceBaseType->sizeOnStack() <= 16, diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 58330764..5748d818 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1252,7 +1252,7 @@ void ExpressionCompiler::endVisit(Literal const& _literal) case Type::Category::StringLiteral: break; // will be done during conversion default: - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Only integer, boolean and string literals implemented for now.")); + solUnimplemented("Only integer, boolean and string literals implemented for now."); } } @@ -1392,7 +1392,7 @@ void ExpressionCompiler::appendBitOperatorCode(Token::Value _operator) void ExpressionCompiler::appendShiftOperatorCode(Token::Value _operator) { - BOOST_THROW_EXCEPTION(UnimplementedFeatureError() << errinfo_comment("Shift operators not yet implemented.")); + solUnimplemented("Shift operators not yet implemented."); switch (_operator) { case Token::SHL: |