forked from M-Labs/nac3
[artiq] Fix LLVM representation of strings
Should be `%str` rather than `[N x i8]`.
This commit is contained in:
parent
9e0601837a
commit
69320a6cf1
|
@ -0,0 +1,26 @@
|
|||
from min_artiq import *
|
||||
from numpy import ndarray, zeros as np_zeros
|
||||
|
||||
|
||||
@nac3
|
||||
class StrFail:
|
||||
core: KernelInvariant[Core]
|
||||
|
||||
def __init__(self):
|
||||
self.core = Core()
|
||||
|
||||
@kernel
|
||||
def hello(self, arg: str):
|
||||
pass
|
||||
|
||||
@kernel
|
||||
def consume_ndarray(self, arg: ndarray[str, 1]):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
self.hello("world")
|
||||
self.consume_ndarray(np_zeros([10], dtype=str))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
StrFail().run()
|
|
@ -163,7 +163,7 @@ impl StaticValue for PythonValue {
|
|||
PrimitiveValue::Bool(val) => {
|
||||
ctx.ctx.i8_type().const_int(u64::from(*val), false).into()
|
||||
}
|
||||
PrimitiveValue::Str(val) => ctx.ctx.const_string(val.as_bytes(), true).into(),
|
||||
PrimitiveValue::Str(val) => ctx.gen_string(generator, val).into(),
|
||||
});
|
||||
}
|
||||
if let Some(global) = ctx.module.get_global(&self.id.to_string()) {
|
||||
|
@ -977,7 +977,7 @@ impl InnerResolver {
|
|||
} else if ty_id == self.primitive_ids.string || ty_id == self.primitive_ids.np_str_ {
|
||||
let val: String = obj.extract().unwrap();
|
||||
self.id_to_primitive.write().insert(id, PrimitiveValue::Str(val.clone()));
|
||||
Ok(Some(ctx.ctx.const_string(val.as_bytes(), true).into()))
|
||||
Ok(Some(ctx.gen_string(generator, val).into()))
|
||||
} else if ty_id == self.primitive_ids.float || ty_id == self.primitive_ids.float64 {
|
||||
let val: f64 = obj.extract().unwrap();
|
||||
self.id_to_primitive.write().insert(id, PrimitiveValue::F64(val));
|
||||
|
|
Loading…
Reference in New Issue