<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -28,6 +28,14 @@ llvm_value_set_name(VALUE self, VALUE rname) {
   return rname; 
 }
 
+VALUE
+llvm_value_type(VALUE self) {
+  Value *v;
+  Data_Get_Struct(self, Value, v);
+  const Type *t = v-&gt;getType();  
+  return Data_Wrap_Struct(cLLVMType, NULL, NULL, (void*) t);;
+}
+
 VALUE 
 llvm_value_num_uses(VALUE self) {
   Value *v;
@@ -147,6 +155,20 @@ llvm_type_function(int argc, VALUE *argv, VALUE self) {
   return Data_Wrap_Struct(cLLVMFunctionType, NULL, NULL, ftype);
 }
 
+VALUE 
+llvm_type_to_s(VALUE self) {
+  Type *type;
+  Data_Get_Struct(self, Type, type);
+  return rb_str_new2(type-&gt;getDescription().c_str());
+}
+
+VALUE 
+llvm_type_type_id(VALUE self) {
+  Type *type;
+  Data_Get_Struct(self, Type, type);
+  return INT2FIX((int) type-&gt;getTypeID());
+}
+
 void init_types() {
   rb_define_const(cLLVMType, &quot;Int1Ty&quot;,  Data_Wrap_Struct(cLLVMType, NULL, NULL, const_cast&lt;IntegerType*&gt;(Type::Int1Ty)));
   rb_define_const(cLLVMType, &quot;Int8Ty&quot;,  Data_Wrap_Struct(cLLVMType, NULL, NULL, const_cast&lt;IntegerType*&gt;(Type::Int8Ty)));</diff>
      <filename>ext/llvm_value.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -37,6 +37,8 @@ VALUE llvm_type_array(VALUE, VALUE, VALUE);
 VALUE llvm_type_vector(VALUE, VALUE, VALUE);
 VALUE llvm_type_function2(VALUE, VALUE);
 VALUE llvm_type_function(VALUE, VALUE, VALUE);
+VALUE llvm_type_to_s(VALUE);
+VALUE llvm_type_type_id(VALUE);
 
 void init_instructions();
 
@@ -120,6 +122,7 @@ VALUE llvm_value_get_immediate_constant(VALUE);
 VALUE llvm_value_get_struct_constant(int, VALUE*, VALUE);
 VALUE llvm_value_name(VALUE);
 VALUE llvm_value_set_name(VALUE, VALUE);
+VALUE llvm_value_type(VALUE);
 VALUE llvm_value_num_uses(VALUE);
 VALUE llvm_value_used_in_basic_block(VALUE, VALUE);
 VALUE llvm_value_replace_all_uses_with(VALUE, VALUE);
@@ -180,6 +183,8 @@ void Init_llvmruby() {
   rb_define_module_function(cLLVMType, &quot;array&quot;, llvm_type_array, 2);
   rb_define_module_function(cLLVMType, &quot;vector&quot;, llvm_type_vector, 2);
   rb_define_module_function(cLLVMType, &quot;function&quot;, llvm_type_function, -1);
+  rb_define_method(cLLVMType, &quot;to_s&quot;, llvm_type_to_s, 0);
+  rb_define_method(cLLVMType, &quot;type_id&quot;, llvm_type_type_id, 0);
 
   rb_define_module_function(cLLVMValue, &quot;get_constant&quot;, llvm_value_get_constant, 2);
   rb_define_module_function(cLLVMValue, &quot;get_float_constant&quot;, llvm_value_get_float_constant, 1);
@@ -188,6 +193,7 @@ void Init_llvmruby() {
   rb_define_module_function(cLLVMValue, &quot;get_struct_constant&quot;, llvm_value_get_struct_constant, -1);
   rb_define_method(cLLVMValue, &quot;name&quot;, llvm_value_name, 0);
   rb_define_method(cLLVMValue, &quot;name=&quot;, llvm_value_set_name, 1);
+  rb_define_method(cLLVMValue, &quot;type&quot;, llvm_value_type, 0);
   rb_define_method(cLLVMValue, &quot;num_uses&quot;, llvm_value_num_uses, 0);
   rb_define_method(cLLVMValue, &quot;used_in_basic_block?&quot;, llvm_value_used_in_basic_block, 1);
   rb_define_method(cLLVMValue, &quot;replace_all_uses_with&quot;, llvm_value_replace_all_uses_with, 1);</diff>
      <filename>ext/llvmruby.c</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,10 @@ class LLVM::Value
 end
 
 module LLVM
+  # enum llvm::Type::TypeID
+  VoidTyID, FloatTyID, DoubleTyID, X86_FP80TyID, FP128TyID, PPC_FP128TyID, LabelTyID, IntegerTyID, 
+  FunctionTyID, StructTyID, ArrayTyID, PointerTyID, OpaqueTyID, VectorTyID = (0..13).to_a
+  
   class Builder
     def self.add_bin_op(op)
       define_method(op.downcase) do |x, y|</diff>
      <filename>lib/llvm.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 require 'test/unit'
+$:.unshift File.dirname(__FILE__) + &quot;/../ext&quot;
 require 'llvm'
 
 include LLVM
@@ -328,4 +329,12 @@ class BasicTests &lt; Test::Unit::TestCase
     m = LLVM::Module.new('test')
     assert PassManager.new.run(m)
   end
+  
+  def test_type_to_s
+    assert_equal &quot;i32&quot;, 2.llvm.type.to_s
+  end
+
+  def test_type_type_id
+    assert_equal IntegerTyID, 2.llvm.type.type_id
+  end
 end</diff>
      <filename>test/test_basic.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bd6fff4905d7ba608633000b6cd8e3a47a9f2534</id>
    </parent>
  </parents>
  <author>
    <name>macournoyer</name>
    <email>macournoyer@gmail.com</email>
  </author>
  <url>http://github.com/tombagby/llvmruby/commit/c70593096d078193a19bb13a1959ea29bc135792</url>
  <id>c70593096d078193a19bb13a1959ea29bc135792</id>
  <committed-date>2008-10-23T19:20:36-07:00</committed-date>
  <authored-date>2008-10-23T19:20:36-07:00</authored-date>
  <message>Implement LLVM::Value#type, LLVM::Type#to_s, LLVM::Type::type_id and Ruby constants for llvm::Type::TypeID enum.</message>
  <tree>6229f96590855dd2f59d2954ef5d7aa31a5205fc</tree>
  <committer>
    <name>macournoyer</name>
    <email>macournoyer@gmail.com</email>
  </committer>
</commit>
