Class: LLVM::Module

Inherits:
Object
  • Object
show all
Defined in:
lib/llvm/analysis.rb,
lib/llvm/core/module.rb

Defined Under Namespace

Classes: FunctionCollection, GlobalCollection, TypeCollection

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ Module

Returns a new instance of Module.



11
12
13
# File 'lib/llvm/core/module.rb', line 11

def initialize(ptr)
  @ptr = ptr
end

Class Method Details

.create(name) ⇒ Object

Creates a module with the given name.



36
37
38
# File 'lib/llvm/core/module.rb', line 36

def self.create(name)
  new(C.LLVMModuleCreateWithName(name))
end

.from_ptr(ptr) ⇒ Object



6
7
8
# File 'lib/llvm/core/module.rb', line 6

def self.from_ptr(ptr)
  ptr.null? ? nil : new(ptr)
end

Instance Method Details

#==(other) ⇒ Object

Checks if the module is equal to other.



21
22
23
24
25
26
27
28
# File 'lib/llvm/core/module.rb', line 21

def ==(other)
  case other
  when LLVM::Module
    @ptr == other.to_ptr
  else
    false
  end
end

#disposeObject

Dispose the module.



233
234
235
# File 'lib/llvm/core/module.rb', line 233

def dispose
  C.LLVMDisposeModule(@ptr)
end

#dumpObject

Print the module’s IR to stdout.



228
229
230
# File 'lib/llvm/core/module.rb', line 228

def dump
  C.LLVMDumpModule(self)
end

#eql?(other) ⇒ Boolean

Checks if the module is equal to other.

Returns:

  • (Boolean)


31
32
33
# File 'lib/llvm/core/module.rb', line 31

def eql?(other)
  other.instance_of?(self.class) && self == other
end

#functionsObject

Returns a FunctionCollection of all the Functions in the module.



144
145
146
# File 'lib/llvm/core/module.rb', line 144

def functions
  @functions ||= FunctionCollection.new(self)
end

#globalsObject

Returns an Enumerable of all the GlobalVariables in the module.



72
73
74
# File 'lib/llvm/core/module.rb', line 72

def globals
  @globals ||= GlobalCollection.new(self)
end

#to_ptrObject



16
17
18
# File 'lib/llvm/core/module.rb', line 16

def to_ptr
  @ptr
end

#typesObject

Returns a TypeCollection of all the Types in the module.



41
42
43
# File 'lib/llvm/core/module.rb', line 41

def types
  @types ||= TypeCollection.new(self)
end

#verifyObject



19
20
21
# File 'lib/llvm/analysis.rb', line 19

def verify
  do_verification(:return_status)
end

#verify!Object



23
24
25
# File 'lib/llvm/analysis.rb', line 23

def verify!
  do_verification(:abort_process)
end