Skip to content
Snippets Groups Projects
Commit ebcbe6cf authored by Ali Sinan Köksal's avatar Ali Sinan Köksal
Browse files

extracted "Typed" expressions of kind x: T

parent c7d7013e
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ object FirstClassConstraints { ...@@ -18,7 +18,7 @@ object FirstClassConstraints {
def main(args: Array[String]) : Unit = { def main(args: Array[String]) : Unit = {
val l = List(1, 3, 5, 7) val l = List(1, 3, 5, 7)
for (x <- (oneOf(l) minimizing ((x: Int) => -x)).findAll) for (x <- (oneOf(l) minimizing (- (_: Int))).findAll)
println("A solution: " + x) println("A solution: " + x)
val mapper : Term1[MyList,MyList] = (l : MyList) => l match { case MyCons(_, xs) => xs; case x => x } val mapper : Term1[MyList,MyList] = (l : MyList) => l match { case MyCons(_, xs) => xs; case x => x }
......
...@@ -628,6 +628,7 @@ trait CodeExtraction extends Extractors { ...@@ -628,6 +628,7 @@ trait CodeExtraction extends Extractors {
} }
case ExInt32Literal(v) => IntLiteral(v).setType(Int32Type) case ExInt32Literal(v) => IntLiteral(v).setType(Int32Type)
case ExBooleanLiteral(v) => BooleanLiteral(v).setType(BooleanType) case ExBooleanLiteral(v) => BooleanLiteral(v).setType(BooleanType)
case ExTyped(e,tpt) => rec(e).setType(scalaType2PureScala(unit,silent)(tpt.tpe))
case i @ ExIdentifier(sym,tpt) => varSubsts.get(sym) match { case i @ ExIdentifier(sym,tpt) => varSubsts.get(sym) match {
case Some(fun) => fun() case Some(fun) => fun()
case None => { case None => {
......
...@@ -210,6 +210,13 @@ trait Extractors { ...@@ -210,6 +210,13 @@ trait Extractors {
} }
} }
object ExTyped {
def unapply(tree : Typed): Option[(Tree,Tree)] = tree match {
case Typed(e,t) => Some((e,t))
case _ => None
}
}
object ExIntIdentifier { object ExIntIdentifier {
def unapply(tree: Ident): Option[String] = tree match { def unapply(tree: Ident): Option[String] = tree match {
case i: Ident if i.symbol.tpe == IntClass.tpe => Some(i.symbol.name.toString) case i: Ident if i.symbol.tpe == IntClass.tpe => Some(i.symbol.name.toString)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment