rendered paste body private def extendScope(members: List[Member], fs: FieldScope, ms: MethodScope): Unit = members match {
case mem :: mems => mem match {
case Field(fieldName, tipe, expr) => {
fs.get(fieldName) match {
case Some(FieldSymbol(dt: DataType)) => Report.error(mem.pos, "Field " + fieldName + " is already defined")
case None => {
fs + ((fieldName, FieldSymbol(tipe)))
extendScope(mems, fs, ms)
}
}
}
case Method(methodName, arguments, returnType, expr) => {
def addArgs(args: List[(String, DataType)], accu: List[DataType]): Unit = args match {
case arg :: nextArgs => addArgs(nextArgs, accu ::: List(arg._2))
case Nil => ms + ((methodName, MethodSymbol(accu, returnType)))
}
ms.get(methodName) match {
case Some(MethodSymbol(listDt: List[DataType], dt: DataType)) => Report.error(mem.pos, "Method " + methodName + " is already defined")
case None => {
addArgs(arguments, Nil)
extendScope(mems, fs, ms)
}
}
}
}
case Nil => //exit
}