diff options
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 7 | ||||
-rw-r--r-- | libsolidity/grammar.txt | 6 | ||||
-rw-r--r-- | libsolidity/parsing/Token.h | 2 |
3 files changed, 11 insertions, 4 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 1cc4a50d..96ca4296 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -568,12 +568,17 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) break; case Location::Send: _functionCall.expression().accept(*this); - m_context << u256(0); // do not send gas (there still is the stipend) + // Provide the gas stipend manually at first because we may send zero ether. + // Will be zeroed if we send more than zero ether. + m_context << u256(eth::GasCosts::callStipend); arguments.front()->accept(*this); utils().convertType( *arguments.front()->annotation().type, *function.parameterTypes().front(), true ); + // gas <- gas * !value + m_context << Instruction::SWAP1 << Instruction::DUP2; + m_context << Instruction::ISZERO << Instruction::MUL << Instruction::SWAP1; appendExternalFunctionCall( FunctionType( TypePointers{}, diff --git a/libsolidity/grammar.txt b/libsolidity/grammar.txt index 86df3db0..755cf281 100644 --- a/libsolidity/grammar.txt +++ b/libsolidity/grammar.txt @@ -43,9 +43,9 @@ StorageLocation = 'memory' | 'storage' Block = '{' Statement* '}' Statement = IfStatement | WhileStatement | ForStatement | Block | ( PlaceholderStatement | Continue | Break | Return | - Throw | SimpleStatement | ExpressionStatement ) ';' + Throw | SimpleStatement ) ';' -ExpressionStatement = Expression | VariableDefinition +ExpressionStatement = Expression IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )? WhileStatement = 'while' '(' Expression ')' Statement PlaceholderStatement = '_' @@ -79,7 +79,7 @@ Expression = PrimaryExpression = Identifier | BooleanLiteral | NumberLiteral | StringLiteral -FunctionCall = Identifier '(' Expression? ( ',' Expression )* ')' +FunctionCall = ( PrimaryExpression | NewExpression | TypeName ) ( ( '.' Identifier ) | ( '[' Expression ']' ) )* '(' Expression? ( ',' Expression )* ')' NewExpression = 'new' Identifier MemberAccess = Expression '.' Identifier IndexAccess = Expression '[' Expression? ']' diff --git a/libsolidity/parsing/Token.h b/libsolidity/parsing/Token.h index cc85b610..2bf7419e 100644 --- a/libsolidity/parsing/Token.h +++ b/libsolidity/parsing/Token.h @@ -230,12 +230,14 @@ namespace solidity K(Let, "let", 0) \ K(Match, "match", 0) \ K(Of, "of", 0) \ + K(Pure, "pure", 0) \ K(Relocatable, "relocatable", 0) \ K(Static, "static", 0) \ K(Switch, "switch", 0) \ K(Try, "try", 0) \ K(Type, "type", 0) \ K(TypeOf, "typeof", 0) \ + K(View, "view", 0) \ /* Illegal token - not able to scan. */ \ T(Illegal, "ILLEGAL", 0) \ \ |