From 5faaf41320352ec05afe9d75d4d85ff6859835e1 Mon Sep 17 00:00:00 2001 From: Philippe Suter <philippe.suter@gmail.com> Date: Thu, 10 Jun 2010 17:40:40 +0000 Subject: [PATCH] starting to plug the parts --- ParseMe.scala | 21 --------------------- src/purescala/Analysis.scala | 10 ++++++++++ 2 files changed, 10 insertions(+), 21 deletions(-) delete mode 100644 ParseMe.scala diff --git a/ParseMe.scala b/ParseMe.scala deleted file mode 100644 index 8e737aeb7..000000000 --- a/ParseMe.scala +++ /dev/null @@ -1,21 +0,0 @@ -import scala.collection.immutable.Set - -object ParseMe { - sealed abstract class Tree - case class Node(left: Tree, value: Int, right: Tree) extends Tree - case class Leaf() extends Tree - - - - def insert(v: Int, t: Tree): Tree = t match { - case Leaf() => Node(Leaf(), v, Leaf()) - case Node(left, v2, right) if v2 > v => Node(insert(v, left), v2, right) - case Node(left, v2, right) if v2 < v => Node(left, v2, insert(v, right)) - case n @ Node(left, v2, right) if v2 == v => n - } - - def emptySet() : Tree = { - Leaf() - } - -} diff --git a/src/purescala/Analysis.scala b/src/purescala/Analysis.scala index 1f9809ad9..e889f1f3f 100644 --- a/src/purescala/Analysis.scala +++ b/src/purescala/Analysis.scala @@ -33,4 +33,14 @@ object Analysis { BooleanLiteral(false) } } + + def flatten(expr: Expr) : (Expr,List[(Variable,Expr)]) = { + // Recursively flattens the expression. The head in the end + // should be the top-level original expression. + def fl(expr: Expr, lets: List[(Variable,Expr)]) : List[(Variable,Expr)] = expr match { + case _ => throw new Exception("ah ha !") + } + + } + } -- GitLab