Skip to content
Snippets Groups Projects
Commit ce7276db authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

Make vanuatoo more resilient to non-patternable Exprs

parent ff8c29a4
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,8 @@ import utils._ ...@@ -10,6 +10,8 @@ import utils._
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean
trait DataGenerator extends Interruptible { trait DataGenerator extends Interruptible {
implicit val debugSection = DebugSectionDataGen
def generateFor(ins: Seq[Identifier], satisfying: Expr, maxValid: Int, maxEnumerated: Int): Iterator[Seq[Expr]]; def generateFor(ins: Seq[Identifier], satisfying: Expr, maxValid: Int, maxEnumerated: Int): Iterator[Seq[Expr]];
protected val interrupted: AtomicBoolean = new AtomicBoolean(false) protected val interrupted: AtomicBoolean = new AtomicBoolean(false)
......
...@@ -109,6 +109,7 @@ class VanuatooDataGen(ctx: LeonContext, p: Program) extends DataGenerator { ...@@ -109,6 +109,7 @@ class VanuatooDataGen(ctx: LeonContext, p: Program) extends DataGenerator {
Nil Nil
} }
// Returns the pattern and whether it is fully precise
private def valueToPattern(v: AnyRef, expType: TypeTree): (VPattern[Expr, TypeTree], Boolean) = (v, expType) match { private def valueToPattern(v: AnyRef, expType: TypeTree): (VPattern[Expr, TypeTree], Boolean) = (v, expType) match {
case (i: Integer, Int32Type) => case (i: Integer, Int32Type) =>
(cPattern(intConstructor(i), List()), true) (cPattern(intConstructor(i), List()), true)
...@@ -143,7 +144,8 @@ class VanuatooDataGen(ctx: LeonContext, p: Program) extends DataGenerator { ...@@ -143,7 +144,8 @@ class VanuatooDataGen(ctx: LeonContext, p: Program) extends DataGenerator {
(ConstructorPattern(c, elems.map(_._1)), elems.forall(_._2)) (ConstructorPattern(c, elems.map(_._1)), elems.forall(_._2))
case _ => case _ =>
sys.error("Could not retreive type for :"+cc.getClass.getName) ctx.reporter.error("Could not retreive type for :"+cc.getClass.getName)
(AnyPattern[Expr, TypeTree](), false)
} }
case (t: codegen.runtime.Tuple, tt @ TupleType(parts)) => case (t: codegen.runtime.Tuple, tt @ TupleType(parts)) =>
...@@ -165,7 +167,8 @@ class VanuatooDataGen(ctx: LeonContext, p: Program) extends DataGenerator { ...@@ -165,7 +167,8 @@ class VanuatooDataGen(ctx: LeonContext, p: Program) extends DataGenerator {
case (gv: GenericValue, t: TypeParameter) => case (gv: GenericValue, t: TypeParameter) =>
(cPattern(getConstructors(t)(gv.id-1), List()), true) (cPattern(getConstructors(t)(gv.id-1), List()), true)
case (v, t) => case (v, t) =>
sys.error("Unsupported value, can't paternify : "+v+" ("+v.getClass+") : "+t) ctx.reporter.debug("Unsupported value, can't paternify : "+v+" ("+v.getClass+") : "+t)
(AnyPattern[Expr, TypeTree](), false)
} }
type InstrumentedResult = (EvaluationResults.Result, Option[vanuatoo.Pattern[Expr, TypeTree]]) type InstrumentedResult = (EvaluationResults.Result, Option[vanuatoo.Pattern[Expr, TypeTree]])
......
...@@ -16,6 +16,7 @@ case object DebugSectionVerification extends DebugSection("verification", 1 << 4 ...@@ -16,6 +16,7 @@ case object DebugSectionVerification extends DebugSection("verification", 1 << 4
case object DebugSectionTermination extends DebugSection("termination", 1 << 5) case object DebugSectionTermination extends DebugSection("termination", 1 << 5)
case object DebugSectionTrees extends DebugSection("trees", 1 << 6) case object DebugSectionTrees extends DebugSection("trees", 1 << 6)
case object DebugSectionPositions extends DebugSection("positions", 1 << 7) case object DebugSectionPositions extends DebugSection("positions", 1 << 7)
case object DebugSectionDataGen extends DebugSection("datagen", 1 << 8)
object DebugSections { object DebugSections {
val all = Set[DebugSection]( val all = Set[DebugSection](
...@@ -26,6 +27,7 @@ object DebugSections { ...@@ -26,6 +27,7 @@ object DebugSections {
DebugSectionVerification, DebugSectionVerification,
DebugSectionTermination, DebugSectionTermination,
DebugSectionTrees, DebugSectionTrees,
DebugSectionPositions DebugSectionPositions,
DebugSectionDataGen
) )
} }
...@@ -35,7 +35,6 @@ class VerificationCondition(val condition: Expr, val funDef: FunDef, val kind: V ...@@ -35,7 +35,6 @@ class VerificationCondition(val condition: Expr, val funDef: FunDef, val kind: V
case Some(s) => s.name case Some(s) => s.name
case None => "" case None => ""
} }
} }
object VCKind extends Enumeration { object VCKind extends Enumeration {
......
...@@ -6,12 +6,8 @@ package verification ...@@ -6,12 +6,8 @@ package verification
import purescala.Definitions.FunDef import purescala.Definitions.FunDef
class VerificationReport(val fvcs: Map[FunDef, List[VerificationCondition]]) { class VerificationReport(val fvcs: Map[FunDef, List[VerificationCondition]]) {
val conditions : Seq[VerificationCondition] = fvcs.flatMap(_._2).toSeq.sortWith { import scala.math.Ordering.Implicits._
(vc1,vc2) => val conditions : Seq[VerificationCondition] = fvcs.flatMap(_._2).toSeq.sortBy(vc => (vc.funDef.id.name, vc.kind))
val id1 = vc1.funDef.id.name
val id2 = vc2.funDef.id.name
if(id1 != id2) id1 < id2 else vc1.getPos < vc2.getPos
}
lazy val totalConditions : Int = conditions.size lazy val totalConditions : Int = conditions.size
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment