File tree 3 files changed +9
-7
lines changed
3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 1
1
class LLVM::Builder
2
2
@disposed = false
3
3
4
- # def initialize(@unwrap : LibLLVM::BuilderRef, @context : Context)
5
- # end
6
-
7
4
def initialize (@unwrap : LibLLVM ::BuilderRef )
8
5
end
9
6
@@ -239,7 +236,7 @@ class LLVM::Builder
239
236
@unwrap
240
237
end
241
238
242
- def finalize
239
+ protected def dispose
243
240
return if @disposed
244
241
@disposed = true
245
242
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ class LLVM::Context
5
5
6
6
def initialize (@unwrap : LibLLVM ::ContextRef , @dispose_on_finalize = true )
7
7
@disposed = false
8
+ @builders = [] of LLVM ::Builder
8
9
end
9
10
10
11
def new_module (name : String ) : Module
@@ -16,8 +17,10 @@ class LLVM::Context
16
17
end
17
18
18
19
def new_builder : Builder
19
- # Builder.new(LibLLVM.create_builder_in_context(self), self)
20
- Builder .new(LibLLVM .create_builder_in_context(self ))
20
+ # builder = Builder.new(LibLLVM.create_builder_in_context(self), self)
21
+ builder = Builder .new(LibLLVM .create_builder_in_context(self ))
22
+ @builders << builder
23
+ builder
21
24
end
22
25
23
26
def void : Type
@@ -121,6 +124,8 @@ class LLVM::Context
121
124
return if @disposed
122
125
@disposed = true
123
126
127
+ @builders .each & .dispose
128
+
124
129
LibLLVM .dispose_context(self )
125
130
end
126
131
Original file line number Diff line number Diff line change 1
1
require " ./lib_llvm"
2
2
3
3
struct LLVM::DIBuilder
4
- def initialize (llvm_module )
4
+ def initialize (@ llvm_module : Module )
5
5
@unwrap = LibLLVMExt .create_di_builder(llvm_module)
6
6
end
7
7
You can’t perform that action at this time.
0 commit comments