[core] codegen: Update raw_alloca to return PointerValue
Better match the expected behavior of alloca.
This commit is contained in:
parent
1b1cb775af
commit
155002629b
@ -1,7 +1,7 @@
|
||||
use inkwell::{
|
||||
context::Context,
|
||||
types::{AnyTypeEnum, BasicType, BasicTypeEnum, IntType, PointerType},
|
||||
values::IntValue,
|
||||
values::{IntValue, PointerValue},
|
||||
AddressSpace,
|
||||
};
|
||||
|
||||
@ -167,7 +167,7 @@ impl<'ctx> ProxyType<'ctx> for ListType<'ctx> {
|
||||
generator: &mut G,
|
||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||
name: Option<&'ctx str>,
|
||||
) -> <Self::Value as ProxyValue<'ctx>>::Base {
|
||||
) -> PointerValue<'ctx> {
|
||||
generator
|
||||
.gen_var_alloc(
|
||||
ctx,
|
||||
|
@ -16,7 +16,11 @@
|
||||
//! the returned object. This is similar to a `new` expression in C++ but the object is allocated
|
||||
//! on the stack.
|
||||
|
||||
use inkwell::{context::Context, types::BasicType, values::IntValue};
|
||||
use inkwell::{
|
||||
context::Context,
|
||||
types::BasicType,
|
||||
values::{IntValue, PointerValue},
|
||||
};
|
||||
|
||||
use super::{
|
||||
values::{ArraySliceValue, ProxyValue},
|
||||
@ -53,13 +57,14 @@ pub trait ProxyType<'ctx>: Into<Self::Base> {
|
||||
llvm_ty: Self::Base,
|
||||
) -> Result<(), String>;
|
||||
|
||||
/// Creates a new value of this type, returning the LLVM instance of this value.
|
||||
/// Creates a new value of this type by invoking `alloca`, returning a [`PointerValue`] instance
|
||||
/// representing the allocated value.
|
||||
fn raw_alloca<G: CodeGenerator + ?Sized>(
|
||||
&self,
|
||||
generator: &mut G,
|
||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||
name: Option<&'ctx str>,
|
||||
) -> <Self::Value as ProxyValue<'ctx>>::Base;
|
||||
) -> PointerValue<'ctx>;
|
||||
|
||||
/// Creates a new array value of this type, returning an [`ArraySliceValue`] encapsulating the
|
||||
/// resulting array.
|
||||
|
@ -218,7 +218,7 @@ impl<'ctx> ProxyType<'ctx> for ContiguousNDArrayType<'ctx> {
|
||||
generator: &mut G,
|
||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||
name: Option<&'ctx str>,
|
||||
) -> <Self::Value as ProxyValue<'ctx>>::Base {
|
||||
) -> PointerValue<'ctx> {
|
||||
generator
|
||||
.gen_var_alloc(
|
||||
ctx,
|
||||
|
@ -176,7 +176,7 @@ impl<'ctx> ProxyType<'ctx> for NDIndexType<'ctx> {
|
||||
generator: &mut G,
|
||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||
name: Option<&'ctx str>,
|
||||
) -> <Self::Value as ProxyValue<'ctx>>::Base {
|
||||
) -> PointerValue<'ctx> {
|
||||
generator
|
||||
.gen_var_alloc(
|
||||
ctx,
|
||||
|
@ -430,7 +430,7 @@ impl<'ctx> ProxyType<'ctx> for NDArrayType<'ctx> {
|
||||
generator: &mut G,
|
||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||
name: Option<&'ctx str>,
|
||||
) -> <Self::Value as ProxyValue<'ctx>>::Base {
|
||||
) -> PointerValue<'ctx> {
|
||||
generator
|
||||
.gen_var_alloc(
|
||||
ctx,
|
||||
|
@ -203,7 +203,7 @@ impl<'ctx> ProxyType<'ctx> for NDIterType<'ctx> {
|
||||
generator: &mut G,
|
||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||
name: Option<&'ctx str>,
|
||||
) -> <Self::Value as ProxyValue<'ctx>>::Base {
|
||||
) -> PointerValue<'ctx> {
|
||||
generator
|
||||
.gen_var_alloc(
|
||||
ctx,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use inkwell::{
|
||||
context::Context,
|
||||
types::{AnyTypeEnum, BasicType, BasicTypeEnum, IntType, PointerType},
|
||||
values::IntValue,
|
||||
values::{IntValue, PointerValue},
|
||||
AddressSpace,
|
||||
};
|
||||
|
||||
@ -131,7 +131,7 @@ impl<'ctx> ProxyType<'ctx> for RangeType<'ctx> {
|
||||
generator: &mut G,
|
||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||
name: Option<&'ctx str>,
|
||||
) -> <Self::Value as ProxyValue<'ctx>>::Base {
|
||||
) -> PointerValue<'ctx> {
|
||||
generator
|
||||
.gen_var_alloc(
|
||||
ctx,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use inkwell::{
|
||||
context::{AsContextRef, Context, ContextRef},
|
||||
types::{AnyTypeEnum, BasicType, BasicTypeEnum, IntType, PointerType},
|
||||
values::IntValue,
|
||||
values::{IntValue, PointerValue},
|
||||
AddressSpace,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
@ -215,7 +215,7 @@ impl<'ctx> ProxyType<'ctx> for SliceType<'ctx> {
|
||||
generator: &mut G,
|
||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||
name: Option<&'ctx str>,
|
||||
) -> <Self::Value as ProxyValue<'ctx>>::Base {
|
||||
) -> PointerValue<'ctx> {
|
||||
generator
|
||||
.gen_var_alloc(
|
||||
ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user