Commit 634b779a authored by Guy Watson's avatar Guy Watson
Browse files

Add conditional branches

parent 088decd9
......@@ -36,6 +36,11 @@
[targetindex]) ;; a number depth
;; todo: the type of val should be unified with the target node
#:prop choice-weight 50]
[BranchIf Expr ([cond : Expr]
[val : Expr]
[targetnode]
[targetindex])
#:prop choice-weight 50]
)
;; Define structured control instruction property
......@@ -125,6 +130,8 @@
wasm-like
fresh
[Branch (match-let ([(cons index node) (choose-br-target (current-hole))])
(hash 'targetindex index 'targetnode node))]
[BranchIf (match-let ([(cons index node) (choose-br-target (current-hole))])
(hash 'targetindex index 'targetnode node))])
(add-att-rule
......@@ -164,6 +171,8 @@
'then int
'else int))]]
[Branch [int (λ (n t) (hash 'val int))]]
[BranchIf [int (λ (n t) (hash 'cond int
'val int))]]
)
(add-prop
......@@ -200,6 +209,12 @@
(append
(render-node (ast-child 'val n))
`(br ,(ast-child 'targetindex n))))]
[BranchIf (λ (n)
(append
(render-node (ast-child 'val n))
(render-node (ast-child 'cond n))
`(br_if ,(ast-child 'targetindex n))))]
)
(add-prop
......
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