aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/CompilerContext.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-09-18 20:47:46 +0800
committerchriseth <chris@ethereum.org>2017-09-22 21:18:32 +0800
commit2530223ab5c470c01b7e684f33e1fdfa5f5f9590 (patch)
treef06f138a0229342e46d24c10afc9222d8342e3b5 /libsolidity/codegen/CompilerContext.cpp
parentab8ce58a3e522cfe8d0a36132e5e0b305d4ca052 (diff)
downloaddexon-solidity-2530223ab5c470c01b7e684f33e1fdfa5f5f9590.tar.gz
dexon-solidity-2530223ab5c470c01b7e684f33e1fdfa5f5f9590.tar.zst
dexon-solidity-2530223ab5c470c01b7e684f33e1fdfa5f5f9590.zip
More verbose errors for generated assembly.
Diffstat (limited to 'libsolidity/codegen/CompilerContext.cpp')
-rw-r--r--libsolidity/codegen/CompilerContext.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp
index 5a77162e..d87c7be5 100644
--- a/libsolidity/codegen/CompilerContext.cpp
+++ b/libsolidity/codegen/CompilerContext.cpp
@@ -26,6 +26,7 @@
#include <libsolidity/codegen/Compiler.h>
#include <libsolidity/interface/Version.h>
#include <libsolidity/interface/ErrorReporter.h>
+#include <libsolidity/interface/SourceReferenceFormatter.h>
#include <libsolidity/parsing/Scanner.h>
#include <libsolidity/inlineasm/AsmParser.h>
#include <libsolidity/inlineasm/AsmCodeGen.h>
@@ -312,8 +313,23 @@ void CompilerContext::appendInlineAssembly(
ErrorReporter errorReporter(errors);
auto scanner = make_shared<Scanner>(CharStream(_assembly), "--CODEGEN--");
auto parserResult = assembly::Parser(errorReporter).parse(scanner);
- solAssert(parserResult, "Failed to parse inline assembly block.");
- solAssert(errorReporter.errors().empty(), "Failed to parse inline assembly block.");
+ if (!parserResult || !errorReporter.errors().empty())
+ {
+ string message =
+ "Error parsing inline assembly block:\n"
+ "------------------ Input: -----------------\n" +
+ _assembly + "\n"
+ "------------------ Errors: ----------------\n";
+ for (auto const& error: errorReporter.errors())
+ message += SourceReferenceFormatter::formatExceptionInformation(
+ *error,
+ (error->type() == Error::Type::Warning) ? "Warning" : "Error",
+ [&](string const&) -> Scanner const& { return *scanner; }
+ );
+ message += "-------------------------------------------\n";
+
+ solAssert(false, message);
+ }
assembly::AsmAnalysisInfo analysisInfo;
assembly::AsmAnalyzer analyzer(analysisInfo, errorReporter, false, identifierAccess.resolve);