mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make dialect const& and allocate single instances statically.
This commit is contained in:
+11
-14
@@ -69,10 +69,7 @@ bool AsmAnalyzer::analyze(Block const& _block)
|
||||
return success && !m_errorReporter.hasErrors();
|
||||
}
|
||||
|
||||
AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect(
|
||||
shared_ptr<Dialect const> _dialect,
|
||||
Block const& _ast
|
||||
)
|
||||
AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect(Dialect const& _dialect, Block const& _ast)
|
||||
{
|
||||
ErrorList errorList;
|
||||
langutil::ErrorReporter errors(errorList);
|
||||
@@ -134,7 +131,7 @@ bool AsmAnalyzer::operator()(Literal const& _literal)
|
||||
}
|
||||
else if (_literal.kind == LiteralKind::Boolean)
|
||||
{
|
||||
solAssert(m_dialect->flavour == AsmFlavour::Yul, "");
|
||||
solAssert(m_dialect.flavour == AsmFlavour::Yul, "");
|
||||
solAssert(_literal.value == "true"_yulstring || _literal.value == "false"_yulstring, "");
|
||||
}
|
||||
m_info.stackHeightInfo[&_literal] = m_stackHeight;
|
||||
@@ -197,7 +194,7 @@ bool AsmAnalyzer::operator()(Identifier const& _identifier)
|
||||
|
||||
bool AsmAnalyzer::operator()(FunctionalInstruction const& _instr)
|
||||
{
|
||||
solAssert(m_dialect->flavour != AsmFlavour::Yul, "");
|
||||
solAssert(m_dialect.flavour != AsmFlavour::Yul, "");
|
||||
bool success = true;
|
||||
for (auto const& arg: _instr.arguments | boost::adaptors::reversed)
|
||||
if (!expectExpression(arg))
|
||||
@@ -215,9 +212,9 @@ bool AsmAnalyzer::operator()(ExpressionStatement const& _statement)
|
||||
{
|
||||
int initialStackHeight = m_stackHeight;
|
||||
bool success = boost::apply_visitor(*this, _statement.expression);
|
||||
if (m_stackHeight != initialStackHeight && (m_dialect->flavour != AsmFlavour::Loose || m_errorTypeForLoose))
|
||||
if (m_stackHeight != initialStackHeight && (m_dialect.flavour != AsmFlavour::Loose || m_errorTypeForLoose))
|
||||
{
|
||||
Error::Type errorType = m_dialect->flavour == AsmFlavour::Loose ? *m_errorTypeForLoose : Error::Type::TypeError;
|
||||
Error::Type errorType = m_dialect.flavour == AsmFlavour::Loose ? *m_errorTypeForLoose : Error::Type::TypeError;
|
||||
string msg =
|
||||
"Top-level expressions are not supposed to return values (this expression returns " +
|
||||
to_string(m_stackHeight - initialStackHeight) +
|
||||
@@ -333,7 +330,7 @@ bool AsmAnalyzer::operator()(FunctionCall const& _funCall)
|
||||
size_t parameters = 0;
|
||||
size_t returns = 0;
|
||||
bool needsLiteralArguments = false;
|
||||
if (BuiltinFunction const* f = m_dialect->builtin(_funCall.functionName.name))
|
||||
if (BuiltinFunction const* f = m_dialect.builtin(_funCall.functionName.name))
|
||||
{
|
||||
// TODO: compare types, too
|
||||
parameters = f->parameters.size();
|
||||
@@ -423,7 +420,7 @@ bool AsmAnalyzer::operator()(Switch const& _switch)
|
||||
if (!expectExpression(*_switch.expression))
|
||||
success = false;
|
||||
|
||||
if (m_dialect->flavour == AsmFlavour::Yul)
|
||||
if (m_dialect.flavour == AsmFlavour::Yul)
|
||||
{
|
||||
YulString caseType;
|
||||
bool mismatchingTypes = false;
|
||||
@@ -658,7 +655,7 @@ Scope& AsmAnalyzer::scope(Block const* _block)
|
||||
}
|
||||
void AsmAnalyzer::expectValidType(string const& type, SourceLocation const& _location)
|
||||
{
|
||||
if (m_dialect->flavour != AsmFlavour::Yul)
|
||||
if (m_dialect.flavour != AsmFlavour::Yul)
|
||||
return;
|
||||
|
||||
if (!builtinTypes.count(type))
|
||||
@@ -675,7 +672,7 @@ void AsmAnalyzer::warnOnInstructions(dev::eth::Instruction _instr, SourceLocatio
|
||||
solAssert(m_evmVersion.supportsReturndata() == m_evmVersion.hasStaticCall(), "");
|
||||
// Similarly we assume bitwise shifting and create2 go together.
|
||||
solAssert(m_evmVersion.hasBitwiseShifting() == m_evmVersion.hasCreate2(), "");
|
||||
solAssert(m_dialect->flavour != AsmFlavour::Yul, "");
|
||||
solAssert(m_dialect.flavour != AsmFlavour::Yul, "");
|
||||
|
||||
auto errorForVM = [=](string const& vmKindMessage) {
|
||||
m_errorReporter.typeError(
|
||||
@@ -724,7 +721,7 @@ void AsmAnalyzer::warnOnInstructions(dev::eth::Instruction _instr, SourceLocatio
|
||||
_instr == dev::eth::Instruction::JUMPDEST
|
||||
)
|
||||
{
|
||||
if (m_dialect->flavour == AsmFlavour::Loose)
|
||||
if (m_dialect.flavour == AsmFlavour::Loose)
|
||||
m_errorReporter.error(
|
||||
m_errorTypeForLoose ? *m_errorTypeForLoose : Error::Type::Warning,
|
||||
_location,
|
||||
@@ -745,7 +742,7 @@ void AsmAnalyzer::warnOnInstructions(dev::eth::Instruction _instr, SourceLocatio
|
||||
|
||||
void AsmAnalyzer::checkLooseFeature(SourceLocation const& _location, string const& _description)
|
||||
{
|
||||
if (m_dialect->flavour != AsmFlavour::Loose)
|
||||
if (m_dialect.flavour != AsmFlavour::Loose)
|
||||
solAssert(false, _description);
|
||||
else if (m_errorTypeForLoose)
|
||||
m_errorReporter.error(*m_errorTypeForLoose, _location, _description);
|
||||
|
||||
Reference in New Issue
Block a user