Skip to content

Commit

Permalink
Export foreign pointers properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
asoffer committed Dec 28, 2023
1 parent fa21944 commit 3488318
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ir/deserialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ bool Deserializer::Deserialize(ModuleProto const& proto, ModuleId id,

value.push_back(
&global_function_registry.function(FunctionId(mid, local_fn_id)));
} else if (t.kind() == type::Type::Kind::Pointer) {
if (exported_symbol.content().size() != 1) { return false; }
uint64_t n = exported_symbol.content()[0];
value.push_back(global_pointer_registry.pointer(n));
} else {
for (uint64_t n : exported_symbol.content()) {
jasmin::Value v = jasmin::Value::Uninitialized();
Expand Down
2 changes: 2 additions & 0 deletions ir/serialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ void Serializer::Serialize(Module& module, ModuleProto& proto) {
if (entry.qualified_type.type().kind() == type::Type::Kind::Function) {
raw_value =
global_function_registry.id(v.as<IrFunction const*>()).value();
} else if (entry.qualified_type.type().kind() == type::Type::Kind::Pointer) {
raw_value = global_pointer_registry.id(v.as<void*>());
} else {
raw_value = v.raw_value();
}
Expand Down

0 comments on commit 3488318

Please sign in to comment.