diff --git a/src/main/scala/hb/dhbw/FiniteClosure.scala b/src/main/scala/hb/dhbw/FiniteClosure.scala index daaa3e4..519a6bb 100644 --- a/src/main/scala/hb/dhbw/FiniteClosure.scala +++ b/src/main/scala/hb/dhbw/FiniteClosure.scala @@ -1,9 +1,13 @@ package hb.dhbw +trait FJNamedType{ + def name: String + def params: List[FJNamedType] +} -class FiniteClosure(val extendsRelations : Set[(UnifyRefType, UnifyRefType)]){ +class FiniteClosure(val extendsRelations : Set[(FJNamedType, FJNamedType)]){ - private def calculateSupertypes(of: UnifyRefType) ={ + private def calculateSupertypes(of: FJNamedType) ={ var rel = Set((of, of)) var size = rel.size do { @@ -12,25 +16,25 @@ class FiniteClosure(val extendsRelations : Set[(UnifyRefType, UnifyRefType)]){ }while(rel.size > size) rel.map(_._2) } - private def reflexiveTypes(of: Set[(UnifyRefType, UnifyRefType)]) ={ + private def reflexiveTypes(of: Set[(FJNamedType, FJNamedType)]) ={ val ref = Set.newBuilder[(UnifyRefType, UnifyRefType)] ref ++= of.map(pair => (pair._1, pair._1)) ref ++= of.map(pair => (pair._2, pair._2)) ref.result() } - private def transitiveTypes(of: Set[(UnifyRefType, UnifyRefType)]) ={ + private def transitiveTypes(of: Set[(FJNamedType, FJNamedType)]) ={ val ref = Set.newBuilder[(UnifyRefType, UnifyRefType)] ref ++= of.flatMap(pair => of.filter(p => p._1.eq(pair._2))) ref.result() } - private def superClassTypes(of: UnifyRefType) = { + private def superClassTypes(of: FJNamedType) = { val extendsRelation = extendsRelations.filter(pair => pair._1.name.equals(of.name)) extendsRelation.map(p => { val paramMap = p._1.params.zip(of.params).toMap (of,UnifyRefType(p._2.name, p._2.params.map(paramMap))) }) } - private def superClassTypes(of: Set[(UnifyRefType, UnifyRefType)]) : Set[(UnifyRefType, UnifyRefType)] ={ + private def superClassTypes(of: Set[(FJNamedType, FJNamedType)]) : Set[(FJNamedType, FJNamedType)] ={ val sClass = Set.newBuilder[(UnifyRefType, UnifyRefType)] sClass ++= of.flatMap(pair => Set(pair._2, pair._1)).flatMap(t => superClassTypes(t)) sClass.result()