forked from M-Labs/nac3
[WIP] Merge Globals into Module
This commit is contained in:
parent
3a7cd82b99
commit
472b76a411
@ -180,9 +180,12 @@
|
||||
clippy
|
||||
pre-commit
|
||||
rustfmt
|
||||
rust-analyzer
|
||||
];
|
||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
shellHook =
|
||||
''
|
||||
export PYTHONPATH=/home/abdul/nac3/pyo3:$PYTHONPATH
|
||||
export DEMO_LINALG_STUB=${packages.x86_64-linux.demo-linalg-stub}/lib/liblinalg.a
|
||||
export DEMO_LINALG_STUB32=${packages.x86_64-linux.demo-linalg-stub32}/lib/liblinalg.a
|
||||
'';
|
||||
|
@ -997,16 +997,24 @@ pub fn attributes_writeback<'ctx>(
|
||||
let ty = ty.unwrap();
|
||||
|
||||
if let Some(def_id) = inner_resolver.pyid_to_def.read().get(gloabl_id) {
|
||||
if let TopLevelDef::Variable { name, .. } = &*top_levels[def_id.0].read() {
|
||||
if let TopLevelDef::Variable { name, simple_name, .. } = &*top_levels[def_id.0].read() {
|
||||
// println!("[+] Varaible with type: {:?}\n{:?}\n", ctx.unifier.stringify(*ty), ctx.unifier.get_ty(*ty));
|
||||
println!("Sending Value of {:?}", val.to_string());
|
||||
if gen_rpc_tag(ctx, ty, &mut scratch_buffer).is_ok() {
|
||||
// let Some(val) = ctx.module.get_global(simple_name.to_string().as_str()) else {continue;};
|
||||
// let val = val.as_pointer_value();
|
||||
let pydict = PyDict::new(py);
|
||||
pydict.set_item("global", val)?;
|
||||
pydict.set_item("name", name)?;
|
||||
host_attributes.append(pydict)?;
|
||||
|
||||
values.push((
|
||||
ty,
|
||||
// ctx.build_gep_and_load(
|
||||
// val,
|
||||
// &[zero, int32.const_int(0, false)],
|
||||
// None,
|
||||
// ),
|
||||
inner_resolver.get_obj_value(py, val, ctx, generator, ty)?.unwrap(),
|
||||
));
|
||||
}
|
||||
|
@ -557,9 +557,12 @@ impl Nac3 {
|
||||
}
|
||||
if let StmtKind::AnnAssign { target, .. } = &stmt.node {
|
||||
let ExprKind::Name { id: name, .. } = target.node else { unreachable!() };
|
||||
|
||||
global_value_ids
|
||||
.write()
|
||||
.insert(id, py_module.getattr(name.to_string().as_str()).unwrap().into());
|
||||
// .insert(id, py_module.getattr(name.to_string().as_str()).unwrap().into());
|
||||
.insert(id, module.as_ref(py).into());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1579,6 +1579,7 @@ impl SymbolResolver for Resolver {
|
||||
let init_val = ctx.gen_symbol_val(generator, &v, ty);
|
||||
let llvm_ty = init_val.get_type();
|
||||
|
||||
println!("Adding {id}");
|
||||
let global = ctx.module.add_global(llvm_ty, None, &id.to_string());
|
||||
global.set_linkage(Linkage::LinkOnceAny);
|
||||
global.set_initializer(&init_val);
|
||||
|
Loading…
Reference in New Issue
Block a user