mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove error reporter from code generation phase.
This commit is contained in:
@@ -524,9 +524,6 @@ bool ContractCompiler::visit(FunctionDefinition const& _function)
|
||||
|
||||
bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
|
||||
{
|
||||
ErrorList errors;
|
||||
ErrorReporter errorReporter(errors);
|
||||
assembly::CodeGenerator codeGen(errorReporter);
|
||||
unsigned startStackHeight = m_context.stackHeight();
|
||||
julia::ExternalIdentifierAccess identifierAccess;
|
||||
identifierAccess.resolve = [&](assembly::Identifier const& _identifier, julia::IdentifierContext, bool)
|
||||
@@ -648,13 +645,12 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
|
||||
}
|
||||
};
|
||||
solAssert(_inlineAssembly.annotation().analysisInfo, "");
|
||||
codeGen.assemble(
|
||||
assembly::CodeGenerator::assemble(
|
||||
_inlineAssembly.operations(),
|
||||
*_inlineAssembly.annotation().analysisInfo,
|
||||
m_context.nonConstAssembly(),
|
||||
identifierAccess
|
||||
);
|
||||
solAssert(Error::containsOnlyWarnings(errorReporter.errors()), "Code generation for inline assembly with errors requested.");
|
||||
m_context.setStackOffset(startStackHeight);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ eth::Assembly assembly::CodeGenerator::assemble(
|
||||
{
|
||||
eth::Assembly assembly;
|
||||
EthAssemblyAdapter assemblyAdapter(assembly);
|
||||
julia::CodeTransform(m_errorReporter, assemblyAdapter, _analysisInfo, false, _identifierAccess).run(_parsedData);
|
||||
julia::CodeTransform(assemblyAdapter, _analysisInfo, false, _identifierAccess).run(_parsedData);
|
||||
return assembly;
|
||||
}
|
||||
|
||||
@@ -152,5 +152,5 @@ void assembly::CodeGenerator::assemble(
|
||||
)
|
||||
{
|
||||
EthAssemblyAdapter assemblyAdapter(_assembly);
|
||||
julia::CodeTransform(m_errorReporter, assemblyAdapter, _analysisInfo, false, _identifierAccess).run(_parsedData);
|
||||
julia::CodeTransform(assemblyAdapter, _analysisInfo, false, _identifierAccess).run(_parsedData);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ class Assembly;
|
||||
}
|
||||
namespace solidity
|
||||
{
|
||||
class ErrorReporter;
|
||||
namespace assembly
|
||||
{
|
||||
struct Block;
|
||||
@@ -42,24 +41,19 @@ struct Block;
|
||||
class CodeGenerator
|
||||
{
|
||||
public:
|
||||
CodeGenerator(ErrorReporter& _errorReporter):
|
||||
m_errorReporter(_errorReporter) {}
|
||||
/// Performs code generation and @returns the result.
|
||||
eth::Assembly assemble(
|
||||
static eth::Assembly assemble(
|
||||
Block const& _parsedData,
|
||||
AsmAnalysisInfo& _analysisInfo,
|
||||
julia::ExternalIdentifierAccess const& _identifierAccess = julia::ExternalIdentifierAccess()
|
||||
);
|
||||
/// Performs code generation and appends generated to to _assembly.
|
||||
void assemble(
|
||||
static void assemble(
|
||||
Block const& _parsedData,
|
||||
AsmAnalysisInfo& _analysisInfo,
|
||||
eth::Assembly& _assembly,
|
||||
julia::ExternalIdentifierAccess const& _identifierAccess = julia::ExternalIdentifierAccess()
|
||||
);
|
||||
|
||||
private:
|
||||
ErrorReporter& m_errorReporter;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -66,8 +66,7 @@ eth::Assembly InlineAssemblyStack::assemble()
|
||||
AsmAnalysisInfo analysisInfo;
|
||||
AsmAnalyzer analyzer(analysisInfo, m_errorReporter);
|
||||
solAssert(analyzer.analyze(*m_parserResult), "");
|
||||
CodeGenerator codeGen(m_errorReporter);
|
||||
return codeGen.assemble(*m_parserResult, analysisInfo);
|
||||
return CodeGenerator::assemble(*m_parserResult, analysisInfo);
|
||||
}
|
||||
|
||||
bool InlineAssemblyStack::parseAndAssemble(
|
||||
@@ -87,7 +86,8 @@ bool InlineAssemblyStack::parseAndAssemble(
|
||||
AsmAnalysisInfo analysisInfo;
|
||||
AsmAnalyzer analyzer(analysisInfo, errorReporter, false, _identifierAccess.resolve);
|
||||
solAssert(analyzer.analyze(*parserResult), "");
|
||||
CodeGenerator(errorReporter).assemble(*parserResult, analysisInfo, _assembly, _identifierAccess);
|
||||
solAssert(errorReporter.errors().empty(), "");
|
||||
CodeGenerator::assemble(*parserResult, analysisInfo, _assembly, _identifierAccess);
|
||||
|
||||
// At this point, the assembly might be messed up, but we should throw an
|
||||
// internal compiler error anyway.
|
||||
|
||||
@@ -76,7 +76,7 @@ bool AssemblyStack::analyzeParsed()
|
||||
return m_analysisSuccessful;
|
||||
}
|
||||
|
||||
eth::LinkerObject AssemblyStack::assemble(Machine _machine)
|
||||
eth::LinkerObject AssemblyStack::assemble(Machine _machine) const
|
||||
{
|
||||
solAssert(m_analysisSuccessful, "");
|
||||
solAssert(m_parserResult, "");
|
||||
@@ -86,13 +86,13 @@ eth::LinkerObject AssemblyStack::assemble(Machine _machine)
|
||||
{
|
||||
case Machine::EVM:
|
||||
{
|
||||
auto assembly = assembly::CodeGenerator(m_errorReporter).assemble(*m_parserResult, *m_analysisInfo);
|
||||
auto assembly = assembly::CodeGenerator::assemble(*m_parserResult, *m_analysisInfo);
|
||||
return assembly.assemble();
|
||||
}
|
||||
case Machine::EVM15:
|
||||
{
|
||||
julia::EVMAssembly assembly(true);
|
||||
julia::CodeTransform(m_errorReporter, assembly, *m_analysisInfo, true).run(*m_parserResult);
|
||||
julia::CodeTransform(assembly, *m_analysisInfo, true).run(*m_parserResult);
|
||||
return assembly.finalize();
|
||||
}
|
||||
case Machine::eWasm:
|
||||
@@ -102,7 +102,7 @@ eth::LinkerObject AssemblyStack::assemble(Machine _machine)
|
||||
return eth::LinkerObject();
|
||||
}
|
||||
|
||||
string AssemblyStack::print()
|
||||
string AssemblyStack::print() const
|
||||
{
|
||||
solAssert(m_parserResult, "");
|
||||
return assembly::AsmPrinter(m_language == Language::JULIA)(*m_parserResult);
|
||||
|
||||
@@ -65,13 +65,13 @@ public:
|
||||
bool analyze(assembly::Block const& _block, Scanner const* _scanner = nullptr);
|
||||
|
||||
/// Run the assembly step (should only be called after parseAndAnalyze).
|
||||
eth::LinkerObject assemble(Machine _machine);
|
||||
eth::LinkerObject assemble(Machine _machine) const;
|
||||
|
||||
/// @returns the errors generated during parsing, analysis (and potentially assembly).
|
||||
ErrorList const& errors() const { return m_errors; }
|
||||
|
||||
/// Pretty-print the input after having parsed it.
|
||||
std::string print();
|
||||
std::string print() const;
|
||||
|
||||
private:
|
||||
bool analyzeParsed();
|
||||
|
||||
Reference in New Issue
Block a user