Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Sort out for in 1.9 mode

  • Loading branch information...
commit 960e18352e80297c749c34b898233ffd4976a052 1 parent 826d6a6
Evan Phoenix authored October 07, 2011
47  lib/compiler/ast/sends.rb
@@ -734,6 +734,53 @@ def sexp_name
734 734
       end
735 735
     end
736 736
 
  737
+    class For19Arguments < Node
  738
+      def initialize(line, arguments)
  739
+        @line = line
  740
+        @arguments = arguments
  741
+
  742
+        if @arguments.kind_of? MultipleAssignment
  743
+          @args = 0
  744
+          @splat = 0
  745
+        else
  746
+          @args = 1
  747
+          @splat = -1
  748
+        end
  749
+      end
  750
+
  751
+      def bytecode(g)
  752
+        g.push_local 0
  753
+        @arguments.bytecode(g)
  754
+        g.pop
  755
+      end
  756
+
  757
+      def required_args
  758
+        @args
  759
+      end
  760
+
  761
+      def total_args
  762
+        @args
  763
+      end
  764
+
  765
+      def post_args
  766
+        @args
  767
+      end
  768
+
  769
+      def splat_index
  770
+        @splat
  771
+      end
  772
+    end
  773
+
  774
+    class For19 < For
  775
+      def initialize(line, arguments, body)
  776
+        @line = line
  777
+        @arguments = For19Arguments.new line, arguments
  778
+        @body = body || NilLiteral.new(line)
  779
+
  780
+        new_local :"*for_args"
  781
+      end
  782
+    end
  783
+
737 784
     class Negate < Node
738 785
       attr_accessor :value
739 786
 
6  lib/melbourne/processor.rb
@@ -541,6 +541,12 @@ def process_iter(line, method_send, scope)
541 541
       method_send
542 542
     end
543 543
 
  544
+    def process_for(line, iter, arguments, body)
  545
+      send = AST::Send.new line, iter, :each
  546
+      send.block = AST::For19.new line, arguments, body
  547
+      send
  548
+    end
  549
+
544 550
     def process_lambda(line, scope)
545 551
       arguments = scope.array.shift
546 552
       if scope.array.size == 1
4  rakelib/blueprint.rb
@@ -16,6 +16,10 @@
16 16
     gcc.cflags << "-O2"
17 17
   end
18 18
 
  19
+  if ENV['POKE']
  20
+    gcc.mtime_only = true
  21
+  end
  22
+
19 23
   # This is necessary for the gcc sync prims to fully work
20 24
   if Rubinius::BUILD_CONFIG[:x86_32]
21 25
     gcc.cflags << "-march=i686"
47  vm/bytecode_verification.cpp
@@ -12,6 +12,8 @@
12 12
 #include "object_utils.hpp"
13 13
 #include "instruments/timing.hpp"
14 14
 
  15
+#include "configuration.hpp"
  16
+
15 17
 namespace rubinius {
16 18
   BytecodeVerification::BytecodeVerification(CompiledMethod* cm)
17 19
     : method_(cm)
@@ -64,6 +66,51 @@ namespace rubinius {
64 66
       return false;
65 67
     }
66 68
 
  69
+    // FIXME
  70
+    //
  71
+    // This is conditional because in 1.8 mode, CM's for blocks have arity
  72
+    // info that isn't used, but therefore fails these checks because 
  73
+    // of the way 'for' works.
  74
+    //
  75
+    // FIXME
  76
+    if(LANGUAGE_19_ENABLED(state) || LANGUAGE_20_ENABLED(state)) {
  77
+      if(Fixnum* fix = try_as<Fixnum>(method_->splat())) {
  78
+        if(fix->to_native() >= locals_) {
  79
+          fail("invalid splat position", -1);
  80
+          return false;
  81
+        }
  82
+      }
  83
+
  84
+      Fixnum* tot = try_as<Fixnum>(method_->total_args());
  85
+      Fixnum* req = try_as<Fixnum>(method_->required_args());
  86
+      Fixnum* post = try_as<Fixnum>(method_->post_args());
  87
+
  88
+      if(!tot || !req || !post) {
  89
+        fail("method not initialized properly (missing arg counts)", -1);
  90
+        return false;
  91
+      }
  92
+
  93
+      if(tot->to_native() > locals_) {
  94
+        fail("more arguments than local slots", -1);
  95
+        return false;
  96
+      }
  97
+
  98
+      if(req->to_native() > tot->to_native()) {
  99
+        fail("more required arguments than total", -1);
  100
+        return false;
  101
+      }
  102
+
  103
+      if(post->to_native() > tot->to_native()) {
  104
+        fail("more post arguments than total", -1);
  105
+        return false;
  106
+      }
  107
+
  108
+      if(post->to_native() + req->to_native() > tot->to_native()) {
  109
+        fail("more post + req arguments than total", -1);
  110
+        return false;
  111
+      }
  112
+    }
  113
+
67 114
     total_ = ops_->num_fields();
68 115
     stack_ = new int32_t[total_];
69 116
 

0 notes on commit 960e183

Please sign in to comment.
Something went wrong with that request. Please try again.