Skip to content

Commit

Permalink
Implement nqp::p6isbindable.
Browse files Browse the repository at this point in the history
Fixes various of the remaining multi-dispatch issues, and other things
that relied on multi-dispatch, such as transliteration.
  • Loading branch information
jnthn committed Jul 2, 2013
1 parent dceb13c commit faa0f9e
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions src/vm/jvm/runtime/org/perl6/rakudo/Ops.java
Expand Up @@ -4,6 +4,7 @@
import java.util.Comparator;
import org.perl6.nqp.runtime.*;
import org.perl6.nqp.sixmodel.*;
import org.perl6.nqp.sixmodel.reprs.CallCaptureInstance;
import org.perl6.nqp.sixmodel.reprs.ContextRefInstance;
import org.perl6.nqp.sixmodel.reprs.LexoticInstance;
import org.perl6.nqp.sixmodel.reprs.VMArrayInstance;
Expand Down Expand Up @@ -58,6 +59,7 @@ public GlobalExt(ThreadContext tc) { }
private static final int HINT_CODE_SIG = 1;
private static final int HINT_ROUTINE_RW = 7;
private static final int HINT_SIG_PARAMS = 0;
private static final int HINT_SIG_CODE = 4;
public static final int HINT_CD_OF = 0;
public static final int HINT_CD_RW = 1;
public static final int HINT_CD_NAME = 2;
Expand Down Expand Up @@ -312,11 +314,43 @@ public static SixModelObject p6bindcaptosig(SixModelObject sig, SixModelObject c
}
}

public static long p6isbindable(SixModelObject signature, SixModelObject capture, ThreadContext tc) {
/* TODO */
if (DEBUG_MODE)
System.err.println("p6isbindable NYI (always returns true)");
return 1;
public static long p6isbindable(SixModelObject sig, SixModelObject cap, ThreadContext tc) {
GlobalExt gcx = key.getGC(tc);

CallSiteDescriptor csd;
Object[] args;
if (cap instanceof CallCaptureInstance) {
CallCaptureInstance cc = (CallCaptureInstance)cap;
csd = cc.descriptor;
args = cc.args;
} else {
csd = Binder.explodeCapture(tc, gcx, cap);
args = tc.flatArgs;
}

SixModelObject params = sig.get_attribute_boxed(tc, gcx.Signature,
"$!params", HINT_SIG_PARAMS);
SixModelObject codeObj = sig.get_attribute_boxed(tc, gcx.Signature,
"$!code", HINT_SIG_CODE);
CodeRef cr = (CodeRef)codeObj.get_attribute_boxed(tc, gcx.Code,
"$!do", HINT_CODE_DO);

CallFrame cf = new CallFrame(tc, cr);
try {
switch (Binder.bind(tc, gcx, cf, params, csd, args, false, null)) {
case Binder.BIND_RESULT_FAIL:
return 0;
default:
return 1;
}
}
catch (Throwable t) {
t.printStackTrace();
throw t;
}
finally {
tc.curFrame = tc.curFrame.caller;
}
}

public static long p6trialbind(SixModelObject routine, SixModelObject values, SixModelObject flags, ThreadContext tc) {
Expand Down

0 comments on commit faa0f9e

Please sign in to comment.