Class: RLTK::CG::Type Abstract
- Includes:
- AbstractClass, BindingClass
- Defined in:
- lib/rltk/cg/type.rb
Overview
Root of the type class hierarchy.
The Type class and its sub-classes are used to describe the size and structure of various data objects inside LLVM and how different operations interact with them. When instantiating objects of the Value class you will often need to pass in some type information.
Direct Known Subclasses
AggregateType, FunctionType, NumberType, SimpleType, VectorType
Instance Attribute Summary
Attributes included from BindingClass
Class Method Summary collapse
-
.from_ptr(ptr) ⇒ Type
Instantiate a Type object from a pointer.
Instance Method Summary collapse
-
#allignment ⇒ NativeInt
Alignment of the type.
-
#context ⇒ Context
Context in which this type was created.
-
#hash ⇒ Fixnum
Hashed value of the pointer representing this type.
-
#initialize(context = nil) ⇒ Type
constructor
The default constructor for Type objects.
-
#kind ⇒ Symbol
The kind of this type.
-
#size ⇒ NativeInt
Size of objects of this type.
Methods included from AbstractClass
Methods included from BindingClass
Constructor Details
#initialize(context = nil) ⇒ Type
The default constructor for Type objects.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rltk/cg/type.rb', line 63 def initialize(context = nil) bname = Bindings.get_bname(self.class.short_name) @ptr = if context Bindings.send((bname.to_s + '_in_context').to_sym, check_type(context, Context, 'context')) else Bindings.send(bname) end end |
Class Method Details
.from_ptr(ptr) ⇒ Type
Instantiate a Type object from a pointer. This function is used internally, and as a library user you should never have to call it.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rltk/cg/type.rb', line 40 def self.from_ptr(ptr) case Bindings.get_type_kind(ptr) when :array then ArrayType.new(ptr) when :double then DoubleType.new when :float then FloatType.new when :function then FunctionType.new(ptr) when :fp128 then FP128Type.new when :integer then IntType.new when :label then LabelType.new when :metadata then raise "Can't generate a Type object for objects of type Metadata." when :pointer then PointerType.new(ptr) when :ppc_fp128 then PPCFP128Type.new when :struct then StructType.new(ptr) when :vector then VectorType.new(ptr) when :void then VoidType.new when :x86_fp80 then X86FP80Type.new when :x86_mmx then X86MMXType.new end end |
Instance Method Details
#allignment ⇒ NativeInt
Returns Alignment of the type.
75 76 77 |
# File 'lib/rltk/cg/type.rb', line 75 def allignment Int64.new(Bindings.align_of(@ptr)) end |
#context ⇒ Context
Returns Context in which this type was created.
80 81 82 |
# File 'lib/rltk/cg/type.rb', line 80 def context Context.new(Bindings.get_type_context(@ptr)) end |
#hash ⇒ Fixnum
Returns Hashed value of the pointer representing this type.
85 86 87 |
# File 'lib/rltk/cg/type.rb', line 85 def hash @ptr.address.hash end |
#kind ⇒ Symbol
Returns The kind of this type.
92 93 94 |
# File 'lib/rltk/cg/type.rb', line 92 def kind Bindings.get_type_kind(@ptr) end |