Skip to content

Commit

Permalink
Sort out for in 1.9 mode
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed Oct 8, 2011
1 parent 826d6a6 commit 960e183
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
47 changes: 47 additions & 0 deletions lib/compiler/ast/sends.rb
Expand Up @@ -734,6 +734,53 @@ def sexp_name
end end
end end


class For19Arguments < Node
def initialize(line, arguments)
@line = line
@arguments = arguments

if @arguments.kind_of? MultipleAssignment
@args = 0
@splat = 0
else
@args = 1
@splat = -1
end
end

def bytecode(g)
g.push_local 0
@arguments.bytecode(g)
g.pop
end

def required_args
@args
end

def total_args
@args
end

def post_args
@args
end

def splat_index
@splat
end
end

class For19 < For
def initialize(line, arguments, body)
@line = line
@arguments = For19Arguments.new line, arguments
@body = body || NilLiteral.new(line)

new_local :"*for_args"
end
end

class Negate < Node class Negate < Node
attr_accessor :value attr_accessor :value


Expand Down
6 changes: 6 additions & 0 deletions lib/melbourne/processor.rb
Expand Up @@ -541,6 +541,12 @@ def process_iter(line, method_send, scope)
method_send method_send
end end


def process_for(line, iter, arguments, body)
send = AST::Send.new line, iter, :each
send.block = AST::For19.new line, arguments, body
send
end

def process_lambda(line, scope) def process_lambda(line, scope)
arguments = scope.array.shift arguments = scope.array.shift
if scope.array.size == 1 if scope.array.size == 1
Expand Down
4 changes: 4 additions & 0 deletions rakelib/blueprint.rb
Expand Up @@ -16,6 +16,10 @@
gcc.cflags << "-O2" gcc.cflags << "-O2"
end end


if ENV['POKE']
gcc.mtime_only = true
end

# This is necessary for the gcc sync prims to fully work # This is necessary for the gcc sync prims to fully work
if Rubinius::BUILD_CONFIG[:x86_32] if Rubinius::BUILD_CONFIG[:x86_32]
gcc.cflags << "-march=i686" gcc.cflags << "-march=i686"
Expand Down
47 changes: 47 additions & 0 deletions vm/bytecode_verification.cpp
Expand Up @@ -12,6 +12,8 @@
#include "object_utils.hpp" #include "object_utils.hpp"
#include "instruments/timing.hpp" #include "instruments/timing.hpp"


#include "configuration.hpp"

namespace rubinius { namespace rubinius {
BytecodeVerification::BytecodeVerification(CompiledMethod* cm) BytecodeVerification::BytecodeVerification(CompiledMethod* cm)
: method_(cm) : method_(cm)
Expand Down Expand Up @@ -64,6 +66,51 @@ namespace rubinius {
return false; return false;
} }


// FIXME
//
// This is conditional because in 1.8 mode, CM's for blocks have arity
// info that isn't used, but therefore fails these checks because
// of the way 'for' works.
//
// FIXME
if(LANGUAGE_19_ENABLED(state) || LANGUAGE_20_ENABLED(state)) {
if(Fixnum* fix = try_as<Fixnum>(method_->splat())) {
if(fix->to_native() >= locals_) {
fail("invalid splat position", -1);
return false;
}
}

Fixnum* tot = try_as<Fixnum>(method_->total_args());
Fixnum* req = try_as<Fixnum>(method_->required_args());
Fixnum* post = try_as<Fixnum>(method_->post_args());

if(!tot || !req || !post) {
fail("method not initialized properly (missing arg counts)", -1);
return false;
}

if(tot->to_native() > locals_) {
fail("more arguments than local slots", -1);
return false;
}

if(req->to_native() > tot->to_native()) {
fail("more required arguments than total", -1);
return false;
}

if(post->to_native() > tot->to_native()) {
fail("more post arguments than total", -1);
return false;
}

if(post->to_native() + req->to_native() > tot->to_native()) {
fail("more post + req arguments than total", -1);
return false;
}
}

total_ = ops_->num_fields(); total_ = ops_->num_fields();
stack_ = new int32_t[total_]; stack_ = new int32_t[total_];


Expand Down

0 comments on commit 960e183

Please sign in to comment.