mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Pragma stdlib.
This commit is contained in:
parent
8af62d66af
commit
2d490a0213
@ -72,6 +72,8 @@ void SyntaxChecker::endVisit(SourceUnit const& _sourceUnit)
|
||||
}
|
||||
if (!m_sourceUnit->annotation().useABICoderV2.set())
|
||||
m_sourceUnit->annotation().useABICoderV2 = true;
|
||||
if (!m_sourceUnit->annotation().useStdlib.set())
|
||||
m_sourceUnit->annotation().useStdlib = false;
|
||||
m_sourceUnit = nullptr;
|
||||
}
|
||||
|
||||
@ -176,6 +178,19 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
|
||||
solAssert(false);
|
||||
}
|
||||
}
|
||||
else if (_pragma.literals()[0] == "stdlib")
|
||||
{
|
||||
solAssert(m_sourceUnit, "");
|
||||
if (m_evmVersion < EVMVersion::constantinople())
|
||||
m_errorReporter.syntaxError(
|
||||
6634_error,
|
||||
_pragma.location(),
|
||||
"\"pragma stdlib\" requires Constantinople EVM version at the minimum (selected EVM version is " +
|
||||
m_evmVersion.name() +
|
||||
")."
|
||||
);
|
||||
m_sourceUnit->annotation().useStdlib = true;
|
||||
}
|
||||
else
|
||||
m_errorReporter.syntaxError(4936_error, _pragma.location(), "Unknown pragma \"" + _pragma.literals()[0] + "\"");
|
||||
|
||||
|
@ -45,9 +45,10 @@ class SyntaxChecker: private ASTConstVisitor
|
||||
{
|
||||
public:
|
||||
/// @param _errorReporter provides the error logging functionality.
|
||||
SyntaxChecker(langutil::ErrorReporter& _errorReporter, bool _useYulOptimizer):
|
||||
SyntaxChecker(langutil::ErrorReporter& _errorReporter, bool _useYulOptimizer, langutil::EVMVersion _evmVersion):
|
||||
m_errorReporter(_errorReporter),
|
||||
m_useYulOptimizer(_useYulOptimizer)
|
||||
m_useYulOptimizer(_useYulOptimizer),
|
||||
m_evmVersion(_evmVersion)
|
||||
{}
|
||||
|
||||
bool checkSyntax(ASTNode const& _astRoot);
|
||||
@ -101,6 +102,8 @@ private:
|
||||
|
||||
bool m_useYulOptimizer = false;
|
||||
|
||||
langutil::EVMVersion m_evmVersion;
|
||||
|
||||
/// Flag that indicates whether a function modifier actually contains '_'.
|
||||
bool m_placeholderFound = false;
|
||||
|
||||
|
@ -97,6 +97,8 @@ struct SourceUnitAnnotation: ASTAnnotation
|
||||
std::set<ExperimentalFeature> experimentalFeatures;
|
||||
/// Using the new ABI coder. Set to `false` if using ABI coder v1.
|
||||
util::SetOnce<bool> useABICoderV2;
|
||||
/// Using the new standard library mechanism.
|
||||
util::SetOnce<bool> useStdlib;
|
||||
};
|
||||
|
||||
struct ScopableAnnotation
|
||||
|
@ -444,7 +444,7 @@ bool CompilerStack::analyze()
|
||||
|
||||
try
|
||||
{
|
||||
SyntaxChecker syntaxChecker(m_errorReporter, m_optimiserSettings.runYulOptimiser);
|
||||
SyntaxChecker syntaxChecker(m_errorReporter, m_optimiserSettings.runYulOptimiser, m_evmVersion);
|
||||
for (Source const* source: m_sourceOrder)
|
||||
if (source->ast && !syntaxChecker.checkSyntax(*source->ast))
|
||||
noErrors = false;
|
||||
|
@ -0,0 +1,4 @@
|
||||
pragma stdlib;
|
||||
// ====
|
||||
// EVMVersion: <constantinople
|
||||
// ----
|
Loading…
Reference in New Issue
Block a user