Class: RLTK::CG::Type Abstract
- Inherits:
-
Object
- Object
- RLTK::CG::Type
- Includes:
- Filigree::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.
-
#dump ⇒ void
Dump a string representation of the type to stdout.
-
#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.
-
#to_s ⇒ String
LLVM IR representation of the type.
Methods included from BindingClass
Constructor Details
#initialize(context = nil) ⇒ Type
The default constructor for Type objects.
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rltk/cg/type.rb', line 66 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.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rltk/cg/type.rb', line 42 def self.from_ptr(ptr) case Bindings.get_type_kind(ptr) when :array then ArrayType.new(ptr) when :half then HalfType.new 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.
78 79 80 |
# File 'lib/rltk/cg/type.rb', line 78 def allignment NativeInt.new(Bindings.align_of(@ptr)) end |
#context ⇒ Context
Returns Context in which this type was created.
83 84 85 |
# File 'lib/rltk/cg/type.rb', line 83 def context Context.new(Bindings.get_type_context(@ptr)) end |
#dump ⇒ void
This method returns an undefined value.
Dump a string representation of the type to stdout.
90 91 92 |
# File 'lib/rltk/cg/type.rb', line 90 def dump Bindings.dump_type(@ptr) end |
#hash ⇒ Fixnum
Returns Hashed value of the pointer representing this type.
95 96 97 |
# File 'lib/rltk/cg/type.rb', line 95 def hash @ptr.address.hash end |
#kind ⇒ Symbol
Returns The kind of this type.
102 103 104 |
# File 'lib/rltk/cg/type.rb', line 102 def kind Bindings.get_type_kind(@ptr) end |
#size ⇒ NativeInt
Returns Size of objects of this type.
107 108 109 |
# File 'lib/rltk/cg/type.rb', line 107 def size Int64.new(Bindings.size_of(@ptr)) end |
#to_s ⇒ String
Returns LLVM IR representation of the type.
112 113 114 |
# File 'lib/rltk/cg/type.rb', line 112 def to_s Bindings.print_type_to_string(@ptr) end |