Commit a1d9d545 authored by Guy Watson's avatar Guy Watson
Browse files

Add 'block', 'loop', and 'if' instructions

parent d11d6621
......@@ -7,9 +7,9 @@ Control Instructions
[ ] unreachable
[ ] nop
[ ] block
[ ] loop
[ ] if
[*] block
[*] loop
[*] if
[*] if else
[*] br
[*] br_if
......@@ -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]
[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 @@
[Func (λ (n) #t)]
[IfElse (λ (n) #t)]
[If (λ (n) #t)]
[Block (λ (n) #t)]
[Loop (λ (n) #t)]
(define (get-nesting-types node)
......@@ -249,13 +262,14 @@
[#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 @@
(render-node (ast-child 'else n))
[If (λ (n)
(render-node (ast-child 'cond n))
'(if (result i32))
(render-node (ast-child 'then n))
[Block (λ (n)
'(block (result i32))
(render-node (ast-child 'e n))
[Loop (λ (n)
'(loop (result i32))
(render-node (ast-child 'e n))
[Branch (λ (n)
(render-node (ast-child 'val n))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment