diff --git a/ParseMe.scala b/ParseMe.scala index c7f6dda03b35fd1094650971073bc07c9a321b27..62be61d7543aabe1e040e708dda1bf12b88c4e34 100644 --- a/ParseMe.scala +++ b/ParseMe.scala @@ -2,6 +2,10 @@ import scala.collection.immutable.Set object ParseMe { + sealed abstract class Tree + case class Node(left: Tree, value: Int, right: Tree) extends Tree + case class Leaf() extends Tree + def fromSet(i: Set[Set[Boolean]]) : Int = { 5 } diff --git a/src/funcheck/CodeExtraction.scala b/src/funcheck/CodeExtraction.scala index 5cba1395e4eb27ae8c711e7a4dde9c77de17f673..fa6752e090324637ac5c730c976439c67edcd9b3 100644 --- a/src/funcheck/CodeExtraction.scala +++ b/src/funcheck/CodeExtraction.scala @@ -68,22 +68,24 @@ trait CodeExtraction extends Extractors { var objectDefs: List[ObjectDef] = Nil var funDefs: List[FunDef] = Nil - tmpl.body.foreach(tree => { - //println("[[[ " + tree + "]]]\n"); - tree match { + tmpl.body.foreach( + _ match { + case ExCaseClassSyntheticJunk() => ; case ExObjectDef(o2, t2) => { objectDefs = extractObjectDef(o2, t2) :: objectDefs } - case ExAbstractClass(o2) => ; + case ExAbstractClass(o2) => println("That seems to be an abstract class: [[" + o2 + "]]") + case ExCaseClass(o2) => println(o2) case ExConstructorDef() => ; case ExMainFunctionDef() => ; case ExFunctionDef(n,p,t,b) => { funDefs = extractFunDef(n,p,t,b) :: funDefs } - case _ => ; - }}) + case tree => { println("Something else: "); println("[[[ " + tree + "]]]\n") } + }) // val theSym = new purescala.Symbols.ObjectSymbol(name, classSyms.reverse, objectSyms.reverse) // we register the tree associated to the symbol to be able to fill in // the rest later // symbolDefMap(theSym) = tmpl val theDef = new ObjectDef(name, objectDefs.reverse ::: classDefs.reverse ::: funDefs.reverse, Nil) + theDef } diff --git a/src/funcheck/Extractors.scala b/src/funcheck/Extractors.scala index ae48a4976db7b7f70a1dc9d26c561620fd19bde9..d6041e3c7b06b0f4f929da5dc065e3e10981b79c 100644 --- a/src/funcheck/Extractors.scala +++ b/src/funcheck/Extractors.scala @@ -54,7 +54,7 @@ trait Extractors { * visibility. Does not match on the automatically generated companion * objects of case classes (or any synthetic class). */ def unapply(cd: ClassDef): Option[(String,Template)] = cd match { - case ClassDef(_, name, tparams, impl) if (cd.symbol.isModuleClass && tparams.isEmpty && !cd.symbol.hasFlag(symtab.Flags.SYNTHETIC)) => { + case ClassDef(_, name, tparams, impl) if (cd.symbol.isModuleClass && tparams.isEmpty && !cd.symbol.isSynthetic) => { Some((name.toString, impl)) } case _ => None @@ -66,16 +66,40 @@ trait Extractors { * constrctor args (in the case of a class), no implementation details, * no abstract members. */ def unapply(cd: ClassDef): Option[(String)] = cd match { - case ClassDef(_, name, tparams, impl) if (cd.symbol.isTrait && tparams.isEmpty && impl.body.length == 2) => { - println(name + " seems to be a cool trait") - Some(name.toString) - } + // trait + // case ClassDef(_, name, tparams, impl) if (cd.symbol.isTrait && tparams.isEmpty && impl.body.isEmpty) => Some(name.toString) + + // abstract class + case ClassDef(_, name, tparams, impl) if (cd.symbol.isAbstractClass && tparams.isEmpty && impl.body.size == 1) => Some(name.toString) + case _ => None } } object ExCaseClass { + def unapply(cd: ClassDef): Option[(String)] = cd match { + case ClassDef(_, name, tparams, impl) if (cd.symbol.isCase && !cd.symbol.isAbstractClass && tparams.isEmpty && impl.body.size >= 8) => { + println("I think I have something here") + println(impl.body.size) + cd.symbol.tpe match { + case ClassInfoType(prts, decls, cls) => { + println("## " + prts) + println("## " + decls) + println("## " + cls) + } + case _ => ; + } + Some(name.toString) + } + case _ => None + } + } + object ExCaseClassSyntheticJunk { + def unapply(cd: ClassDef): Boolean = cd match { + case ClassDef(_, _, _, _) if (cd.symbol.isSynthetic && cd.symbol.isFinal) => true + case _ => false + } } object ExConstructorDef {