diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-03-07 00:07:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-07 00:07:03 +0800 |
commit | 14b12ae7452388516d0c4eb833b0c83fe5156b44 (patch) | |
tree | ff814ac430ddc4fc56ba8753777e5bf32f7663b7 /libsolidity | |
parent | 83dacbf669f58ad40e3035837d4ea8a846c46949 (diff) | |
parent | 3057aeece495276265d9632b97e3faffcb57fe71 (diff) | |
download | dexon-solidity-14b12ae7452388516d0c4eb833b0c83fe5156b44.tar.gz dexon-solidity-14b12ae7452388516d0c4eb833b0c83fe5156b44.tar.zst dexon-solidity-14b12ae7452388516d0c4eb833b0c83fe5156b44.zip |
Merge pull request #2966 from ethereum/useStaticCall
Use STATICCALL for pure function calls.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/ast/ExperimentalFeatures.h | 4 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/libsolidity/ast/ExperimentalFeatures.h b/libsolidity/ast/ExperimentalFeatures.h index a17778b4..30ea7ec5 100644 --- a/libsolidity/ast/ExperimentalFeatures.h +++ b/libsolidity/ast/ExperimentalFeatures.h @@ -29,8 +29,8 @@ namespace solidity enum class ExperimentalFeature { - SMTChecker, ABIEncoderV2, // new ABI encoder that makes use of JULIA + SMTChecker, V050, // v0.5.0 breaking changes Test, TestOnlyAnalysis @@ -45,8 +45,8 @@ static const std::map<ExperimentalFeature, bool> ExperimentalFeatureOnlyAnalysis static const std::map<std::string, ExperimentalFeature> ExperimentalFeatureNames = { - { "SMTChecker", ExperimentalFeature::SMTChecker }, { "ABIEncoderV2", ExperimentalFeature::ABIEncoderV2 }, + { "SMTChecker", ExperimentalFeature::SMTChecker }, { "v0.5.0", ExperimentalFeature::V050 }, { "__test", ExperimentalFeature::Test }, { "__testOnlyAnalysis", ExperimentalFeature::TestOnlyAnalysis }, diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index d27af7db..7162cb0d 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1610,6 +1610,10 @@ void ExpressionCompiler::appendExternalFunctionCall( bool returnSuccessCondition = funKind == FunctionType::Kind::BareCall || funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::BareDelegateCall; bool isCallCode = funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::CallCode; bool isDelegateCall = funKind == FunctionType::Kind::BareDelegateCall || funKind == FunctionType::Kind::DelegateCall; + bool useStaticCall = + _functionType.stateMutability() <= StateMutability::View && + m_context.experimentalFeatureActive(ExperimentalFeature::V050) && + m_context.evmVersion().hasStaticCall(); unsigned retSize = 0; if (returnSuccessCondition) @@ -1738,6 +1742,8 @@ void ExpressionCompiler::appendExternalFunctionCall( // [value,] addr, gas (stack top) if (isDelegateCall) solAssert(!_functionType.valueSet(), "Value set for delegatecall"); + else if (useStaticCall) + solAssert(!_functionType.valueSet(), "Value set for staticcall"); else if (_functionType.valueSet()) m_context << dupInstruction(m_context.baseToCurrentStackOffset(valueStackPos)); else @@ -1769,10 +1775,13 @@ void ExpressionCompiler::appendExternalFunctionCall( gasNeededByCaller += eth::GasCosts::callNewAccountGas; // we never know m_context << gasNeededByCaller << Instruction::GAS << Instruction::SUB; } + // Order is important here, STATICCALL might overlap with DELEGATECALL. if (isDelegateCall) m_context << Instruction::DELEGATECALL; else if (isCallCode) m_context << Instruction::CALLCODE; + else if (useStaticCall) + m_context << Instruction::STATICCALL; else m_context << Instruction::CALL; |