Skip to content
Snippets Groups Projects
Commit 8efcbafa authored by Philippe Suter's avatar Philippe Suter
Browse files

It's night and a programmer wonders

How one can make sense of these pointers
 It would be quite pleasant
 To find the class parent
Yet so far he gets only errors.

parent d072e872
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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
......
......@@ -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
}
......
......@@ -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
......
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