Skip to content

Commit

Permalink
Add rules for (deprecated) Yul labels
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Aug 21, 2024
1 parent 7cc66df commit 1997c67
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/solidity/inputs/language/bindings/rules.msgb
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,17 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
edge @body.lexical_scope -> @init.defs
}

;;; (Deprecated) Label statements

@block [YulBlock [YulStatements [YulStatement @label [YulLabel @name label: [YulIdentifier]]]]] {
node def
attr (def) node_definition = @name
attr (def) definiens_node = @label

; Labels are hoisted to the beginning of the block
edge @block.lexical_scope -> def
}

;;; Expressions

@expr [YulExpression] {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
contract Test {
function test() public {
// ^def:dummy
assembly {
let n := calldataload(4)
let a := 1
let b := a
loop:
//<def:1 (< 0.5.0)
jumpi(loopend, eq(n, 0))
// ^ref:2 (< 0.5.0)
// ^ref:! (>= 0.5.0)
a add swap1
n := sub(n, 1)
jump(loop)
// ^ref:1 (< 0.5.0)
// ^ref:! (>= 0.5.0)
loopend:
//<def:2 (< 0.5.0)
mstore(0, a)
return(0, 0x20)
}
}
}

0 comments on commit 1997c67

Please sign in to comment.