Fix borrow-example
This commit is contained in:
parent
4de346e3c0
commit
8be6ce1549
@ -835,11 +835,7 @@ impl mir::Expression {
|
|||||||
.expect("index returned none!")
|
.expect("index returned none!")
|
||||||
.instr();
|
.instr();
|
||||||
|
|
||||||
let first = scope
|
dbg!(&ty);
|
||||||
.block
|
|
||||||
.build_named("array.zero", Instr::Constant(ConstValue::U32(0)))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let TypeKind::CodegenPtr(inner) = ty else {
|
let TypeKind::CodegenPtr(inner) = ty else {
|
||||||
panic!();
|
panic!();
|
||||||
};
|
};
|
||||||
@ -848,7 +844,7 @@ impl mir::Expression {
|
|||||||
let loaded = scope
|
let loaded = scope
|
||||||
.block
|
.block
|
||||||
.build_named(
|
.build_named(
|
||||||
"array.load",
|
"load",
|
||||||
Instr::Load(
|
Instr::Load(
|
||||||
kind.instr(),
|
kind.instr(),
|
||||||
inner.get_type(scope.type_values, scope.types),
|
inner.get_type(scope.type_values, scope.types),
|
||||||
@ -858,15 +854,36 @@ impl mir::Expression {
|
|||||||
(
|
(
|
||||||
scope
|
scope
|
||||||
.block
|
.block
|
||||||
.build_named(format!("array.gep"), Instr::GetElemPtr(loaded, vec![idx]))
|
.build_named(format!("gep"), Instr::GetElemPtr(loaded, vec![idx]))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.maybe_location(&mut scope.block, location),
|
.maybe_location(&mut scope.block, location),
|
||||||
*further_inner,
|
*further_inner,
|
||||||
)
|
)
|
||||||
|
} else if let TypeKind::CodegenPtr(further_inner) = *inner.clone() {
|
||||||
|
let TypeKind::Array(_, _) = *further_inner else {
|
||||||
|
panic!();
|
||||||
|
};
|
||||||
|
|
||||||
|
(
|
||||||
|
scope
|
||||||
|
.block
|
||||||
|
.build_named(
|
||||||
|
format!("array.gep"),
|
||||||
|
Instr::GetElemPtr(kind.instr(), vec![idx]),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
.maybe_location(&mut scope.block, location),
|
||||||
|
val_t.clone(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
let TypeKind::Array(_, _) = *inner else {
|
let TypeKind::Array(_, _) = *inner else {
|
||||||
panic!();
|
panic!();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let first = scope
|
||||||
|
.block
|
||||||
|
.build_named("array.zero", Instr::Constant(ConstValue::U32(0)))
|
||||||
|
.unwrap();
|
||||||
(
|
(
|
||||||
scope
|
scope
|
||||||
.block
|
.block
|
||||||
@ -1082,7 +1099,7 @@ impl mir::Expression {
|
|||||||
.expect("Variable reference not found?!");
|
.expect("Variable reference not found?!");
|
||||||
Some(StackValue(
|
Some(StackValue(
|
||||||
StackValueKind::mutable(*mutable, v.0.instr()),
|
StackValueKind::mutable(*mutable, v.0.instr()),
|
||||||
v.1.clone(),
|
TypeKind::Borrow(Box::new(v.1.clone()), *mutable),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
mir::ExprKind::Deref(varref) => {
|
mir::ExprKind::Deref(varref) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user