Skip to content

Commit e44ed21

Browse files
cgeweckefedericobond
authored andcommitted
Allow return keyword to used as assembly opcode
1 parent bb2463d commit e44ed21

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

solidity.pegjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,8 +1610,18 @@ AssemblyAssignment
16101610
}
16111611
}
16121612

1613+
ReturnOpCode
1614+
= 'return' {
1615+
return {
1616+
type: "Identifier",
1617+
name: "return",
1618+
start: location().start.offset,
1619+
end: location().end.offset
1620+
}
1621+
}
1622+
16131623
FunctionalAssemblyInstruction
1614-
= name:Identifier __ '(' __ head:AssemblyItem? __ tail:( ',' __ AssemblyItem )* __ ')' {
1624+
= name:(Identifier / ReturnOpCode) __ '(' __ head:AssemblyItem? __ tail:( ',' __ AssemblyItem )* __ ')' {
16151625
return {
16161626
type: "FunctionalAssemblyInstruction",
16171627
name: name,

test/doc_examples.sol

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,19 @@ contract assemblyLocalBinding {
312312
}
313313
}
314314

315+
contract assemblyReturn {
316+
uint a = 10;
317+
318+
function get() constant returns(uint) {
319+
assembly {
320+
mstore(0x40, sload(0))
321+
byte(0)
322+
address(0)
323+
return(0x40,32)
324+
}
325+
}
326+
}
327+
315328
contract usesConst {
316329
uint const = 0;
317330
}

0 commit comments

Comments
 (0)