cl-typeck: Turn ref into a linked list.
This should be fine, since the only thing you can do with a ref is dereference it.
This commit is contained in:
parent
03a4e76292
commit
4096442f75
@ -21,10 +21,8 @@ impl fmt::Display for Entry<'_, '_> {
|
||||
TypeKind::Instance(id) => write!(f, "{}", self.with_id(*id)),
|
||||
TypeKind::Intrinsic(kind) => write!(f, "{kind}"),
|
||||
TypeKind::Adt(adt) => write_adt(adt, self, f),
|
||||
&TypeKind::Ref(cnt, id) => {
|
||||
for _ in 0..cnt {
|
||||
&TypeKind::Ref(id) => {
|
||||
f.write_str("&")?;
|
||||
}
|
||||
let h_id = self.with_id(id);
|
||||
write_name_or(h_id, f)
|
||||
}
|
||||
|
@ -97,8 +97,12 @@ impl TypeExpression for TyTuple {
|
||||
impl TypeExpression for TyRef {
|
||||
fn evaluate(&self, table: &mut Table, node: Handle) -> Result<Handle, Error> {
|
||||
let Self { mutable: _, count, to } = self;
|
||||
let kind = TypeKind::Ref(*count, to.evaluate(table, node)?);
|
||||
Ok(table.anon_type(kind))
|
||||
let mut t = to.evaluate(table, node)?;
|
||||
for _ in 0..*count {
|
||||
let kind = TypeKind::Ref(t);
|
||||
t = table.anon_type(kind)
|
||||
}
|
||||
Ok(t)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ pub enum TypeKind {
|
||||
/// A user-defined aromatic data type
|
||||
Adt(Adt),
|
||||
/// A reference to an already-defined type: &T
|
||||
Ref(u16, Handle),
|
||||
Ref(Handle),
|
||||
/// A contiguous view of dynamically sized memory
|
||||
Slice(Handle),
|
||||
/// A contiguous view of statically sized memory
|
||||
|
@ -11,12 +11,7 @@ impl Display for TypeKind {
|
||||
TypeKind::Instance(def) => write!(f, "alias to #{def}"),
|
||||
TypeKind::Intrinsic(i) => i.fmt(f),
|
||||
TypeKind::Adt(a) => a.fmt(f),
|
||||
TypeKind::Ref(cnt, def) => {
|
||||
for _ in 0..*cnt {
|
||||
f.write_str("&")?;
|
||||
}
|
||||
def.fmt(f)
|
||||
}
|
||||
TypeKind::Ref(def) => write!(f, "&{def}"),
|
||||
TypeKind::Slice(def) => write!(f, "slice [#{def}]"),
|
||||
TypeKind::Array(def, size) => write!(f, "array [#{def}; {size}]"),
|
||||
TypeKind::Tuple(defs) => {
|
||||
|
Loading…
Reference in New Issue
Block a user