diff --git a/sources/zweic/Analyzer.scala b/sources/zweic/Analyzer.scala index 642b5e6..ae9aa05 100755 --- a/sources/zweic/Analyzer.scala +++ b/sources/zweic/Analyzer.scala @@ -24,21 +24,21 @@ val emptyVarScope: VarScope = ListMap.Empty; // Analyze a program - def analyzeProgram(tree: Program): Unit = - tree match { - - case Program(classes, main) => - classes.foreach(analyzeClass); - analyzeExpr(emptyVarScope, main); - () - } + def analyzeProgram(tree: Program): Unit = tree match { + case Program(classes, main) => + classes.foreach(analyzeClass); + analyzeExpr(emptyVarScope, main); + () + } // Analyze a class - private def analyzeClass(tree: ClassDef): Unit = - tree match { + private def analyzeClass(tree: ClassDef): Unit = tree match { + case ClassDef(name, None, members) => + Console.println("hallo") case ClassDef(name, extend, members) => + Console.println("println") } - // ... � compl�ter ... + // Analyze a member private def analyzeMember(ownerClass: ClassSymbol, tree: Member): Unit = @@ -48,11 +48,10 @@ ownerClass.enterField(FieldSymbol(tree.pos, name, analyzeType(typ))) case MethodDef(name, args, rtype, expr) => lookupMethod(name) match { - case Some - ownerClass.enterMethod + case Some => + ownerClass.enterMethod } } - // ... � compl�ter ... // Analyze a statement private def analyzeStat(varScope: VarScope, tree: Stat): VarScope = diff --git a/sources/zweic/Type.scala b/sources/zweic/Type.scala index dfaea15..17eecc4 100755 --- a/sources/zweic/Type.scala +++ b/sources/zweic/Type.scala @@ -11,7 +11,9 @@ abstract class Type { override def toString(): String = this match { - // ... � compl�ter ... + case IClassType => "ClassType"; + case IIntType => "IntType" + case INullType => "NullType" case IBadType => "" } @@ -26,8 +28,15 @@ } def lub(that: Type): Option[Type] = Pair(this, that) match { - // ... � compl�ter ... - case _ => None + case Pair(IIntType, IIntType) => IIntType + case Pair(IClassType(x), INullType) => t1 + case Pair(INullType, IClassType(x)) => t2 + case Pair(IClassType(c1), IClassType(c2)) => + intersection(c1.superclasses, c2.superclasses) match { + case t :: ts => t + case List() => badLub(t1, t2) + } + case x => badLub(t1, t2) } }