diff --git a/build.xml b/build.xml index c64f64198693cefe58098cb11b79eeafbe074040..36a4dbc404c1892df434c4ec60151e729dcd8d8e 100644 --- a/build.xml +++ b/build.xml @@ -79,7 +79,7 @@ --> <!-- phases definitions --> - <target name="compile-funcheck-lib" description="compile the FunCheck library (used for specification)"> + <!-- <target name="compile-funcheck-lib" description="compile the FunCheck library (used for specification)"> <mkdir dir="${build.funcheck.lib.dir}" /> <scalac srcdir="${sources.dir}" destdir="${build.funcheck.lib.dir}" force="changed" addparams="${scalac.default.params}"> <classpath> @@ -88,6 +88,7 @@ <include name="funcheck/lib/**/*.scala" /> </scalac> </target> + --> <!-- <target name="compile-scalac-lib-extension" description="compile Scala library extension for immutable Multiset"> @@ -99,7 +100,8 @@ </target> --> - <target name="compile" depends="compile-funcheck-lib" description="compile the FunCheck plugin"> + <!-- <target name="compile" depends="compile-funcheck-lib" description="compile the FunCheck plugin"> --> + <target name="compile" description="compile the FunCheck plugin"> <mkdir dir="${build.plugin.funcheck.dir}" /> <scalac srcdir="${sources.dir}" destdir="${build.plugin.funcheck.dir}" force="changed" addparams="${scalac.default.params}"> <classpath> diff --git a/src/funcheck/CodeExtraction.scala b/src/funcheck/CodeExtraction.scala index fa6752e090324637ac5c730c976439c67edcd9b3..9dca1024a59f4d1fa26bcfadc0500e260492ab4b 100644 --- a/src/funcheck/CodeExtraction.scala +++ b/src/funcheck/CodeExtraction.scala @@ -68,17 +68,36 @@ trait CodeExtraction extends Extractors { var objectDefs: List[ObjectDef] = Nil var funDefs: List[FunDef] = Nil + val scalaClassSyms: scala.collection.mutable.Map[Symbol,Identifier] = + scala.collection.mutable.Map.empty[Symbol,Identifier] + + // we need the new type definitions before we can do anything... tmpl.body.foreach( _ match { - case ExCaseClassSyntheticJunk() => ; - case ExObjectDef(o2, t2) => { objectDefs = extractObjectDef(o2, t2) :: objectDefs } - 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 tree => { println("Something else: "); println("[[[ " + tree + "]]]\n") } - }) + case ExAbstractClass(o2, sym) => { + scalaClassSyms += (sym -> o2) + } + case ExCaseClass(o2, sym) => { + scalaClassSyms += (sym -> o2) + } + case _ => ; + } + ) + + println(scalaClassSyms) + + tmpl.body.foreach( + _ match { + case ExCaseClassSyntheticJunk() => ; + case ExObjectDef(o2, t2) => { objectDefs = extractObjectDef(o2, t2) :: objectDefs } + case ExAbstractClass(o2,sym) => ; //println("That seems to be an abstract class: [[" + o2 + "]]") + case ExCaseClass(o2,sym) => ; //println(o2) + case ExConstructorDef() => ; + case ExMainFunctionDef() => ; + case ExFunctionDef(n,p,t,b) => { funDefs = extractFunDef(n,p,t,b) :: funDefs } + 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 diff --git a/src/funcheck/Extractors.scala b/src/funcheck/Extractors.scala index d6041e3c7b06b0f4f929da5dc065e3e10981b79c..6d17be38a698387741a14c460eedcb447a6d8524 100644 --- a/src/funcheck/Extractors.scala +++ b/src/funcheck/Extractors.scala @@ -65,31 +65,34 @@ trait Extractors { /** Matches an abstract class or a trait with no type parameters, no * constrctor args (in the case of a class), no implementation details, * no abstract members. */ - def unapply(cd: ClassDef): Option[(String)] = cd match { - // trait - // case ClassDef(_, name, tparams, impl) if (cd.symbol.isTrait && tparams.isEmpty && impl.body.isEmpty) => Some(name.toString) - + def unapply(cd: ClassDef): Option[(String,Symbol)] = cd match { // abstract class - case ClassDef(_, name, tparams, impl) if (cd.symbol.isAbstractClass && tparams.isEmpty && impl.body.size == 1) => Some(name.toString) + case ClassDef(_, name, tparams, impl) if (cd.symbol.isAbstractClass && tparams.isEmpty && impl.body.size == 1) => Some((name.toString, cd.symbol)) case _ => None } } object ExCaseClass { - def unapply(cd: ClassDef): Option[(String)] = cd match { + def unapply(cd: ClassDef): Option[(String,Symbol)] = 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) + // println("I think I have something here") + // cd.symbol.tpe match { + // case TypeRef(_, sym, Nil) => { + // println("It's a typeref, of course") + // println(sym.tpe) + // println(debugString(sym.tpe)) + // println(sym.tpe.baseTypeSeq) + // println(sym.tpe.baseClasses) + // } + // case ClassInfoType(prts, decls, cls) => { + // println("## " + prts) + // println("## " + decls) + // println("## " + cls) + // } + // case _ => ; + // } + Some((name.toString, cd.symbol)) } case _ => None } diff --git a/src/purescala/Definitions.scala b/src/purescala/Definitions.scala index da78954e43d3e29a1f063e4c61b239a254472a04..6dd35e86297e2427daa4dd8ffccba9d316d68c3d 100644 --- a/src/purescala/Definitions.scala +++ b/src/purescala/Definitions.scala @@ -78,7 +78,7 @@ object Definitions { sealed trait ClassTypeDef extends Definition { val id: Identifier val parent: Option[AbstractClassDef] - val fields: VarDecls + // val fields: VarDecls } /** Will be used at some point as a common ground for case classes (which @@ -86,10 +86,14 @@ object Definitions { sealed trait ExtractorTypeDef /** Abstract classes. */ - case class AbstractClassDef(id: Identifier, parent: Option[AbstractClassDef], fields: VarDecls) extends ClassTypeDef + class AbstractClassDef(val id: Identifier, val parent: Option[AbstractClassDef]) extends ClassTypeDef { + var fields: VarDecls = Nil + } /** Case classes. */ - case class CaseClassDef(id: Identifier, parent: Option[AbstractClassDef], fields: VarDecls) extends ClassTypeDef with ExtractorTypeDef + class CaseClassDef(val id: Identifier, val parent: Option[AbstractClassDef]) extends ClassTypeDef with ExtractorTypeDef { + var fields: VarDecls = Nil + } /** "Regular" classes */ case class ClassDef(id: Identifier, parent: Option[AbstractClassDef], fields: VarDecls) extends ClassTypeDef