Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added bigint conversion op

  • Loading branch information...
commit 6f1b074724a3b28a354ef695538d5b1dc84d75bb 1 parent 7179ed3
Carl Mäsak masak authored
Showing with 19 additions and 2 deletions.
  1. +3 −1 src/QAST/Compiler.nqp
  2. +1 −0  src/QAST/Operations.nqp
  3. +15 −1 t/qast/qast.t
4 src/QAST/Compiler.nqp
View
@@ -231,7 +231,9 @@ class QAST::Compiler is HLL::Compiler {
if nqp::substr($inferee, 0, 1) eq '$' {
nqp::substr($inferee, 1, 1)
}
- elsif nqp::substr($inferee, 0, 6) eq 'utf8:"' || nqp::substr($inferee, 0, 6) eq 'ucs4:"' {
+ elsif nqp::substr($inferee, 0, 6) eq 'utf8:"'
+ || nqp::substr($inferee, 0, 6) eq 'ucs4:"'
+ || nqp::substr($inferee, 0, 1) eq '"' {
"s"
}
elsif nqp::index($inferee, ".", 0) > 0 {
1  src/QAST/Operations.nqp
View
@@ -179,3 +179,4 @@ for <if unless> -> $op_name {
# Straight mappings to Parrot opcodes.
QAST::Operations.add_core_pirop_mapping('add_i', 'add', 'Iii');
QAST::Operations.add_core_pirop_mapping('neg_i', 'neg', 'Ii');
+QAST::Operations.add_core_pirop_mapping('fromstr_I', 'nqp_bigint_from_str', 'PsP');
16 t/qast/qast.t
View
@@ -1,6 +1,6 @@
use QRegex;
-plan(15);
+plan(16);
# Following a test infrastructure.
sub compile_qast($qast) {
@@ -173,3 +173,17 @@ is_qast(
2,
'unless with IVal');
+class MyBigInt is repr('P6bigint') { }
+
+test_qast_result(
+ QAST::Block.new(
+ QAST::Op.new(
+ :op('fromstr_I'),
+ QAST::SVal.new(:value('-42')),
+ QAST::WVal.new(:value(MyBigInt))
+ )
+ ),
+ -> $r {
+ ok(nqp::unbox_i($r) == -42, 'bigint conversion roundtrips');
+ });
+
Please sign in to comment.
Something went wrong with that request. Please try again.