cl-typeck: With super
semantics redone, search within self for items
This commit is contained in:
parent
f5f905cd70
commit
4228324ab3
@ -65,7 +65,6 @@ fn cat_alias(table: &mut Table, node: Handle, a: &Alias) -> CatResult<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn cat_struct(table: &mut Table, node: Handle, s: &Struct) -> CatResult<()> {
|
fn cat_struct(table: &mut Table, node: Handle, s: &Struct) -> CatResult<()> {
|
||||||
let parent = parent(table, node);
|
|
||||||
let Struct { name: _, gens: _, kind } = s;
|
let Struct { name: _, gens: _, kind } = s;
|
||||||
// TODO: Generics
|
// TODO: Generics
|
||||||
let kind = match kind {
|
let kind = match kind {
|
||||||
@ -73,7 +72,7 @@ fn cat_struct(table: &mut Table, node: Handle, s: &Struct) -> CatResult<()> {
|
|||||||
StructKind::Tuple(types) => {
|
StructKind::Tuple(types) => {
|
||||||
let mut out = vec![];
|
let mut out = vec![];
|
||||||
for ty in types {
|
for ty in types {
|
||||||
out.push((Visibility::Public, ty.evaluate(table, parent)?))
|
out.push((Visibility::Public, ty.evaluate(table, node)?))
|
||||||
}
|
}
|
||||||
TypeKind::Adt(Adt::TupleStruct(out))
|
TypeKind::Adt(Adt::TupleStruct(out))
|
||||||
}
|
}
|
||||||
@ -122,14 +121,13 @@ fn cat_variant<'a>(
|
|||||||
node: Handle,
|
node: Handle,
|
||||||
v: &'a Variant,
|
v: &'a Variant,
|
||||||
) -> CatResult<(Sym, Option<Handle>)> {
|
) -> CatResult<(Sym, Option<Handle>)> {
|
||||||
let parent = parent(table, node);
|
|
||||||
let Variant { name, kind } = v;
|
let Variant { name, kind } = v;
|
||||||
match kind {
|
match kind {
|
||||||
VariantKind::Plain => Ok((*name, None)),
|
VariantKind::Plain => Ok((*name, None)),
|
||||||
VariantKind::CLike(c) => todo!("enum-variant constant {c}"),
|
VariantKind::CLike(c) => todo!("enum-variant constant {c}"),
|
||||||
VariantKind::Tuple(ty) => {
|
VariantKind::Tuple(ty) => {
|
||||||
let ty = ty
|
let ty = ty
|
||||||
.evaluate(table, parent)
|
.evaluate(table, node)
|
||||||
.map_err(|e| Error::TypeEval(e, " while categorizing a variant"))?;
|
.map_err(|e| Error::TypeEval(e, " while categorizing a variant"))?;
|
||||||
Ok((*name, Some(ty)))
|
Ok((*name, Some(ty)))
|
||||||
}
|
}
|
||||||
@ -170,10 +168,9 @@ fn cat_static(table: &mut Table, node: Handle, s: &Static) -> CatResult<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn cat_function(table: &mut Table, node: Handle, f: &Function) -> CatResult<()> {
|
fn cat_function(table: &mut Table, node: Handle, f: &Function) -> CatResult<()> {
|
||||||
let parent = parent(table, node);
|
|
||||||
let kind = TypeKind::Instance(
|
let kind = TypeKind::Instance(
|
||||||
f.sign
|
f.sign
|
||||||
.evaluate(table, parent)
|
.evaluate(table, node)
|
||||||
.map_err(|e| Error::TypeEval(e, " while categorizing a function"))?,
|
.map_err(|e| Error::TypeEval(e, " while categorizing a function"))?,
|
||||||
);
|
);
|
||||||
table.set_ty(node, kind);
|
table.set_ty(node, kind);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user