Skip to content

Commit 9ab48a0

Browse files
committed
Implement nqp::throw.
1 parent 4b6519a commit 9ab48a0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ QAST::OperationsJAST.map_classlib_core_op('getmessage', $TYPE_OPS, 'getmessage',
15551555
QAST::OperationsJAST.map_classlib_core_op('setmessage', $TYPE_OPS, 'setmessage', [$RT_OBJ, $RT_STR], $RT_STR, :tc);
15561556
QAST::OperationsJAST.map_classlib_core_op('newexception', $TYPE_OPS, 'newexception', [], $RT_OBJ, :tc);
15571557
QAST::OperationsJAST.map_classlib_core_op('backtracestrings', $TYPE_OPS, 'backtracestrings', [$RT_OBJ], $RT_OBJ, :tc);
1558-
QAST::OperationsJAST.map_classlib_core_op('throw', $TYPE_OPS, 'throw', [$RT_OBJ], $RT_OBJ, :tc);
1558+
QAST::OperationsJAST.map_classlib_core_op('throw', $TYPE_OPS, '_throw', [$RT_OBJ], $RT_OBJ, :tc);
15591559
QAST::OperationsJAST.map_classlib_core_op('rethrow', $TYPE_OPS, 'rethrow', [$RT_OBJ], $RT_OBJ, :tc);
15601560
QAST::OperationsJAST.map_classlib_core_op('resume', $TYPE_OPS, 'resume', [$RT_OBJ], $RT_OBJ, :tc);
15611561
my %handler_names := nqp::hash(

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3239,6 +3239,16 @@ public static SixModelObject backtracestrings(SixModelObject obj, ThreadContext
32393239
throw ExceptionHandling.dieInternal(tc, "backtracestring needs an object with VMException representation");
32403240
}
32413241
}
3242+
public static SixModelObject _throw(SixModelObject obj, ThreadContext tc) {
3243+
if (obj instanceof VMExceptionInstance) {
3244+
VMExceptionInstance ex = (VMExceptionInstance)obj;
3245+
ex.origin = tc.curFrame;
3246+
return ExceptionHandling.handlerDynamic(tc, ex.category, ex);
3247+
}
3248+
else {
3249+
throw ExceptionHandling.dieInternal(tc, "throw needs an object with VMException representation");
3250+
}
3251+
}
32423252
public static SixModelObject rethrow(SixModelObject obj, ThreadContext tc) {
32433253
if (obj instanceof VMExceptionInstance) {
32443254
VMExceptionInstance ex = (VMExceptionInstance)obj;

0 commit comments

Comments
 (0)