Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added nqp::seekfh on JVM.
  • Loading branch information
donaldh committed May 16, 2014
1 parent a438ec8 commit 0ea245b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/vm/jvm/QAST/Compiler.nqp
Expand Up @@ -1916,6 +1916,7 @@ QAST::OperationsJAST.map_classlib_core_op('getstdout', $TYPE_OPS, 'getstdout', [
QAST::OperationsJAST.map_classlib_core_op('getstderr', $TYPE_OPS, 'getstderr', [], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('setencoding', $TYPE_OPS, 'setencoding', [$RT_OBJ, $RT_STR], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('setinputlinesep', $TYPE_OPS, 'setinputlinesep', [$RT_OBJ, $RT_STR], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('seekfh', $TYPE_OPS, 'seekfh', [$RT_OBJ, $RT_INT, $RT_INT], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('tellfh', $TYPE_OPS, 'tellfh', [$RT_OBJ], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('readfh', $TYPE_OPS, 'readfh', [$RT_OBJ, $RT_OBJ, $RT_INT], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('writefh', $TYPE_OPS, 'writefh', [$RT_OBJ, $RT_OBJ], $RT_INT, :tc);
Expand Down
17 changes: 17 additions & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -476,6 +476,23 @@ public static SixModelObject setinputlinesep(SixModelObject obj, String sep, Thr
return obj;
}

public static SixModelObject seekfh(SixModelObject obj, long offset, long whence, ThreadContext tc) {
if (obj instanceof IOHandleInstance) {
IOHandleInstance h = (IOHandleInstance)obj;
if (h.handle instanceof IIOSeekable) {
((IIOSeekable)h.handle).seek(tc, offset, whence);
return obj;
}
else
throw ExceptionHandling.dieInternal(tc,
"This handle does not support seek");
}
else {
throw ExceptionHandling.dieInternal(tc,
"seekfh requires an object with the IOHandle REPR");
}
}

public static long tellfh(SixModelObject obj, ThreadContext tc) {
if (obj instanceof IOHandleInstance) {
IOHandleInstance h = (IOHandleInstance)obj;
Expand Down

0 comments on commit 0ea245b

Please sign in to comment.