Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
xsmith
WebAssembly Sandbox
Commits
a1d9d545
Commit
a1d9d545
authored
Mar 12, 2020
by
Guy Watson
Browse files
Add 'block', 'loop', and 'if' instructions
parent
d11d6621
Changes
2
Hide whitespace changes
Inline
Side-by-side
wasmlike/instructions.txt
View file @
a1d9d545
...
...
@@ -7,9 +7,9 @@ Control Instructions
--------------------
[ ] unreachable
[ ] nop
[
] block
[
] loop
[
] if
[
*
] block
[
*
] loop
[
*
] if
[*] if else
[*] br
[*] br_if
...
...
wasmlike/wasmlike.rkt
View file @
a1d9d545
...
...
@@ -89,6 +89,10 @@
[
then
:
Expr
]
[
else
:
Expr
])
#:prop
choice-weight
10
]
[
If
Expr
([
cond
:
Expr
]
[
then
:
Expr
])]
[
Block
Expr
([
e
:
Expr
])]
[
Loop
Expr
([
e
:
Expr
])]
[
Branch
Expr
([
val
:
Expr
]
[
targetnode
]
[
targetindex
])
;; a number depth
...
...
@@ -191,6 +195,12 @@
(
hash
'cond
int
'then
int
'else
int
))]]
[
If
[
int
(
λ
(
n
t
)
(
hash
'cond
int
'then
int
))]]
[
Block
[
int
(
λ
(
n
t
)
(
hash
'e
int
))]]
[
Loop
[
int
(
λ
(
n
t
)
(
hash
'e
int
))]]
[
Branch
[
int
(
λ
(
n
t
)
(
hash
'val
int
))]]
[
BranchIf
[
int
(
λ
(
n
t
)
(
hash
'cond
int
'val
int
))]]
...
...
@@ -219,6 +229,9 @@
structured-control-instruction
[
Func
(
λ
(
n
)
#t
)]
[
IfElse
(
λ
(
n
)
#t
)]
[
If
(
λ
(
n
)
#t
)]
[
Block
(
λ
(
n
)
#t
)]
[
Loop
(
λ
(
n
)
#t
)]
)
(
define
(
get-nesting-types
node
)
...
...
@@ -249,13 +262,14 @@
parent
#f
))))
(
add-att-rule
wasm-like
control-valid?
[
#f
(
λ
(
n
c
)
#t
)]
[
IfElse
(
λ
(
n
c
)
(
not
(
eq?
(
ast-child
'cond
n
)
c
)))]
[
If
(
λ
(
n
c
)
(
not
(
eq?
(
ast-child
'cond
n
)
c
)))]
)
...
...
@@ -328,6 +342,22 @@
'
(
else
)
(
render-node
(
ast-child
'else
n
))
'
(
end
)))]
[
If
(
λ
(
n
)
(
append
(
render-node
(
ast-child
'cond
n
))
'
(
if
(
result
i32
))
(
render-node
(
ast-child
'then
n
))
'
(
end
)))]
[
Block
(
λ
(
n
)
(
append
'
(
block
(
result
i32
))
(
render-node
(
ast-child
'e
n
))
'
(
end
)))]
[
Loop
(
λ
(
n
)
(
append
'
(
loop
(
result
i32
))
(
render-node
(
ast-child
'e
n
))
'
(
end
)))]
[
Branch
(
λ
(
n
)
(
append
(
render-node
(
ast-child
'val
n
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment