Skip to content

Commit

Permalink
Implement some missing capture-related ops.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Apr 29, 2013
1 parent 92db4a1 commit 8a230e7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/vm/jvm/QAST/Compiler.nqp
Expand Up @@ -1517,6 +1517,8 @@ QAST::OperationsJAST.map_classlib_core_op('captureposarg_i', $TYPE_OPS, 'capture
QAST::OperationsJAST.map_classlib_core_op('captureposarg_n', $TYPE_OPS, 'captureposarg_n', [$RT_OBJ, $RT_INT], $RT_NUM, :tc);
QAST::OperationsJAST.map_classlib_core_op('captureposarg_s', $TYPE_OPS, 'captureposarg_s', [$RT_OBJ, $RT_INT], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('captureposprimspec', $TYPE_OPS, 'captureposprimspec', [$RT_OBJ, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('captureexistsnamed', $TYPE_OPS, 'captureexistsnamed', [$RT_OBJ, $RT_STR], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('capturehasnameds', $TYPE_OPS, 'capturehasnameds', [$RT_OBJ], $RT_INT, :tc);

# Multiple dispatch related.
QAST::OperationsJAST.map_classlib_core_op('invokewithcapture', $TYPE_OPS, 'invokewithcapture', [$RT_OBJ, $RT_OBJ], $RT_OBJ, :tc);
Expand Down
Expand Up @@ -36,7 +36,7 @@ public class CallSiteDescriptor {
public boolean hasFlattening = false;

/* Original names list. */
private String[] names;
public String[] names;

public CallSiteDescriptor(byte[] flags, String[] names) {
argFlags = flags;
Expand Down
18 changes: 18 additions & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -1190,6 +1190,24 @@ public static SixModelObject captureposarg(SixModelObject obj, long idx, ThreadC
throw ExceptionHandling.dieInternal(tc, "captureposarg requires a CallCapture");
}
}
public static long captureexistsnamed(SixModelObject obj, String name, ThreadContext tc) {
if (obj instanceof CallCaptureInstance) {
CallCaptureInstance cc = (CallCaptureInstance)obj;
return cc.descriptor.nameMap.containsKey(name) ? 1 : 0;
}
else {
throw ExceptionHandling.dieInternal(tc, "capturehasnameds requires a CallCapture");
}
}
public static long capturehasnameds(SixModelObject obj, ThreadContext tc) {
if (obj instanceof CallCaptureInstance) {
CallCaptureInstance cc = (CallCaptureInstance)obj;
return cc.descriptor.names == null ? 0 : 1;
}
else {
throw ExceptionHandling.dieInternal(tc, "capturehasnameds requires a CallCapture");
}
}

/* Invocation. */
public static final CallSiteDescriptor emptyCallSite = new CallSiteDescriptor(new byte[0], null);
Expand Down

0 comments on commit 8a230e7

Please sign in to comment.