Class: RLTK::CG::Function
- Inherits:
-
GlobalValue
- Object
- Value
- User
- Constant
- GlobalValue
- RLTK::CG::Function
- Defined in:
- lib/rltk/cg/function.rb
Overview
An LLVM IR function.
Defined Under Namespace
Classes: BasicBlockCollection, FunctionAttrCollection, ParameterCollection
Instance Attribute Summary collapse
-
#type ⇒ FunctionType
readonly
FunctionType object describing this function’s type.
Attributes included from BindingClass
Instance Method Summary collapse
-
#attributes ⇒ FunctionAttrCollection
(also: #attrs)
Proxy object for inspecting function attributes.
-
#basic_blocks ⇒ BasicBlockCollection
(also: #blocks)
Proxy object for inspecting a function’s basic blocks.
-
#calling_convention ⇒ Symbol
Get a function’s calling convention.
-
#calling_convention=(conv) ⇒ Object
Set a function’s calling convention.
-
#initialize(overloaded, name = '', *type_info, &block) ⇒ Function
constructor
Define a new function in a given module.
-
#parameters ⇒ ParameterCollection
(also: #params)
Proxy object for inspecting a function’s parameters.
-
#verify ⇒ nil, String
Verify that the function is valid LLVM IR.
-
#verify! ⇒ nil
Verify that the function is valid LLVM IR and abort the process if it isn’t.
Methods inherited from GlobalValue
#alignment, #alignment=, #declaration?, #global_constant=, #global_constant?, #initializer, #initializer=, #linkage, #linkage=, #section, #section=, #visibility, #visibility=
Methods inherited from Constant
#bitcast_to, #get_element_ptr, #get_element_ptr_in_bounds
Methods included from AbstractClass
Methods inherited from User
Methods inherited from Value
#==, #bitcast, #constant?, #dump, #hash, #name, #name=, #null?, #print, #trunc, #trunc_or_bitcast, #undefined?, #zextend, #zextend_or_bitcast
Methods included from BindingClass
Constructor Details
#initialize(overloaded, name = '', *type_info, &block) ⇒ Function
Define a new function in a given module. You can also use the Module::FunctionCollection#add method to add functions to modules.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rltk/cg/function.rb', line 36 def initialize(overloaded, name = '', *type_info, &block) @ptr = case overloaded when FFI::Pointer overloaded when RLTK::CG::Module @type = if type_info.first.is_a?(FunctionType) then type_info.first else FunctionType.new(*type_info) end Bindings.add_function(overloaded, name.to_s, @type) else raise 'The first argument to Function.new must be either a pointer or an instance of RLTK::CG::Module.' end self.instance_exec(self, &block) if block end |
Instance Attribute Details
#type ⇒ FunctionType (readonly)
Returns FunctionType object describing this function’s type.
24 25 26 |
# File 'lib/rltk/cg/function.rb', line 24 def type @type end |
Instance Method Details
#attributes ⇒ FunctionAttrCollection Also known as: attrs
Returns Proxy object for inspecting function attributes.
55 56 57 |
# File 'lib/rltk/cg/function.rb', line 55 def attributes @attributes ||= FunctionAttrCollection.new(self) end |
#basic_blocks ⇒ BasicBlockCollection Also known as: blocks
Returns Proxy object for inspecting a function’s basic blocks.
61 62 63 |
# File 'lib/rltk/cg/function.rb', line 61 def basic_blocks @basic_blocks ||= BasicBlockCollection.new(self) end |
#calling_convention ⇒ Symbol
Get a function’s calling convention.
71 72 73 |
# File 'lib/rltk/cg/function.rb', line 71 def calling_convention Bindings.enum_type(:call_conv)[Bindings.get_function_call_conv(@ptr)] end |
#calling_convention=(conv) ⇒ Object
Set a function’s calling convention.
80 81 82 83 84 |
# File 'lib/rltk/cg/function.rb', line 80 def calling_convention=(conv) Bindings.set_function_call_conv(@ptr, Bindings.enum_type(:call_conv)[conv]) conv end |
#parameters ⇒ ParameterCollection Also known as: params
Returns Proxy object for inspecting a function’s parameters.
87 88 89 |
# File 'lib/rltk/cg/function.rb', line 87 def parameters @parameters ||= ParameterCollection.new(self) end |
#verify ⇒ nil, String
Verify that the function is valid LLVM IR.
95 96 97 |
# File 'lib/rltk/cg/function.rb', line 95 def verify do_verification(:return_status) end |
#verify! ⇒ nil
Verify that the function is valid LLVM IR and abort the process if it isn’t.
102 103 104 |
# File 'lib/rltk/cg/function.rb', line 102 def verify! do_verification(:abort_process) end |