我关注HipsterTree.scala文件。使用此文件,如何在以下位置定义类型推理的案例:
val tipe : Expression => Type =
attr {
case IdnExpr(i) =>
entity(i) match {
case e : Applicable => UnknownType()
case e : TypedEntity => e.tipe
case _ => UnknownType()
}
case _ : IntExpr => IntType()
case _ : FloatExpr => FloatType()
case _ : BoolExpr => BoolType()
// FIXME: Add type inference cases for all other expression
// node types here.
case _ => UnknownType()
}
val expTipe : Expression => Set[Type] =
attr {
// Expected types of dimension expressions.
case tree.parent(_ : BoundedDim) => Set(IntType())
case tree.parent(_ : CyclicDim) => Set(IntType())
case tree.parent.pair(n, ConstantDecl(t,_,_)) =>
compatTypes(t)
case tree.parent.pair(n, VarDecl(t,_,_)) =>
compatTypes(t)
// FIXME: Add cases to compute the set of expected types for an
// expression node by inspecting the type of its parent.
// with the computed expression type.
case n => compatTypes(tipe(n))
}
我很感激能帮助我添加FIXME
指示