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]
#:prop choice-weight 50]
;; Define structured control instruction property
......@@ -125,7 +130,9 @@
[Branch (match-let ([(cons index node) (choose-br-target (current-hole))])
(hash 'targetindex index 'targetnode node))])
(hash 'targetindex index 'targetnode node))]
[BranchIf (match-let ([(cons index node) (choose-br-target (current-hole))])
(hash 'targetindex index 'targetnode node))])
......@@ -164,6 +171,8 @@
'then int
'else int))]]
[Branch [int (λ (n t) (hash 'val int))]]
[BranchIf [int (λ (n t) (hash 'cond int
'val int))]]
......@@ -200,6 +209,12 @@
(render-node (ast-child 'val n))
`(br ,(ast-child 'targetindex n))))]
[BranchIf (λ (n)
(render-node (ast-child 'val n))
(render-node (ast-child 'cond n))
`(br_if ,(ast-child 'targetindex 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