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

stuff

parent 540a61da
No related branches found
No related tags found
No related merge requests found
......@@ -83,12 +83,15 @@ trait CodeExtraction extends Extractors {
scalaClassSyms += (sym -> o2)
scalaClassNames += o2
}
case ExCaseClass(o2, sym) => {
case ExCaseClass(o2, sym, tpl) => {
if(scalaClassNames.contains(o2)) {
unit.error(t.pos, "A class with the same name already exists.")
}
scalaClassSyms += (sym -> o2)
scalaClassNames += o2
// println("***")
// println(tpl)
// println("***")
}
case _ => ;
}
......@@ -107,6 +110,28 @@ trait CodeExtraction extends Extractors {
}
})
classesToClasses.foreach(p => {
println(p._1)
val superC: List[ClassTypeDef] = p._1.tpe.baseClasses.filter(bcs => scalaClassSyms.exists(pp => pp._1 == bcs) && bcs != p._1).map(s => classesToClasses(s)).toList
val superAC: List[AbstractClassDef] = superC.map(c => {
if(!c.isInstanceOf[AbstractClassDef]) {
unit.error(p._1.pos, "Class is inheriting from non-abstract class.")
null
} else {
c.asInstanceOf[AbstractClassDef]
}
}).filter(_ != null)
if(superAC.length > 1) {
unit.error(p._1.pos, "Multiple inheritance.")
}
if(superAC.length == 1) {
p._2.parent = Some(superAC.head)
}
})
// TODO
// resolve all inheritance links (look at
// add all fields to case classes
......@@ -118,7 +143,7 @@ trait CodeExtraction extends Extractors {
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 ExCaseClass(_,_,_) => ; //println(o2)
case ExConstructorDef() => ;
case ExMainFunctionDef() => ;
case ExFunctionDef(n,p,t,b) => { funDefs = extractFunDef(n,p,t,b) :: funDefs }
......
......@@ -74,25 +74,10 @@ trait Extractors {
}
object ExCaseClass {
def unapply(cd: ClassDef): Option[(String,Symbol)] = cd match {
def unapply(cd: ClassDef): Option[(String,Symbol,Tree)] = 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")
// 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))
Some((name.toString, cd.symbol, impl))
}
case _ => None
}
......
......@@ -148,7 +148,7 @@ object PrettyPrinter {
ind(nsb)
nsb.append("sealed abstract class ")
nsb.append(id)
parent.foreach(p => nsb.append("extends " + p.id + " "))
parent.foreach(p => nsb.append(" extends " + p.id))
nsb
}
......
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