<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -248,13 +248,11 @@ module LLVMUtil
       if rec[0].type.is_a?(ComplexType) then
         rec[0].type.element_type.add_same_type atype
         # atype.add_same_type rec[0].type.element_type
-      else
-        rec[0].add_same_type atype
-        atype.add_same_type rec[0]
       end
     end
     
     lambda {|b, context, lst, led, body, recval, excl|
+=begin
       if argsize == 1 then
         if rec[0].type.is_a?(ComplexType) then
           rec[0].type.element_type.add_same_type atype
@@ -265,6 +263,7 @@ module LLVMUtil
         end
       end
       RubyType.resolve
+=end
       
       bcond = context.builder.create_block
       bbody = context.builder.create_block
@@ -466,6 +465,10 @@ module SendUtil
 
     elsif candidatenum &lt; MaxSmallPolymotphicNum then
       # TODO : Use inline hash function generation
+      p rectype.conflicted_types.keys
+      p rectype.inspect2
+      p rectype.name
+      p lexklass
       raise(&quot;Not implimented polymorphic methed call yet '#{mname}' #{lexklass}&quot;)
 
     else</diff>
      <filename>lib/llvmutil.rb</filename>
    </modified>
    <modified>
      <diff>@@ -103,9 +103,9 @@ module MethodDefinition
 
             case arr[0].type
             when ArrayType
-              val[0].add_same_type(arr[0].type.element_type)
-              arr[0].type.element_type.add_same_type(val[0])
-              RubyType.resolve
+#              val[0].add_same_type(arr[0].type.element_type)
+#              arr[0].type.element_type.add_same_type(val[0])
+#              RubyType.resolve
               ftype = Type.function(Type::VoidTy, 
                                     [VALUE, MACHINE_WORD, VALUE])
               func = context.builder.external_function('rb_ary_store', ftype)
@@ -520,6 +520,7 @@ module MethodDefinition
                   context
                   
                 else
+                  p rec[0].conflicted_types.keys
                   raise &quot;Do not supported #{rec[0].inspect2}&quot;
                 end
             }]</diff>
      <filename>lib/methoddef.rb</filename>
    </modified>
    <modified>
      <diff>@@ -819,7 +819,7 @@ class ArrayType&lt;AbstructContainerType
   def inspect2
     if @element_type then
       if has_cycle? then
-        &quot;Array of VALUE&quot;
+        &quot;Array of Array of ...&quot;
       else
         &quot;Array of #{@element_type.inspect2}&quot;
       end
@@ -886,7 +886,7 @@ class HashType&lt;AbstructContainerType
   def inspect2
     if @element_type then
       if has_cycle? then
-        &quot;Hash of VALUE&quot;
+        &quot;Hash of Hash of ...&quot;
       else
         &quot;Hash of #{@element_type.inspect2}&quot;
       end</diff>
      <filename>lib/type.rb</filename>
    </modified>
    <modified>
      <diff>@@ -252,6 +252,16 @@ class YarvTranslator&lt;YarvVisitor
   def run
     super
 
+    if OPTION[:var_signature] then
+      @global_var_tab.each do |vn, vtab|
+        if tinfo = vtab[:type] then
+          print &quot;#{vn} : #{tinfo.inspect2} \n&quot;
+        else
+          print &quot;#{vn} : nil \n&quot;
+        end
+      end
+    end
+
     # generate code for access Ruby internal
     if OPTION[:cache_instance_variable] then
       if @instance_var_tab.size != 0 then
@@ -950,8 +960,8 @@ class YarvTranslator&lt;YarvVisitor
     # don't call before visit_block_start call.
     if @is_live == nil then
       @is_live = true
+      @prev_label = ln
     end
-    @prev_label = ln
 
     # p @expstack.map {|n| n[1]}
   end
@@ -1267,6 +1277,7 @@ class YarvTranslator&lt;YarvVisitor
     srctype.add_same_value(dsttype)
     dsttype.add_same_type(srctype)
     srctype.extent = :global
+    dsttype.extent = :global
 
     oldrescode = @rescode
     @rescode = lambda {|b, context|
@@ -2044,6 +2055,7 @@ class YarvTranslator&lt;YarvVisitor
     rett2 = nil
     if code.lblock_list.last != ln then
       @is_live = false
+      @prev_label = ln
     end
 
     if retexp == nil then
@@ -2146,6 +2158,7 @@ class YarvTranslator&lt;YarvVisitor
     end
     bval = nil
     @is_live = false
+    @prev_label = ln
     @jump_from[lab] ||= []
     @jump_from[lab].push ln
     @rescode = lambda {|b, context|
@@ -2202,6 +2215,7 @@ class YarvTranslator&lt;YarvVisitor
         bval = [valexp[0], valexp[1].call(b, context).rc]
         context.block_value[iflab] = bval
       end
+
       condval = cond[1].call(b, context).rc
       if cond[0].type.llvm != Type::Int1Ty then
         vcond = cond[0].type.to_value(condval, b, context)
@@ -2839,7 +2853,14 @@ class YarvTranslator&lt;YarvVisitor
     if s1[0].type 
       if s1[0].type.klass == :String then
         rettype = check_same_type_2arg_static(s1, s2)
-      elsif s1[0].type.klass != :Array then
+      elsif s1[0].type.klass == :Array then
+        rettype = RubyType.array(info[3], &quot;Return type of ltlt&quot;)
+        s1[0].add_same_type rettype
+        rettype.add_same_type s1[0]
+        s2[0].add_same_type rettype.type.element_type
+        rettype.type.element_type.add_same_type s2[0]
+        RubyType.resolve
+      else
         rettype = check_same_type_2arg_static(s1, s2)
       end
     end
@@ -2887,7 +2908,26 @@ class YarvTranslator&lt;YarvVisitor
     when :Array
       context = idx[1].call(b, context)
       idxp = context.rc
-      if OPTION[:array_range_check] then
+      if idx[0].klass == :Range then
+        context = arr[1].call(b, context)
+        arrp = context.rc
+
+        idxptr = context.array_alloca_area
+        b.store(idxp, idxptr)
+
+        ftype = Type.function(VALUE, [LONG, P_VALUE, VALUE])
+        func = context.builder.external_function('rb_ary_aref', ftype)
+        av = b.call(func, 1.llvm, idxptr, arrp)
+        arrelet = arr[0].type.element_type.type
+        if arrelet then
+          context.rc = arrelet.from_value(av, b, context)
+        else
+          context.rc = av
+        end
+        context
+        
+        
+      elsif OPTION[:array_range_check] then
         context = arr[1].call(b, context)
         arrp = context.rc
         ftype = Type.function(VALUE, [VALUE, MACHINE_WORD])
@@ -3028,18 +3068,11 @@ class YarvTranslator&lt;YarvVisitor
   def visit_opt_aref(code, ins, local_vars, ln, info)
     idx = @expstack.pop
     arr = @expstack.pop
-    case arr[0].klass
-    when :Array
-      fix = RubyType.fixnum(info[3])
-      idx[0].add_same_type(fix)
-      fix.add_same_value(idx[0])
-    #  fix.resolve
-    end
+
     RubyType.resolve
 
     # AbstrubctContainorType is type which have [] and []= as method.
     if arr[0].type == nil then
-   #   RubyType.new(AbstructContainerType.new(nil)).add_same_type arr[0]
       arr[0].type = AbstructContainerType.new(nil)
     end
 
@@ -3047,7 +3080,19 @@ class YarvTranslator&lt;YarvVisitor
     indx = nil
     case arr[0].klass
     when :Array                 #, :Object
-      rettype = arr[0].type.element_type
+      if idx[0].klass == :Range then
+        rettype = arr[0].dup_type
+        level = @expstack.size
+        if @array_alloca_size == nil or @array_alloca_size &lt; 1 + level then
+          @array_alloca_size = 1 + level
+        end
+      else
+        fix = RubyType.fixnum(info[3])
+        idx[0].add_same_type(fix)
+        fix.add_same_value(idx[0])
+
+        rettype = arr[0].type.element_type
+      end
       
     when :Struct, :Hash
       rettype = RubyType.value</diff>
      <filename>lib/vmtraverse.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,6 +34,7 @@ DEF_OPTION = {
   :dump_yarv =&gt; false,
   :write_bc =&gt; false,
   :func_signature =&gt; false,
+  :var_signature =&gt; false,
 
   :array_range_check =&gt; true,
 </diff>
      <filename>lib/yarv2llvm.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
 module YARV2LLVM
-#=begin
 
   # type definition of method
 
@@ -57,7 +56,7 @@ module YARV2LLVM
     :rettype =&gt; rt,
     :copy_rettype =&gt; true,
   }
-#=begin
+
   MethodDefinition::RubyMethod[:at][:Array] = {
     :self =&gt; nil,
     :argtype =&gt; [RubyType.new(nil)],
@@ -70,7 +69,7 @@ module YARV2LLVM
       rt
     },
   }
-#=end
+
   st = RubyType.array
   rt = RubyType.new(nil)
   rt.add_same_type(st.type.element_type)
@@ -98,6 +97,17 @@ module YARV2LLVM
   rt = RubyType.array
   rt.add_same_type(st)
   st.add_same_type(rt)
+  MethodDefinition::RubyMethod[:sort][:Array] = {
+    :self =&gt; st,
+    :argtype =&gt; [],
+    :rettype =&gt; rt,
+    :copy_rettype =&gt; true,
+  }
+
+  st = RubyType.array
+  rt = RubyType.array
+  rt.add_same_type(st)
+  st.add_same_type(rt)
   MethodDefinition::RubyMethod[:slice!][:Array] = {
     :self =&gt; st,
     :argtype =&gt; [RubyType.new(nil), RubyType.new(nil)],
@@ -151,7 +161,7 @@ module YARV2LLVM
     :rettype =&gt; lst,
     :copy_rettype =&gt; true,
   }
-#=end
+
 end
 
 &lt;&lt;-'EOS'</diff>
      <filename>runtime/prelude.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@ require 'yarv2llvm'
 class UnsafeTests &lt; Test::Unit::TestCase
 
   def test_unsafe
-    YARV2LLVM::compile(&lt;&lt;-EOS, {:disasm =&gt; true, :dump_yarv =&gt; true, :optimize=&gt; true})
+    YARV2LLVM::compile(&lt;&lt;-EOS, {:disasm =&gt; false, :dump_yarv =&gt; false, :optimize=&gt; true})
 def tunsafe
   type = LLVM::struct([RubyHelpers::VALUE, LLVM::Type::Int32Ty, RubyHelpers::VALUE, RubyHelpers::VALUE])
   a = [:a, :b]
@@ -28,7 +28,7 @@ EOS
   end
 
   def test_define_external_function
-    YARV2LLVM::compile(&lt;&lt;-EOS, {:disasm =&gt; true, :dump_yarv =&gt; true, :optimize=&gt; true, :func_signature =&gt; true})
+    YARV2LLVM::compile(&lt;&lt;-EOS, {:disasm =&gt; false, :dump_yarv =&gt; false, :optimize=&gt; true, :func_signature =&gt; true})
 def tdefine_external_function
   value = RubyHelpers::VALUE
   int32ty = LLVM::Type::Int32Ty
@@ -45,7 +45,7 @@ EOS
   end
 
   def test_define_macro
-    YARV2LLVM::compile(&lt;&lt;-'EOS', {:disasm =&gt; true, :dump_yarv =&gt; true, :optimize=&gt; false, :func_signature =&gt; false})
+    YARV2LLVM::compile(&lt;&lt;-'EOS', {:disasm =&gt; false, :dump_yarv =&gt; false, :optimize=&gt; false, :func_signature =&gt; false})
 
 
 YARV2LLVM::define_macro :myif do |arg| `if #{_sender_env[:args][2]} then #{_sender_env[:args][1]} else #{_sender_env[:args][0]} end` end
@@ -57,5 +57,4 @@ end
 EOS
     assert_equal(tdefine_macro, &quot;hello&quot;)
   end
-
 end</diff>
      <filename>test/test_unsafe.rb</filename>
    </modified>
    <modified>
      <diff>@@ -78,6 +78,11 @@ if __FILE__ == $0 then
     y2lopt[:func_signature] = f
   end
 
+  opt.on('--[no-]var-signature', 
+         'Display type inferenced inforamtion about global variable') do |f|
+    y2lopt[:var_signature] = f
+  end
+
   opt.on('--[no-]type-message', 
          'Display type message for example Type Conflict Error') do |f|
     y2lopt[:type_message] = f</diff>
      <filename>yarv2llvm.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>131b0b56f21a4b8a79dba01e8cdab9ddf6cf8286</id>
    </parent>
  </parents>
  <author>
    <name>U-KOZUE\kozue</name>
    <email>m-72@tf6.so-net.ne.jp</email>
  </author>
  <url>http://github.com/miura1729/yarv2llvm/commit/011f5437e84218303a101714a7086e2bf66cf2a3</url>
  <id>011f5437e84218303a101714a7086e2bf66cf2a3</id>
  <committed-date>2009-09-20T23:54:45-07:00</committed-date>
  <authored-date>2009-09-20T23:54:45-07:00</authored-date>
  <message>Add --var-signature option and some bugs fixed</message>
  <tree>e31835c8ea5521423046bc8074547e3285a60611</tree>
  <committer>
    <name>U-KOZUE\kozue</name>
    <email>m-72@tf6.so-net.ne.jp</email>
  </committer>
</commit>
