Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Fir/Char.fir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Char(
value type Char(
_codePoint: U32,
)

Expand Down
2 changes: 1 addition & 1 deletion Fir/Str.fir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Immutable, UTF-8 encoded strings.
type Str(
value type Str(
# UTF-8 encoding of the string.
_bytes: Array[U8],
)
Expand Down
2 changes: 1 addition & 1 deletion Fir/StrBuf.fir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type StrBuf(
value type StrBuf(
# UTF-8 encoding of the string.
_bytes: Vec[U8],
)
Expand Down
26 changes: 23 additions & 3 deletions src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ pub struct LoweredPgm {

#[derive(Debug)]
pub enum TypeObjs {
Product(HeapObjIdx),
Product {
idx: HeapObjIdx,
value: bool,
},
Sum {
con_indices: Vec<HeapObjIdx>,
value: bool,
Expand Down Expand Up @@ -346,6 +349,7 @@ pub struct SourceConDecl {
pub idx: HeapObjIdx,
pub ty_args: Vec<mono::Type>,
pub fields: Vec<mono::Type>,
pub value: bool,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -811,6 +815,7 @@ pub fn lower(mono_pgm: &mut mono::MonoPgm) -> LoweredPgm {
&name,
con_ty_args,
fields,
con_decl.value,
));
con_indices.push(idx);
}
Expand All @@ -835,12 +840,19 @@ pub fn lower(mono_pgm: &mut mono::MonoPgm) -> LoweredPgm {
con_id,
con_ty_args,
fields,
con_decl.value,
));
let old = lowered_pgm
.type_objs
.entry(con_id.clone())
.or_default()
.insert(con_ty_args.clone(), TypeObjs::Product(idx));
.insert(
con_ty_args.clone(),
TypeObjs::Product {
idx,
value: con_decl.value,
},
);
assert!(old.is_none());
}
},
Expand All @@ -858,7 +870,13 @@ pub fn lower(mono_pgm: &mut mono::MonoPgm) -> LoweredPgm {
.type_objs
.entry(con_id.clone())
.or_default()
.insert(con_ty_args.clone(), TypeObjs::Product(idx));
.insert(
con_ty_args.clone(),
TypeObjs::Product {
idx,
value: con_decl.value,
},
);
assert!(old.is_none());
}

Expand Down Expand Up @@ -1481,6 +1499,7 @@ fn lower_source_con(
con_id: &SmolStr,
con_ty_args: &[mono::Type],
fields: &mono::ConFields,
value: bool,
) -> HeapObj {
HeapObj::Source(SourceConDecl {
name: con_id.clone(),
Expand All @@ -1491,6 +1510,7 @@ fn lower_source_con(
mono::ConFields::Named(fields) => fields.values().cloned().collect(),
mono::ConFields::Unnamed(fields) => fields.to_vec(),
},
value,
})
}

Expand Down
1 change: 1 addition & 0 deletions src/lowering/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl LoweredPgm {
idx,
ty_args,
fields,
value: _,
}) => {
assert_eq!(idx.0 as usize, heap_obj_idx);
buf.push_str(name.as_str());
Expand Down
Loading
Loading