Merge pull request #3643 from ethereum/gasleft

Move msg.gas to global function gasleft(). Closes #2971.
This commit is contained in:
chriseth
2018-03-05 20:11:37 +01:00
committed by GitHub
11 changed files with 116 additions and 8 deletions
@@ -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")