Skip to content

Commit

Permalink
Fixes to allow the compiler to work with the new block-passing logic
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.codehaus.org/jruby/branches/enebo_block@2830 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
headius committed Jan 23, 2007
1 parent 4f8a422 commit a190726
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 42 deletions.
4 changes: 2 additions & 2 deletions jruby/src/org/jruby/RubyArray.java
Expand Up @@ -91,7 +91,7 @@ public RubyArray(IRuby runtime, RubyClass klass) {
}

public IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte switchvalue, String name,
IRubyObject[] args, CallType callType) {
IRubyObject[] args, CallType callType, Block block) {
switch (switchvalue) {
case OP_PLUS_SWITCHVALUE:
Arity.singleArgument().checkArity(context.getRuntime(), args);
Expand Down Expand Up @@ -125,7 +125,7 @@ public IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte
return empty_p();
case 0:
default:
return super.callMethod(context, rubyclass, name, args, callType, null);
return super.callMethod(context, rubyclass, name, args, callType, block);
}
}

Expand Down
6 changes: 3 additions & 3 deletions jruby/src/org/jruby/RubyBignum.java
Expand Up @@ -37,12 +37,12 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallType;
import org.jruby.runtime.CallbackFactory;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;

import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.marshal.MarshalStream;
import org.jruby.runtime.marshal.UnmarshalStream;
Expand Down Expand Up @@ -108,7 +108,7 @@ public RubyBignum(IRuby runtime, BigInteger value) {
}

public IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte switchvalue, String name,
IRubyObject[] args, CallType callType) {
IRubyObject[] args, CallType callType, Block block) {
switch (switchvalue) {
case OP_PLUS_SWITCHVALUE:
Arity.singleArgument().checkArity(context.getRuntime(), args);
Expand All @@ -118,7 +118,7 @@ public IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte
return minus(args[0]);
case 0:
default:
return super.callMethod(context, rubyclass, name, args, callType, null);
return super.callMethod(context, rubyclass, name, args, callType, block);
}
}

Expand Down
6 changes: 3 additions & 3 deletions jruby/src/org/jruby/RubyFixnum.java
Expand Up @@ -35,8 +35,8 @@
package org.jruby;

import java.math.BigInteger;

import org.jruby.runtime.Arity;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallType;
import org.jruby.runtime.CallbackFactory;
import org.jruby.runtime.ClassIndex;
Expand Down Expand Up @@ -125,7 +125,7 @@ public RubyFixnum(IRuby runtime, long value) {
}

public IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte switchvalue, String name,
IRubyObject[] args, CallType callType) {
IRubyObject[] args, CallType callType, Block block) {
switch (switchvalue) {
case OP_PLUS_SWITCHVALUE:
Arity.singleArgument().checkArity(context.getRuntime(), args);
Expand All @@ -138,7 +138,7 @@ public IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte
return lt(args[0]);
case 0:
default:
return super.callMethod(context, rubyclass, name, args, callType, null);
return super.callMethod(context, rubyclass, name, args, callType, block);
}
}

Expand Down
16 changes: 12 additions & 4 deletions jruby/src/org/jruby/RubyObject.java
Expand Up @@ -348,17 +348,17 @@ public IRubyObject callMethod(ThreadContext context, String name,
}

/**
*
* Used by the compiler to ease calling indexed methods
*/
public IRubyObject callMethod(ThreadContext context, byte methodIndex, String name,
IRubyObject[] args, CallType callType) {
IRubyObject[] args, CallType callType, Block block) {
RubyModule module = getMetaClass();

if (module.index != 0) {
return callMethod(context, module, getRuntime().getSelectorTable().table[module.index][methodIndex], name, args, callType);
return callMethod(context, module, getRuntime().getSelectorTable().table[module.index][methodIndex], name, args, callType, block);
}

return callMethod(context, module, name, args, callType, null);
return callMethod(context, module, name, args, callType, block);
}

/**
Expand All @@ -368,6 +368,14 @@ public IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte
IRubyObject[] args, CallType callType) {
return callMethod(context, rubyclass, name, args, callType, null);
}

/**
*
*/
public IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte switchvalue, String name,
IRubyObject[] args, CallType callType, Block block) {
return callMethod(context, rubyclass, name, args, callType, block);
}

/**
*
Expand Down
4 changes: 2 additions & 2 deletions jruby/src/org/jruby/RubyString.java
Expand Up @@ -98,7 +98,7 @@ private RubyString(IRuby runtime, RubyClass rubyClass, CharSequence value) {
}

public IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte switchvalue, String name,
IRubyObject[] args, CallType callType) {
IRubyObject[] args, CallType callType, Block block) {
switch (switchvalue) {
case OP_PLUS_SWITCHVALUE:
Arity.singleArgument().checkArity(context.getRuntime(), args);
Expand Down Expand Up @@ -129,7 +129,7 @@ public IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte
return empty();
case 0:
default:
return super.callMethod(context, rubyclass, name, args, callType, null);
return super.callMethod(context, rubyclass, name, args, callType, block);
}
}

Expand Down
5 changes: 3 additions & 2 deletions jruby/src/org/jruby/compiler/impl/StandardASMCompiler.java
Expand Up @@ -442,8 +442,8 @@ public void lineNumber(ISourcePosition position) {
public void invokeDynamic(String name, boolean hasReceiver, boolean hasArgs) {
MethodVisitor mv = getMethodVisitor();
String callType = null;
String callSig = sig(IRubyObject.class, params(ThreadContext.class, String.class, IRubyObject[].class, CallType.class));
String callSigIndexed = sig(IRubyObject.class, params(ThreadContext.class, Byte.TYPE, String.class, IRubyObject[].class, CallType.class));
String callSig = sig(IRubyObject.class, params(ThreadContext.class, String.class, IRubyObject[].class, CallType.class, Block.class));
String callSigIndexed = sig(IRubyObject.class, params(ThreadContext.class, Byte.TYPE, String.class, IRubyObject[].class, CallType.class, Block.class));

byte index = MethodIndex.getIndex(name);

Expand Down Expand Up @@ -512,6 +512,7 @@ public void invokeDynamic(String name, boolean hasReceiver, boolean hasArgs) {
}

mv.visitFieldInsn(Opcodes.GETSTATIC, p(CallType.class), callType, ci(CallType.class));
mv.visitInsn(Opcodes.ACONST_NULL);

if (index != 0) {
invokeIRubyObject("callMethod", callSigIndexed);
Expand Down
10 changes: 4 additions & 6 deletions jruby/src/org/jruby/internal/runtime/methods/CompiledMethod.java
Expand Up @@ -61,7 +61,7 @@ public void postMethod(ThreadContext context) {
context.postCompiledMethod();
}

public IRubyObject internalCall(ThreadContext context, IRubyObject receiver, RubyModule lastClass, String name, IRubyObject[] args, boolean noSuper) {
public IRubyObject internalCall(ThreadContext context, IRubyObject receiver, RubyModule lastClass, String name, IRubyObject[] args, boolean noSuper, Block block) {
assert false;
return null;
}
Expand All @@ -83,7 +83,7 @@ private IRubyObject wrap(ThreadContext context, IRuby runtime, IRubyObject recei
}
}

public IRubyObject call(ThreadContext context, IRubyObject receiver, RubyModule lastClass, String name, IRubyObject[] args, boolean noSuper) {
public IRubyObject call(ThreadContext context, IRubyObject receiver, RubyModule lastClass, String name, IRubyObject[] args, boolean noSuper, Block block) {
IRuby runtime = context.getRuntime();
arity.checkArity(runtime, args);

Expand All @@ -92,14 +92,12 @@ public IRubyObject call(ThreadContext context, IRubyObject receiver, RubyModule

runtime.callTraceFunction(context, "c-call", position, receiver, name, getImplementationClass());
try {
// FIXME: pass block when it's available
return wrap(context, runtime, receiver, args, null);
return wrap(context, runtime, receiver, args, block);
} finally {
runtime.callTraceFunction(context, "c-return", position, receiver, name, getImplementationClass());
}
}
// FIXME: pass block when it's available
return wrap(context, runtime, receiver, args, null);
return wrap(context, runtime, receiver, args, block);
}

public abstract IRubyObject call(ThreadContext context, IRubyObject receiver, IRubyObject[] args, Block block);
Expand Down
40 changes: 20 additions & 20 deletions jruby/src/org/jruby/runtime/builtin/IRubyObject.java
Expand Up @@ -81,7 +81,7 @@ public interface IRubyObject {
IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, String name, IRubyObject[] args, CallType callType, Block block);
IRubyObject callMethod(ThreadContext context, RubyModule rubyclass, byte switchvalue, String name, IRubyObject[] args, CallType callType);

IRubyObject callMethod(ThreadContext context, byte switchValue, String name, IRubyObject[] args, CallType callType);
IRubyObject callMethod(ThreadContext context, byte switchValue, String name, IRubyObject[] args, CallType callType, Block block);

IRubyObject callMethod(ThreadContext context, String name, IRubyObject[] args, CallType callType);
IRubyObject callMethod(ThreadContext context, String name, IRubyObject[] args, CallType callType, Block block);
Expand All @@ -95,6 +95,25 @@ public interface IRubyObject {
IRubyObject callMethod(ThreadContext context, String string);
IRubyObject callMethod(ThreadContext context, String string, Block aBlock);

/**
* RubyMethod funcall.
* @param context TODO
* @param string
* @param arg
* @return RubyObject
*/
IRubyObject callMethod(ThreadContext context, String string, IRubyObject arg);

/**
* RubyMethod callMethod.
* @param context TODO
* @param method
* @param rubyArgs
* @return IRubyObject
*/
IRubyObject callMethod(ThreadContext context, String method, IRubyObject[] rubyArgs);
IRubyObject callMethod(ThreadContext context, String method, IRubyObject[] rubyArgs, Block block);

/**
* RubyMethod isNil.
* @return boolean
Expand All @@ -117,15 +136,6 @@ public interface IRubyObject {

boolean isImmediate();

/**
* RubyMethod funcall.
* @param context TODO
* @param string
* @param arg
* @return RubyObject
*/
IRubyObject callMethod(ThreadContext context, String string, IRubyObject arg);

/**
* RubyMethod getRubyClass.
*/
Expand Down Expand Up @@ -170,16 +180,6 @@ public interface IRubyObject {
*/
Class getJavaClass();

/**
* RubyMethod callMethod.
* @param context TODO
* @param method
* @param rubyArgs
* @return IRubyObject
*/
IRubyObject callMethod(ThreadContext context, String method, IRubyObject[] rubyArgs);
IRubyObject callMethod(ThreadContext context, String method, IRubyObject[] rubyArgs, Block block);

/**
* RubyMethod eval.
* @param iNode
Expand Down

0 comments on commit a190726

Please sign in to comment.