mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-12 23:50:20 +03:00
Build erased load in llvm
This commit is contained in:
parent
fcb907b0c9
commit
f37cc48e88
@ -1134,7 +1134,14 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
|
||||
let callee = scope.load_symbol(callee).into_pointer_value();
|
||||
erased::build(env, value, callee).into()
|
||||
}
|
||||
ErasedLoad { .. } => todo_lambda_erasure!(),
|
||||
ErasedLoad { symbol, field } => {
|
||||
let value = scope.load_symbol(symbol).into_struct_value();
|
||||
let wanted_llvm_type =
|
||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(layout))
|
||||
.into_pointer_type();
|
||||
|
||||
erased::load(env, value, *field, wanted_llvm_type).into()
|
||||
}
|
||||
|
||||
Reset {
|
||||
symbol,
|
||||
|
@ -1,8 +1,9 @@
|
||||
use inkwell::{
|
||||
types::StructType,
|
||||
types::{PointerType, StructType},
|
||||
values::{PointerValue, StructValue},
|
||||
AddressSpace,
|
||||
};
|
||||
use roc_mono::ir::ErasedField;
|
||||
|
||||
use super::build::Env;
|
||||
|
||||
@ -64,3 +65,28 @@ pub fn build<'a, 'ctx>(
|
||||
|
||||
struct_value.into_struct_value()
|
||||
}
|
||||
|
||||
pub fn load<'ctx>(
|
||||
env: &Env<'_, 'ctx, '_>,
|
||||
erasure: StructValue<'ctx>,
|
||||
field: ErasedField,
|
||||
as_type: PointerType<'ctx>,
|
||||
) -> PointerValue<'ctx> {
|
||||
let index = match field {
|
||||
ErasedField::Value => 0,
|
||||
ErasedField::Callee => 1,
|
||||
};
|
||||
|
||||
let value = env
|
||||
.builder
|
||||
.build_extract_value(erasure, index, "extract_value")
|
||||
.unwrap()
|
||||
.into_pointer_value();
|
||||
|
||||
let value = env
|
||||
.builder
|
||||
.build_bitcast(value, as_type, "bitcast_to_type")
|
||||
.into_pointer_value();
|
||||
|
||||
value
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user