@@ 50,6 50,12 @@ fn mono_expr(
// to know its monomorph. So what the hell do we do here?
// TODO: Worry about it later, I guess. Let's just deal
// with the simplest case of direct function calls.
+ let instance = tck.instances_rev.get(&heck.id).unwrap();
+ trace!(
+ "instantiating variable {} with type {}",
+ name,
+ tck.reconstruct(*instance).unwrap().get_name()
+ );
}
E::Var { name: *name }
}
@@ 83,7 89,12 @@ fn mono_expr(
// let instance = tck.instances_rev.get(&func.id).unwrap();
// let instantiated_type = tck.reconstruct(*instance).unwrap();
// trace!("instantiating type {}", instantiated_type.get_name());
- // functions_to_mono.push_back()
+
+ let instance = tck.instances_rev.get(&func.id).unwrap();
+ trace!(
+ "instantiating type {}",
+ tck.reconstruct(*instance).unwrap().get_name()
+ );
e
}
@@ 401,6 401,8 @@ pub struct Signature {
impl Signature {
/// Returns a lambda typedef representing the signature
+ ///
+ /// TODO: Type::from() ?
pub fn to_type(&self) -> Type {
let paramtypes = self.params.iter().map(|(_nm, ty)| ty.clone()).collect();
let typeparams = self.typeparams.iter().map(|nm| Type::named0(*nm)).collect();
@@ 430,3 432,26 @@ impl Signature {
format!("(|{}| {}) {}", typeargs, args, self.rettype.get_name())
}
}
+
+impl std::convert::TryFrom<&Type> for Signature {
+ type Error = ();
+ /// If this is a function type, return its signature.
+ /// Otherwise return None.
+ ///
+ /// TODO: Signature::try_from
+ fn try_from(_: &Type) -> Result<Signature, Self::Error> {
+ todo!()
+ // match t {
+ // Type::Func(params, rettype, typeparams) => {
+ // Hmm, we'd have to conjure up names for the type params
+ // let sig = Signature {
+ // params: params.clone(),
+ // rettype,
+ // typeparams,
+ // };
+ // Some(sig)
+ // }
+ // _ => None,
+ // }
+ }
+}