diff --git a/src/main/scala/leon/frontends/scalac/ASTExtractors.scala b/src/main/scala/leon/frontends/scalac/ASTExtractors.scala index e4a84967021a60d73254b40e360c3fc0aa2457f8..defcdb45380a151c7ecd1268f3857541a708b2ce 100644 --- a/src/main/scala/leon/frontends/scalac/ASTExtractors.scala +++ b/src/main/scala/leon/frontends/scalac/ASTExtractors.scala @@ -191,13 +191,6 @@ trait ASTExtractors { } object ExCaseClass { - /* -<<<<<<< HEAD - def unapply(cd: ClassDef): Option[(String,Symbol,Seq[(String, ValDef)], Template)] = cd match { -======= - def unapply(cd: ClassDef): Option[(String,Symbol,Seq[(Symbol,Tree)], Template)] = cd match { ->>>>>>> Field Extraction & handling -*/ def unapply(cd: ClassDef): Option[(String,Symbol,Seq[(Symbol,ValDef)], Template)] = cd match { case ClassDef(_, name, tparams, impl) if (cd.symbol.isCase && !cd.symbol.isAbstractClass && impl.body.size >= 8) => { val constructor: DefDef = impl.children.find(child => child match { @@ -205,13 +198,6 @@ trait ASTExtractors { case _ => false }).get.asInstanceOf[DefDef] -/* -<<<<<<< HEAD - val args = constructor.vparamss.flatten.map(vd => (vd.name.toString, vd)) -======= - val args = constructor.vparamss.flatten.map(vd => ( vd.symbol, vd.tpt)) ->>>>>>> Field Extraction & handling -*/ val args = constructor.vparamss.flatten.map(vd => ( vd.symbol, vd)) Some((name.toString, cd.symbol, args, impl)) } @@ -629,41 +615,6 @@ trait ASTExtractors { case _ => None } } - - object ExNotEquals { - def unapply(tree: Apply): Option[(Tree,Tree)] = tree match { - case Apply(Select(lhs, n), List(rhs)) if (n == nme.NE) => Some((lhs,rhs)) - case _ => None - } - } - - object ExLessThan { - def unapply(tree: Apply): Option[(Tree,Tree)] = tree match { - case Apply(Select(lhs, n), List(rhs)) if (n == nme.LT && hasIntType(lhs)) => Some((lhs,rhs)) - case _ => None - } - } - - object ExLessEqThan { - def unapply(tree: Apply): Option[(Tree,Tree)] = tree match { - case Apply(Select(lhs, n), List(rhs)) if (n == nme.LE && hasIntType(lhs)) => Some((lhs,rhs)) - case _ => None - } - } - - object ExGreaterThan { - def unapply(tree: Apply): Option[(Tree,Tree)] = tree match { - case Apply(Select(lhs, n), List(rhs)) if (n == nme.GT && hasIntType(lhs)) => Some((lhs,rhs)) - case _ => None - } - } - - object ExGreaterEqThan { - def unapply(tree: Apply): Option[(Tree,Tree)] = tree match { - case Apply(Select(lhs, n), List(rhs)) if (n == nme.GE && hasIntType(lhs)) => Some((lhs,rhs)) - case _ => None - } - } object ExUMinus { def unapply(tree: Select): Option[Tree] = tree match { @@ -672,42 +623,6 @@ trait ASTExtractors { } } - object ExPlus { - def unapply(tree: Apply): Option[(Tree,Tree)] = tree match { - case Apply(Select(lhs, n), List(rhs)) if (n == nme.ADD && hasIntType(lhs)) => - Some((lhs,rhs)) - case _ => None - } - } - - object ExMinus { - def unapply(tree: Apply): Option[(Tree,Tree)] = tree match { - case Apply(Select(lhs, n), List(rhs)) if (n == nme.SUB && hasIntType(lhs)) => Some((lhs,rhs)) - case _ => None - } - } - - object ExTimes { - def unapply(tree: Apply): Option[(Tree,Tree)] = tree match { - case Apply(Select(lhs, n), List(rhs)) if (n == nme.MUL && hasIntType(lhs)) => Some((lhs,rhs)) - case _ => None - } - } - - object ExDiv { - def unapply(tree: Apply): Option[(Tree,Tree)] = tree match { - case Apply(Select(lhs, n), List(rhs)) if (n == nme.DIV && hasIntType(lhs)) => Some((lhs,rhs)) - case _ => None - } - } - - object ExMod { - def unapply(tree: Apply): Option[(Tree,Tree)] = tree match { - case Apply(Select(lhs, n), List(rhs)) if (n == nme.MOD && hasIntType(lhs)) => Some((lhs,rhs)) - case _ => None - } - } - object ExPatternMatching { def unapply(tree: Match): Option[(Tree,List[CaseDef])] = if(tree != null) Some((tree.selector, tree.cases)) else None diff --git a/src/main/scala/leon/frontends/scalac/CodeExtraction.scala b/src/main/scala/leon/frontends/scalac/CodeExtraction.scala index 0b49d28fcffbd6eb073bc9cb209de02e3d74326f..e2778a3596058fb26906adc6948f33b026ebd1c5 100644 --- a/src/main/scala/leon/frontends/scalac/CodeExtraction.scala +++ b/src/main/scala/leon/frontends/scalac/CodeExtraction.scala @@ -1125,16 +1125,9 @@ trait CodeExtraction extends ASTExtractors { } - case ExAnd(l, r) => And(extractTree(l), extractTree(r)) - case ExOr(l, r) => Or(extractTree(l), extractTree(r)) case ExNot(e) => Not(extractTree(e)) case ExUMinus(e) => UMinus(extractTree(e)) - case ExMod(l, r) => Modulo(extractTree(l), extractTree(r)) - case ExNotEquals(l, r) => Not(Equals(extractTree(l), extractTree(r))) - case ExGreaterThan(l, r) => GreaterThan(extractTree(l), extractTree(r)) - case ExGreaterEqThan(l, r) => GreaterEquals(extractTree(l), extractTree(r)) - case ExLessThan(l, r) => LessThan(extractTree(l), extractTree(r)) - case ExLessEqThan(l, r) => LessEquals(extractTree(l), extractTree(r)) + case ExEquals(l, r) => val rl = extractTree(l) val rr = extractTree(r) @@ -1298,6 +1291,9 @@ trait CodeExtraction extends ASTExtractors { CaseClassSelector(cct, rec, fieldID) + case (a1, "!=", List(a2)) => + Not(Equals(a1, a2)) + // Int methods case (IsTyped(a1, Int32Type), "+", List(IsTyped(a2, Int32Type))) => Plus(a1, a2) @@ -1308,9 +1304,34 @@ trait CodeExtraction extends ASTExtractors { case (IsTyped(a1, Int32Type), "*", List(IsTyped(a2, Int32Type))) => Times(a1, a2) + case (IsTyped(a1, Int32Type), "%", List(IsTyped(a2, Int32Type))) => + Modulo(a1, a2) + case (IsTyped(a1, Int32Type), "/", List(IsTyped(a2, Int32Type))) => Division(a1, a2) + case (IsTyped(a1, Int32Type), ">", List(IsTyped(a2, Int32Type))) => + GreaterThan(a1, a2) + + case (IsTyped(a1, Int32Type), ">=", List(IsTyped(a2, Int32Type))) => + GreaterEquals(a1, a2) + + case (IsTyped(a1, Int32Type), "<", List(IsTyped(a2, Int32Type))) => + LessThan(a1, a2) + + case (IsTyped(a1, Int32Type), "<=", List(IsTyped(a2, Int32Type))) => + LessEquals(a1, a2) + + case (IsTyped(a1, Int32Type), "<=", List(IsTyped(a2, Int32Type))) => + LessEquals(a1, a2) + + // Boolean methods + case (IsTyped(a1, BooleanType), "&&", List(IsTyped(a2, BooleanType))) => + And(a1, a2) + + case (IsTyped(a1, BooleanType), "||", List(IsTyped(a2, BooleanType))) => + Or(a1, a2) + // Set methods case (IsTyped(a1, SetType(b1)), "min", Nil) => SetMin(a1).setType(b1)