Skip to content

Commit

Permalink
Call method case of boolification.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Feb 16, 2013
1 parent 67c7023 commit 264c63b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/org/perl6/nqp/runtime/Ops.java
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ public static SixModelObject captureposarg(SixModelObject obj, long idx, ThreadC

/* Invocation. */
private static final CallSiteDescriptor emptyCallSite = new CallSiteDescriptor(new byte[0], null);
private static final CallSiteDescriptor invocantCallSite = new CallSiteDescriptor(new byte[] { CallSiteDescriptor.ARG_OBJ }, null);
public static void invoke(ThreadContext tc, SixModelObject invokee, int callsiteIndex) throws Exception {
// If it's lexotic, throw the exception right off.
if (invokee instanceof Lexotic) {
Expand Down Expand Up @@ -962,7 +963,7 @@ public static void invoke(ThreadContext tc, SixModelObject invokee, int callsite
else
invokeInternal(tc, invokee, emptyCallSite);
}
private static void invokeInternal(ThreadContext tc, SixModelObject invokee, CallSiteDescriptor csd) throws Exception {
private static void invokeInternal(ThreadContext tc, SixModelObject invokee, CallSiteDescriptor csd) {
// Otherwise, get the code ref.
CodeRef cr;
if (invokee instanceof CodeRef) {
Expand All @@ -971,7 +972,7 @@ private static void invokeInternal(ThreadContext tc, SixModelObject invokee, Cal
else {
InvocationSpec is = invokee.st.InvocationSpec;
if (is == null)
throw new Exception("Can not invoke this object");
throw new RuntimeException("Can not invoke this object");
if (is.ClassHandle != null)
cr = (CodeRef)invokee.get_attribute_boxed(tc, is.ClassHandle, is.AttrName, is.Hint);
else
Expand Down Expand Up @@ -1005,7 +1006,7 @@ private static void invokeInternal(ThreadContext tc, SixModelObject invokee, Cal
if (cf.outer == null)
cf.outer = wanted.priorInvocation;
if (cf.outer == null)
throw new Exception("Could not locate an outer for code reference " +
throw new RuntimeException("Could not locate an outer for code reference " +
cr.staticInfo.uniqueId);
}
}
Expand Down Expand Up @@ -1549,6 +1550,10 @@ public static SixModelObject setboolspec(SixModelObject obj, long mode, SixModel
public static long istrue(SixModelObject obj, ThreadContext tc) {
BoolificationSpec bs = obj.st.BoolificationSpec;
switch (bs == null ? BoolificationSpec.MODE_NOT_TYPE_OBJECT : bs.Mode) {
case BoolificationSpec.MODE_CALL_METHOD:
tc.curFrame.oArg[0] = obj;
invokeInternal(tc, bs.Method, invocantCallSite);
return istrue(result_o(tc.curFrame), tc);
case BoolificationSpec.MODE_UNBOX_INT:
return obj instanceof TypeObject || obj.get_int(tc) == 0 ? 0 : 1;
case BoolificationSpec.MODE_UNBOX_NUM:
Expand Down

0 comments on commit 264c63b

Please sign in to comment.