Skip to content
Snippets Groups Projects
Commit a6ab44ad authored by Marco Antognini's avatar Marco Antognini Committed by Etienne Kneuss
Browse files

Add support for case class

parent bd5ec205
No related branches found
No related tags found
No related merge requests found
......@@ -367,6 +367,15 @@ class CConverter(val ctx: LeonContext, val prog: Program) {
argsFs.bodies ~~ CAST.StructInit(args, struct)
case CaseClassSelector(_, x1, fieldId) =>
val struct = convertToStruct(x1.getType)
val x2 = convertToStmt(x1)
val fs = normaliseExecution((x2, struct) :: Nil)
val x = fs.values.head
fs.bodies ~~ CAST.AccessField(x, convertToId(fieldId))
case LessThan(lhs, rhs) => buildBinOp(lhs, "<", rhs)
case GreaterThan(lhs, rhs) => buildBinOp(lhs, ">", rhs)
case LessEquals(lhs, rhs) => buildBinOp(lhs, "<=", rhs)
......
import leon.lang._
object CaseClass {
case class Color(r: Int, g: Int, b: Int)
def red = Color(0, 255, 0)
def cyan = Color(0, 255, 255)
def sub(c: Color, d: Color) = Color(c.r - d.r, c.g - d.g, c.b - d.b)
def main = {
val c = red
val d = cyan
val z = sub(c, d).g
z
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment