Update based on feedback
This commit is contained in:
parent
1ad9c3672d
commit
f63a2c4498
@ -41,7 +41,9 @@ use nac3core::{
|
|||||||
numpy::unpack_ndarray_var_tys,
|
numpy::unpack_ndarray_var_tys,
|
||||||
DefinitionId, GenCall,
|
DefinitionId, GenCall,
|
||||||
},
|
},
|
||||||
typecheck::typedef::{iter_type_vars, FunSignature, FuncArg, Type, TypeEnum, VarMap},
|
typecheck::typedef::{
|
||||||
|
iter_type_vars, FunSignature, FuncArg, Type, TypeEnum, TypeEnum::*, VarMap,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The parallelism mode within a block.
|
/// The parallelism mode within a block.
|
||||||
@ -392,8 +394,6 @@ fn gen_rpc_tag(
|
|||||||
buffer.push(b'k');
|
buffer.push(b'k');
|
||||||
}
|
}
|
||||||
|
|
||||||
use nac3core::typecheck::typedef::TypeEnum::*;
|
|
||||||
|
|
||||||
let int32 = ctx.primitives.int32;
|
let int32 = ctx.primitives.int32;
|
||||||
let int64 = ctx.primitives.int64;
|
let int64 = ctx.primitives.int64;
|
||||||
let float = ctx.primitives.float;
|
let float = ctx.primitives.float;
|
||||||
@ -451,7 +451,7 @@ fn gen_rpc_tag(
|
|||||||
|
|
||||||
buffer.push(b'a');
|
buffer.push(b'a');
|
||||||
buffer.push((ndarray_ndims & 0xFF) as u8);
|
buffer.push((ndarray_ndims & 0xFF) as u8);
|
||||||
gen_rpc_tag(ctx, ndarray_dtype, false, buffer)?; // Pass false for is_kwarg
|
gen_rpc_tag(ctx, ndarray_dtype, false, buffer)?;
|
||||||
}
|
}
|
||||||
_ => return Err(format!("Unsupported type: {:?}", ctx.unifier.stringify(ty))),
|
_ => return Err(format!("Unsupported type: {:?}", ctx.unifier.stringify(ty))),
|
||||||
}
|
}
|
||||||
@ -804,7 +804,7 @@ fn format_rpc_ret<'ctx>(
|
|||||||
Some(result)
|
Some(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rpc_codegen_callback_fn<'ctx>(
|
fn rpc_codegen_callback_fn<'ctx>(
|
||||||
ctx: &mut CodeGenContext<'ctx, '_>,
|
ctx: &mut CodeGenContext<'ctx, '_>,
|
||||||
obj: Option<(Type, ValueEnum<'ctx>)>,
|
obj: Option<(Type, ValueEnum<'ctx>)>,
|
||||||
fun: (&FunSignature, DefinitionId),
|
fun: (&FunSignature, DefinitionId),
|
||||||
@ -816,10 +816,6 @@ pub fn rpc_codegen_callback_fn<'ctx>(
|
|||||||
let int32 = ctx.ctx.i32_type();
|
let int32 = ctx.ctx.i32_type();
|
||||||
let size_type = ctx.get_size_type();
|
let size_type = ctx.get_size_type();
|
||||||
let ptr_type = int8.ptr_type(AddressSpace::default());
|
let ptr_type = int8.ptr_type(AddressSpace::default());
|
||||||
let tag_ptr_type = ctx
|
|
||||||
.ctx
|
|
||||||
.struct_type(&[ptr_type.into(), size_type.into()], false)
|
|
||||||
.ptr_type(AddressSpace::default());
|
|
||||||
let service_id = int32.const_int(fun.1 .0 as u64, false);
|
let service_id = int32.const_int(fun.1 .0 as u64, false);
|
||||||
// -- setup rpc tags
|
// -- setup rpc tags
|
||||||
let mut tag = Vec::new();
|
let mut tag = Vec::new();
|
||||||
@ -842,9 +838,8 @@ pub fn rpc_codegen_callback_fn<'ctx>(
|
|||||||
} else {
|
} else {
|
||||||
let tag_len = tag.len();
|
let tag_len = tag.len();
|
||||||
let arr_ty = int8.array_type(tag_len as u32);
|
let arr_ty = int8.array_type(tag_len as u32);
|
||||||
let tag_const = int8.const_array(
|
let tag_const = int8
|
||||||
&tag.iter().map(|&b| int8.const_int(u64::from(b), false)).collect::<Vec<_>>(),
|
.const_array(&tag.iter().map(|&b| int8.const_int(u64::from(b), false)).collect_vec());
|
||||||
);
|
|
||||||
let arr_gv = ctx.module.add_global(arr_ty, None, &format!("{hash}.arr"));
|
let arr_gv = ctx.module.add_global(arr_ty, None, &format!("{hash}.arr"));
|
||||||
arr_gv.set_linkage(Linkage::Private);
|
arr_gv.set_linkage(Linkage::Private);
|
||||||
arr_gv.set_initializer(&tag_const);
|
arr_gv.set_initializer(&tag_const);
|
||||||
@ -941,7 +936,7 @@ pub fn rpc_codegen_callback_fn<'ctx>(
|
|||||||
ctx,
|
ctx,
|
||||||
if is_async { "rpc_send_async" } else { "rpc_send" },
|
if is_async { "rpc_send_async" } else { "rpc_send" },
|
||||||
None,
|
None,
|
||||||
&[service_id.into(), tag_ptr.into(), args_ptr.into()],
|
&[service_id.into(), tag_ptr.into(), arg_array.into()],
|
||||||
Some("rpc.send"),
|
Some("rpc.send"),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user