Skip to content

Commit f0c299b

Browse files
committed
Some preparations to support bind lowering on JVM.
1 parent 82cd0cb commit f0c299b

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3229,7 +3229,7 @@ class QAST::CompilerJAST {
32293229
# Look for one required positional case. Methods with no params
32303230
# beyond the invocant are always this.
32313231
my $param := $block.params[0];
3232-
if !$param.named && !$param.slurpy && !$param.default {
3232+
if !$param.named && !$param.slurpy && !$param.default && !$param.list {
32333233
if nqp::objprimspec($param.returns) == 0 {
32343234
$jmeth.add_argument('__arg_0', $TYPE_SMO);
32353235
$il.append(JAST::Instruction.new( :op('aload'), '__arg_0' ));
@@ -3257,7 +3257,7 @@ class QAST::CompilerJAST {
32573257
elsif $num_params == 2 {
32583258
my $is_obj_obj := 1;
32593259
for $block.params {
3260-
if $_.named || $_.slurpy || $_.default || nqp::objprimspec($_.returns) != 0 {
3260+
if $_.named || $_.slurpy || $_.default || nqp::objprimspec($_.returns) != 0 || $_.list {
32613261
$is_obj_obj := 0;
32623262
last;
32633263
}
@@ -3477,6 +3477,29 @@ class QAST::CompilerJAST {
34773477
'bindlex_' ~ typechar($type), $jtype, $jtype, $TYPE_CF, 'Integer' ));
34783478
$il.append(pop_ins($type));
34793479
}
3480+
3481+
# Emit any additional tasks and typechecks.
3482+
for $_.list {
3483+
my $*BLOCK := $block;
3484+
if nqp::istype($_, QAST::ParamTypeCheck) {
3485+
my $lbl := JAST::Label.new( :name(self.unique("tc_ok")) );
3486+
my $tc := self.as_jast($_[0], :want($RT_INT));
3487+
$il.append($tc.jast);
3488+
$*STACK.obtain($il, $tc);
3489+
$il.append($L2I);
3490+
$il.append(JAST::Instruction.new( :op('ifne'), $lbl ));
3491+
$il.append(JAST::Instruction.new( :op('aload'), 'tc' ));
3492+
$il.append(JAST::Instruction.new( :op('invokestatic'), $TYPE_OPS,
3493+
"paramcheckassertfail", 'V', $TYPE_TC ));
3494+
$il.append($lbl);
3495+
}
3496+
else {
3497+
my $task := self.as_jast($_, :want($RT_VOID));
3498+
$il.append($task.jast);
3499+
$*STACK.obtain($il, $task);
3500+
}
3501+
}
3502+
34803503
$param_idx++;
34813504
}
34823505
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,11 @@ public static SixModelObject namedslurpy(ThreadContext tc, CallFrame cf, CallSit
16851685

16861686
return result;
16871687
}
1688+
1689+
/* Bind error reporting. */
1690+
public static void paramcheckassertfail(ThreadContext tc) {
1691+
throw ExceptionHandling.dieInternal(tc, "Parameter check assert failed; error generation NYI");
1692+
}
16881693

16891694
/* Return value setting. */
16901695
public static void return_o(SixModelObject v, CallFrame cf) {

0 commit comments

Comments
 (0)