Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/simplify/simplify.sml
 [diderot] / branches / vis12 / src / compiler / simplify / simplify.sml

# Diff of /branches/vis12/src/compiler/simplify/simplify.sml

revision 395, Thu Oct 14 16:52:15 2010 UTC revision 416, Sun Oct 17 00:32:07 2010 UTC
# Line 143  Line 143
143                  in                  in
144                    (stms, S.E_Cons xs)                    (stms, S.E_Cons xs)
145                  end                  end
146              | AST.E_Slice(e, indices) => let (* tensor slicing *)              | AST.E_Slice(e, indices, ty) => let (* tensor slicing *)
147                  val (stms, x) = simplifyExpToVar (e, stms)                  val (stms, x) = simplifyExpToVar (e, stms)
148                    fun f ([], ys, stms) = (stms, List.rev ys)
149                      | f (NONE::es, ys, stms) = f (es, NONE::ys, stms)
150                      | f (SOME e::es, ys, stms) = let
151                          val (stms, y) = simplifyExpToVar (e, stms)
152                  in                  in
153                    raise Fail "FIXME"                          f (es, SOME y::ys, stms)
154                  end                  end
155              | AST.E_Cond(e1, e2, e3) => let                  val (stms, indices) = f (indices, [], stms)
156                    in
157                      (stms, S.E_Slice(x, indices, ty))
158                    end
159                | AST.E_Cond(e1, e2, e3, ty) => let
160                (* a conditional expression gets turned into an if-then-else statememt *)                (* a conditional expression gets turned into an if-then-else statememt *)
161                  val result = newTemp Ty.T_Bool                  val result = newTemp ty
162                  val (stms, x) = simplifyExpToVar (e1, stms)                  val (stms, x) = simplifyExpToVar (e1, stms)
163                  fun simplifyBranch e = let                  fun simplifyBranch e = let
164                        val (stms, e) = simplifyExp (e, [])                        val (stms, e) = simplifyExp (e, [])
165                        in                        in
166                          mkBlock (S.S_Assign(result, e)::stms)                          mkBlock (S.S_Assign(result, e)::stms)
167                        end                        end
168                  val s1 = simplifyBranch e1                  val s1 = simplifyBranch e2
169                  val s2 = simplifyBranch e2                  val s2 = simplifyBranch e3
170                  in                  in
171                    (S.S_IfThenElse(x, s1, s2) :: stms, S.E_Var result)                    (S.S_IfThenElse(x, s1, s2) :: stms, S.E_Var result)
172                  end                  end

Legend:
 Removed from v.395 changed lines Added in v.416