Add CompilerStack.setStdlib

This commit is contained in:
Alex Beregszaszi 2022-06-27 00:18:33 +02:00
parent e0727076d3
commit 2a07c6dfdc
2 changed files with 17 additions and 1 deletions

View File

@ -218,6 +218,13 @@ void CompilerStack::setViaIR(bool _viaIR)
m_viaIR = _viaIR;
}
void CompilerStack::setStdlib(bool _stdlib)
{
if (m_stackState >= ParsedAndImported)
solThrow(CompilerError, "Must set stdlib before parsing.");
m_stdlib = _stdlib;
}
void CompilerStack::setEVMVersion(langutil::EVMVersion _version)
{
if (m_stackState >= ParsedAndImported)
@ -340,6 +347,10 @@ bool CompilerStack::parse()
Parser parser{m_errorReporter, m_evmVersion, m_parserErrorRecovery};
if (m_stdlib) {
// TODO: fill out m_sources
}
vector<string> sourcesToParse;
for (auto const& s: m_sources)
sourcesToParse.push_back(s.first);
@ -433,7 +444,7 @@ bool CompilerStack::analyze()
if (source->ast && !syntaxChecker.checkSyntax(*source->ast))
noErrors = false;
m_globalContext = make_shared<GlobalContext>(false);
m_globalContext = make_shared<GlobalContext>(m_stdlib);
// We need to keep the same resolver during the whole process.
NameAndTypeResolver resolver(*m_globalContext, m_evmVersion, m_errorReporter);
for (Source const* source: m_sourceOrder)

View File

@ -169,6 +169,10 @@ public:
/// Must be set before parsing.
void setViaIR(bool _viaIR);
/// Sets the pipeline to use the stdlib or not.
/// Must be set before parsing.
void setStdlib(bool _stdlib);
/// Set the EVM version used before running compile.
/// When called without an argument it will revert to the default version.
/// Must be set before parsing.
@ -487,6 +491,7 @@ private:
RevertStrings m_revertStrings = RevertStrings::Default;
State m_stopAfter = State::CompilationSuccessful;
bool m_viaIR = false;
bool m_stdlib = false;
langutil::EVMVersion m_evmVersion;
ModelCheckerSettings m_modelCheckerSettings;
std::map<std::string, std::set<std::string>> m_requestedContractNames;