Class: RLTK::CG::Target
- Inherits:
-
Object
- Object
- RLTK::CG::Target
- Includes:
- BindingClass
- Defined in:
- lib/rltk/cg/target.rb
Overview
Class binding for the LLVM Triple class.
Instance Attribute Summary
Attributes included from BindingClass
Class Method Summary collapse
-
.first ⇒ Target
First target in the target list.
-
.host ⇒ Target
Target object for the host architecture.
-
.next_target(target) ⇒ Target
Next target in the target list.
Instance Method Summary collapse
-
#asm_backend? ⇒ Boolean
Whether or not the target has an ASM backend.
-
#describe ⇒ String
Description of the target.
-
#initialize(overloaded) ⇒ Target
constructor
Create an object representing a particular code generation target.
-
#jit? ⇒ Boolean
Whether or not the target has a JIT.
-
#target_machine? ⇒ Boolean
Whether or not the target has a TargetMachine.
-
#triple ⇒ Triple
Triple object for this target.
Methods included from BindingClass
Constructor Details
#initialize(overloaded) ⇒ Target
Create an object representing a particular code generation target. You can create a target either from a string or a Triple.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rltk/cg/target.rb', line 51 def initialize(overloaded) @ptr, @triple = case overloaded when String [Bindings.get_target_from_name(overloaded), Triple.new(overloaded)] when RLTK::CG::Triple ptr = FFI::MemoryPointer.new(:pointer) error = FFI::MemoryPointer.new(:pointer) status = Bindings.get_target_from_triple(overloaded.to_s, ptr, error) if status.zero? [ptr, overloaded] else errorp = error.read_pointer = errorp.null? ? 'Unknown' : errorp.read_string error.autorelease = false Bindings.(error) raise "Error creating target: #{}" end when RLTK::CG::Bindings::Triple [overloaded, nil] end end |
Class Method Details
.first ⇒ Target
Returns First target in the target list.
29 30 31 |
# File 'lib/rltk/cg/target.rb', line 29 def self.first @first ||= self.new(Bindings.get_first_target) end |
.host ⇒ Target
Returns Target object for the host architecture.
34 35 36 |
# File 'lib/rltk/cg/target.rb', line 34 def self.host @host ||= self.new(Triple.host) end |
.next_target(target) ⇒ Target
Returns Next target in the target list.
39 40 41 |
# File 'lib/rltk/cg/target.rb', line 39 def self.next_target(target) self.new(Bindings.get_next_target(target)) end |
Instance Method Details
#asm_backend? ⇒ Boolean
Returns Whether or not the target has an ASM backend.
82 83 84 |
# File 'lib/rltk/cg/target.rb', line 82 def asm_backend? Bindings.target_has_asm_backend(@ptr).to_bool end |
#describe ⇒ String
Returns Description of the target.
97 98 99 |
# File 'lib/rltk/cg/target.rb', line 97 def describe Bindings.get_target_description(@ptr) end |
#jit? ⇒ Boolean
Returns Whether or not the target has a JIT.
87 88 89 |
# File 'lib/rltk/cg/target.rb', line 87 def jit? Bindings.target_has_jit(@ptr).to_bool end |
#target_machine? ⇒ Boolean
Returns Whether or not the target has a TargetMachine.
92 93 94 |
# File 'lib/rltk/cg/target.rb', line 92 def target_machine? Bindings.target_has_target_machine(@ptr).to_bool end |
#triple ⇒ Triple
Returns Triple object for this target.
102 103 104 |
# File 'lib/rltk/cg/target.rb', line 102 def triple @triple ||= Triple.new(Bindings.get_target_name(@ptr)) end |