68 |
|
|
69 |
(* is the given statement's continuation the syntactically following statement? *) |
(* is the given statement's continuation the syntactically following statement? *) |
70 |
fun contIsNext (AST.S_Block stms) = List.all contIsNext stms |
fun contIsNext (AST.S_Block stms) = List.all contIsNext stms |
71 |
|
| contIsNext (AST.IfThenElse(_, s1, s2)) = contIsNext s1 orelse contIsNext s2 |
72 |
| contIsNext AST.S_Die = false |
| contIsNext AST.S_Die = false |
73 |
| contIsNext AST.S_Stabilize = false |
| contIsNext AST.S_Stabilize = false |
74 |
| contIsNext (AST.S_Return _) = false |
| contIsNext (AST.S_Return _) = false |
213 |
|
|
214 |
(* simplify the statement stm where stms is a reverse-order list of preceeding simplified |
(* simplify the statement stm where stms is a reverse-order list of preceeding simplified |
215 |
* statements. This function returns a reverse-order list of simplified statements. |
* statements. This function returns a reverse-order list of simplified statements. |
216 |
|
* Note that error reporting is done in the typechecker, but it does not prune unreachable |
217 |
|
* code. |
218 |
*) |
*) |
219 |
and simplifyStmt (stm, stms) = (case stm |
and simplifyStmt (stm, stms) = (case stm |
220 |
of AST.S_Block body => let |
of AST.S_Block body => let |
|
(* FIXME: we should probably prune unreachable code in the typechecker and issue a warning! *) |
|
221 |
fun simplify ([], stms) = stms |
fun simplify ([], stms) = stms |
222 |
| simplify (stm::r, stms) = if contIsNext stm |
| simplify (stm::r, stms) = if contIsNext stm |
223 |
then simplify (r, simplifyStmt (stm, stms)) |
then simplify (r, simplifyStmt (stm, stms)) |