aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/ExpressionCompiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 61920592..0ce70f38 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -906,6 +906,9 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
m_context << success;
break;
}
+ case FunctionType::Kind::GasLeft:
+ m_context << Instruction::GAS;
+ break;
default:
solAssert(false, "Invalid function type.");
}
@@ -921,6 +924,8 @@ bool ExpressionCompiler::visit(NewExpression const&)
bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
{
+ bool const v050 = m_context.experimentalFeatureActive(ExperimentalFeature::V050);
+
CompilerContext::LocationSetter locationSetter(m_context, _memberAccess);
// Check whether the member is a bound function.
ASTString const& member = _memberAccess.memberName();
@@ -1136,7 +1141,10 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
else if (member == "origin")
m_context << Instruction::ORIGIN;
else if (member == "gas")
+ {
+ solAssert(!v050, "");
m_context << Instruction::GAS;
+ }
else if (member == "gasprice")
m_context << Instruction::GASPRICE;
else if (member == "data")
@@ -1671,16 +1679,19 @@ void ExpressionCompiler::appendExternalFunctionCall(
utils().storeFreeMemoryPointer();
}
- // Touch the end of the output area so that we do not pay for memory resize during the call
- // (which we would have to subtract from the gas left)
- // We could also just use MLOAD; POP right before the gas calculation, but the optimizer
- // would remove that, so we use MSTORE here.
- if (!_functionType.gasSet() && retSize > 0)
+ if (!m_context.evmVersion().canOverchargeGasForCall())
{
- m_context << u256(0);
- utils().fetchFreeMemoryPointer();
- // This touches too much, but that way we save some rounding arithmetics
- m_context << u256(retSize) << Instruction::ADD << Instruction::MSTORE;
+ // Touch the end of the output area so that we do not pay for memory resize during the call
+ // (which we would have to subtract from the gas left)
+ // We could also just use MLOAD; POP right before the gas calculation, but the optimizer
+ // would remove that, so we use MSTORE here.
+ if (!_functionType.gasSet() && retSize > 0)
+ {
+ m_context << u256(0);
+ utils().fetchFreeMemoryPointer();
+ // This touches too much, but that way we save some rounding arithmetics
+ m_context << u256(retSize) << Instruction::ADD << Instruction::MSTORE;
+ }
}
// Copy function identifier to memory.
@@ -1749,14 +1760,14 @@ void ExpressionCompiler::appendExternalFunctionCall(
if (_functionType.gasSet())
m_context << dupInstruction(m_context.baseToCurrentStackOffset(gasStackPos));
- else if (m_context.experimentalFeatureActive(ExperimentalFeature::V050))
+ else if (m_context.evmVersion().canOverchargeGasForCall())
// Send all gas (requires tangerine whistle EVM)
m_context << Instruction::GAS;
else
{
// send all gas except the amount needed to execute "SUB" and "CALL"
// @todo this retains too much gas for now, needs to be fine-tuned.
- u256 gasNeededByCaller = eth::GasCosts::callGas + 10;
+ u256 gasNeededByCaller = eth::GasCosts::callGas(m_context.evmVersion()) + 10;
if (_functionType.valueSet())
gasNeededByCaller += eth::GasCosts::callValueTransferGas;
if (!existenceChecked)