Skip to content

Commit

Permalink
fix: disable type.context automatically free
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziqi-Yang committed Sep 6, 2024
1 parent 0b6219d commit a9a6fb7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/el_psy_congaroo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@

m = utils.parse_assembly(asm_str)

print(m.context) # FIXME
print(m.context)
# with core.Context.get_global_context() as ctx:
# print(ctx)
4 changes: 3 additions & 1 deletion src/llvm/Core/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ void bindTypeClasses(nb::module_ &m) {
"Whether the type has a known size.\n\n"
"Things that don't have a size are abstract types, labels, and void.a")
.def_prop_ro("context",
[](PymType &t) { return PymContext(LLVMGetTypeContext(t.get())); },
[](PymType &t) {
return PymContext(LLVMGetTypeContext(t.get()), true);
},
"Obtain the context to which this type instance is associated.")
.def_prop_ro("sub_type_number",
[](PymType &t) {
Expand Down
4 changes: 4 additions & 0 deletions src/llvm/types_priv/PymContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
class PymContext : public PymLLVMObject<PymContext, LLVMContextRef> {
public:
explicit PymContext();
/*
is_global_context: whether this context is a global context; Or true if you
don't want automatically delete the context.
*/
explicit PymContext(LLVMContextRef context, bool is_global_context);
explicit PymContext(LLVMContextRef context);
static PymContext getGlobalContext();
Expand Down

0 comments on commit a9a6fb7

Please sign in to comment.