forked from AbleOS/holey-bytes
fixing duplicate structs
This commit is contained in:
parent
802e8b5d55
commit
006bc80f12
|
@ -735,6 +735,7 @@ impl Codegen {
|
||||||
|
|
||||||
fn build_struct(
|
fn build_struct(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
file: FileId,
|
||||||
explicit_alignment: Option<u8>,
|
explicit_alignment: Option<u8>,
|
||||||
fields: &[CommentOr<StructField>],
|
fields: &[CommentOr<StructField>],
|
||||||
) -> ty::Struct {
|
) -> ty::Struct {
|
||||||
|
@ -746,6 +747,7 @@ impl Codegen {
|
||||||
self.tys.structs.push(Struct {
|
self.tys.structs.push(Struct {
|
||||||
field_start: self.tys.fields.len() as _,
|
field_start: self.tys.fields.len() as _,
|
||||||
explicit_alignment,
|
explicit_alignment,
|
||||||
|
file,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
self.tys.fields.extend(self.tys.fields_tmp.drain(prev_tmp..));
|
self.tys.fields.extend(self.tys.fields_tmp.drain(prev_tmp..));
|
||||||
|
@ -757,11 +759,9 @@ impl Codegen {
|
||||||
use {Expr as E, TokenKind as T};
|
use {Expr as E, TokenKind as T};
|
||||||
let value = match *expr {
|
let value = match *expr {
|
||||||
E::Mod { id, .. } => Some(Value::ty(ty::Kind::Module(id).compress())),
|
E::Mod { id, .. } => Some(Value::ty(ty::Kind::Module(id).compress())),
|
||||||
E::Struct { fields, captured, packed, .. } => {
|
E::Struct { captured, .. } => {
|
||||||
if captured.is_empty() {
|
if captured.is_empty() {
|
||||||
Some(Value::ty(
|
Some(Value::ty(self.ty(expr)))
|
||||||
ty::Kind::Struct(self.build_struct(packed.then_some(1), fields)).compress(),
|
|
||||||
))
|
|
||||||
} else {
|
} else {
|
||||||
let values = captured
|
let values = captured
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -2380,7 +2380,8 @@ impl Codegen {
|
||||||
}
|
}
|
||||||
|
|
||||||
let stru =
|
let stru =
|
||||||
ty::Kind::Struct(self.build_struct(packed.then_some(1), fields)).compress();
|
ty::Kind::Struct(self.build_struct(self.ci.file, packed.then_some(1), fields))
|
||||||
|
.compress();
|
||||||
self.ci.vars.truncate(prev_len);
|
self.ci.vars.truncate(prev_len);
|
||||||
self.ct.vm.write_reg(1, stru.repr() as u64);
|
self.ct.vm.write_reg(1, stru.repr() as u64);
|
||||||
debug_assert_ne!(stru.expand().inner(), 1);
|
debug_assert_ne!(stru.expand().inner(), 1);
|
||||||
|
@ -2473,8 +2474,8 @@ impl Codegen {
|
||||||
Expr::BinOp {
|
Expr::BinOp {
|
||||||
left: &Expr::Ident { .. },
|
left: &Expr::Ident { .. },
|
||||||
op: TokenKind::Decl,
|
op: TokenKind::Decl,
|
||||||
right: Expr::Struct { fields, packed, .. },
|
right: stru @ Expr::Struct { .. },
|
||||||
} => ty::Kind::Struct(self.build_struct(packed.then_some(1), fields)),
|
} => self.ty(stru).expand(),
|
||||||
Expr::BinOp { left, op: TokenKind::Decl, right } => {
|
Expr::BinOp { left, op: TokenKind::Decl, right } => {
|
||||||
let gid = self.tys.globals.len() as ty::Global;
|
let gid = self.tys.globals.len() as ty::Global;
|
||||||
self.tys.globals.push(Global { file, name: ident, ..Default::default() });
|
self.tys.globals.push(Global { file, name: ident, ..Default::default() });
|
||||||
|
|
Loading…
Reference in a new issue