Browse Source
Currently, a variable can be named in two different ways in an ISLE pattern. One can write a pattern like `(T x y)` that binds the two args of `T` with the subpatterns `x` and `y`, each of which match anything and capture the value as a bound variable. Or, one can write a pattern like `(T x =x)`, where the first arg pattern `x` captures the value in `x` and the second arg pattern `=x` matches only the same value that was already captured. It turns out (thanks to @fitzgen for this insight here [1]) that this distinction can actually be inferred easily: if `x` isn't bound, then mentioning it binds it; otherwise, it matches only the already-bound variable. There's no concern about ordering (one mention binding vs. the other) because (i) the value is equal either way, and (ii) the types at both sites must be the same. This language tweak seems like it should simplify things nicely! We can remove the `=x` syntax later if we want, but this PR doesn't do so. [1] https://github.com/bytecodealliance/wasmtime/pull/4071#discussion_r859111513pull/4078/head
Chris Fallin
3 years ago
committed by
GitHub
5 changed files with 73 additions and 32 deletions
@ -0,0 +1,7 @@ |
|||
(type u32 (primitive u32)) |
|||
(type u64 (primitive u64)) |
|||
|
|||
(decl A (u32 u64) u32) |
|||
|
|||
(rule 1 (A x x) x) |
|||
(rule 0 (A x _) 0) |
@ -0,0 +1,6 @@ |
|||
(type u32 (primitive u32)) |
|||
|
|||
(decl A (u32 u32) u32) |
|||
|
|||
(rule 1 (A x x) x) |
|||
(rule 0 (A x _) 0) |
Loading…
Reference in new issue