Class: RLTK::CG::Context

Inherits:
Object show all
Includes:
BindingClass
Defined in:
lib/rltk/cg/context.rb

Overview

Bindings for LLVM contexts.

Constant Summary collapse

CLASS_FINALIZER =

The Proc object called by the garbage collector to free resources used by LLVM.

Proc.new { |id| Bindings.context_dispose(ptr) if ptr = ObjectSpace._id2ref(id).ptr }

Instance Attribute Summary

Attributes included from BindingClass

#ptr

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BindingClass

#==

Constructor Details

#initialize(ptr = nil) ⇒ Context

Returns a new instance of Context.

Parameters:

  • ptr (FFI::Pointer, nil) (defaults to: nil)

    Pointer representing a context. If nil, a new context is created.



40
41
42
43
44
45
46
# File 'lib/rltk/cg/context.rb', line 40

def initialize(ptr = nil)
	@ptr = ptr || Bindings.context_create()
	
	# Define a finalizer to free the memory used by LLVM for this
	# context.
	ObjectSpace.define_finalizer(self, CLASS_FINALIZER)
end

Class Method Details

.globalContext

Returns A global context.

Returns:



31
32
33
# File 'lib/rltk/cg/context.rb', line 31

def self.global
	self.new(Bindings.get_global_context())
end