143 |
(* dummy node *) |
(* dummy node *) |
144 |
val dummy : node |
val dummy : node |
145 |
(* CFG edges *) |
(* CFG edges *) |
146 |
|
val hasPred : node -> bool |
147 |
val preds : node -> node list |
val preds : node -> node list |
148 |
val setPred : node * node -> unit |
val setPred : node * node -> unit |
149 |
val hasSucc : node -> bool |
val hasSucc : node -> bool |
369 |
fun mkSTABILIZE () = new (STABILIZE{pred = ref dummy}) |
fun mkSTABILIZE () = new (STABILIZE{pred = ref dummy}) |
370 |
fun mkEXIT () = new (EXIT{pred = ref dummy}) |
fun mkEXIT () = new (EXIT{pred = ref dummy}) |
371 |
(* editing node edges *) |
(* editing node edges *) |
372 |
|
fun hasPred (ND{kind, ...}) = (case kind |
373 |
|
of NULL => false |
374 |
|
| ENTRY _ => false |
375 |
|
| _ => true |
376 |
|
(* end case *)) |
377 |
fun setPred (nd0 as ND{kind, ...}, nd) = (case kind |
fun setPred (nd0 as ND{kind, ...}, nd) = (case kind |
378 |
of NULL => raise Fail("setPred on NULL node "^toString nd0) |
of NULL => raise Fail("setPred on NULL node "^toString nd0) |
379 |
| ENTRY _ => raise Fail("setPred on ENTRY node "^toString nd0) |
| ENTRY _ => raise Fail("setPred on ENTRY node "^toString nd0) |
548 |
end |
end |
549 |
|
|
550 |
(* replace a simple node in a cfg with a subgraph *) |
(* replace a simple node in a cfg with a subgraph *) |
551 |
fun splice (nd, CFG{entry, exit}) = ?? |
fun splice (nd as ND{kind, ...}, CFG{entry, exit}) = (case kind |
552 |
|
of ASSIGN{pred, succ, ...} => ( |
553 |
|
Node.addEdge (!pred, !entry); |
554 |
|
Node.addEdge (!exit, !succ)) |
555 |
|
| _ => raise Fail "unsupported splice" |
556 |
|
(* end case *)) |
557 |
|
|
558 |
end |
end |
559 |
|
|