Permalink
Browse files

fixed super within a method that has a splat argument

  • Loading branch information...
1 parent 8397cfb commit 164ca93c02da4a94a47fa00ea1683a9df7e1dc54 @lrz lrz committed Aug 4, 2009
Showing with 16 additions and 0 deletions.
  1. +15 −0 compiler.cpp
  2. +1 −0 compiler.h
View
@@ -43,6 +43,7 @@ RoxorCompiler::RoxorCompiler(void)
rescue_bb = NULL;
ensure_bb = NULL;
current_mid = 0;
+ current_arity = rb_vm_arity(-1);
current_instance_method = false;
self_id = rb_intern("self");
current_self = NULL;
@@ -2899,9 +2900,14 @@ RoxorCompiler::compile_node(NODE *node)
BranchInst::Create(entry_bb, bb);
bb = entry_bb;
+ rb_vm_arity_t old_current_arity = current_arity;
+ current_arity = arity;
+
DEBUG_LEVEL_INC();
val = compile_node(node->nd_body);
DEBUG_LEVEL_DEC();
+
+ current_arity = old_current_arity;
}
if (val == NULL) {
val = nilVal;
@@ -3781,8 +3787,17 @@ RoxorCompiler::compile_node(NODE *node)
Function::ArgumentListType::iterator iter = fargs.begin();
iter++; // skip self
iter++; // skip sel
+ const int rest_pos = current_arity.max == -1
+ ? (current_arity.left_req
+ + (current_arity.real - current_arity.min - 1))
+ : -1;
+ int i = 0;
while (iter != fargs.end()) {
+ if (i == rest_pos) {
+ params.push_back(splatArgFollowsVal);
+ }
params.push_back(iter);
+ ++i;
++iter;
}
argc = fargs_arity;
View
@@ -80,6 +80,7 @@ class RoxorCompiler {
BasicBlock *bb;
BasicBlock *entry_bb;
ID current_mid;
+ rb_vm_arity_t current_arity;
bool current_instance_method;
ID self_id;
Value *current_self;

0 comments on commit 164ca93

Please sign in to comment.