Skip to content

Commit 6dc2a6f

Browse files
committed
num64/num32 truncate/extend coercion code-gen.
1 parent d1a15a1 commit 6dc2a6f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/vm/moar/QAST/QASTCompilerMAST.nqp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ my class MASTCompilerInstance {
428428
elsif $got == $MVM_reg_str {
429429
push_op($il, 'coerce_sn', $res_reg, $reg);
430430
}
431+
elsif $got == $MVM_reg_num32 {
432+
push_op($il, 'extend_n32', $res_reg, $reg);
433+
}
431434
elsif $got == $MVM_reg_void {
432435
push_op($il, 'const_n64', $res_reg, MAST::NVal.new( :value(0) ));
433436
}
@@ -449,6 +452,14 @@ my class MASTCompilerInstance {
449452
nqp::die("Unknown coercion case for str; got: "~$got);
450453
}
451454
}
455+
elsif $desired == $MVM_reg_num32 {
456+
if $got == $MVM_reg_num64 {
457+
push_op($il, 'trunc_n32', $res_reg, $reg);
458+
}
459+
else {
460+
nqp::die("Unknown coercion case for num32; got: "~$got);
461+
}
462+
}
452463
else {
453464
nqp::die("Coercion from type '$got' to '$desired' NYI");
454465
}

0 commit comments

Comments
 (0)