Skip to content
Snippets Groups Projects
Commit b19c478f authored by Mikaël Mayer's avatar Mikaël Mayer
Browse files

Added minimal string value

Added values for generating values.
parent 84e8cc8f
No related branches found
No related tags found
No related merge requests found
...@@ -32,12 +32,19 @@ class VanuatooDataGen(ctx: LeonContext, p: Program) extends DataGenerator { ...@@ -32,12 +32,19 @@ class VanuatooDataGen(ctx: LeonContext, p: Program) extends DataGenerator {
val booleans = (for (b <- Set(true, false)) yield { val booleans = (for (b <- Set(true, false)) yield {
b -> Constructor[Expr, TypeTree](List(), BooleanType, s => BooleanLiteral(b), ""+b) b -> Constructor[Expr, TypeTree](List(), BooleanType, s => BooleanLiteral(b), ""+b)
}).toMap }).toMap
val strings = (for (b <- Set("", "a", "Abcd")) yield {
b -> Constructor[Expr, TypeTree](List(), StringType, s => StringLiteral(b), b)
}).toMap
def intConstructor(i: Int) = ints(i) def intConstructor(i: Int) = ints(i)
def bigIntConstructor(i: Int) = bigInts(i) def bigIntConstructor(i: Int) = bigInts(i)
def boolConstructor(b: Boolean) = booleans(b) def boolConstructor(b: Boolean) = booleans(b)
def stringConstructor(s: String) = strings(s)
def cPattern(c: Constructor[Expr, TypeTree], args: Seq[VPattern[Expr, TypeTree]]) = { def cPattern(c: Constructor[Expr, TypeTree], args: Seq[VPattern[Expr, TypeTree]]) = {
ConstructorPattern[Expr, TypeTree](c, args) ConstructorPattern[Expr, TypeTree](c, args)
...@@ -166,6 +173,9 @@ class VanuatooDataGen(ctx: LeonContext, p: Program) extends DataGenerator { ...@@ -166,6 +173,9 @@ class VanuatooDataGen(ctx: LeonContext, p: Program) extends DataGenerator {
case (b: java.lang.Boolean, BooleanType) => case (b: java.lang.Boolean, BooleanType) =>
(cPattern(boolConstructor(b), List()), true) (cPattern(boolConstructor(b), List()), true)
case (b: java.lang.String, StringType) =>
(cPattern(stringConstructor(b), List()), true)
case (cc: codegen.runtime.CaseClass, ct: ClassType) => case (cc: codegen.runtime.CaseClass, ct: ClassType) =>
val r = cc.__getRead() val r = cc.__getRead()
......
...@@ -1100,6 +1100,7 @@ object ExprOps { ...@@ -1100,6 +1100,7 @@ object ExprOps {
/** Returns simplest value of a given type */ /** Returns simplest value of a given type */
def simplestValue(tpe: TypeTree) : Expr = tpe match { def simplestValue(tpe: TypeTree) : Expr = tpe match {
case StringType => StringLiteral("")
case Int32Type => IntLiteral(0) case Int32Type => IntLiteral(0)
case RealType => FractionalLiteral(0, 1) case RealType => FractionalLiteral(0, 1)
case IntegerType => InfiniteIntegerLiteral(0) case IntegerType => InfiniteIntegerLiteral(0)
...@@ -1735,6 +1736,10 @@ object ExprOps { ...@@ -1735,6 +1736,10 @@ object ExprOps {
case UnitType => case UnitType =>
// Anything matches () // Anything matches ()
ps.nonEmpty ps.nonEmpty
case StringType =>
// Can't possibly pattern match against all Strings one by one
ps exists (_.isInstanceOf[WildcardPattern])
case Int32Type => case Int32Type =>
// Can't possibly pattern match against all Ints one by one // Can't possibly pattern match against all Ints one by one
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment