Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add nqp::isbig_I op, and nqp:: variants for bigint <-> str conversion
  • Loading branch information
moritz committed Nov 11, 2011
1 parent caacd56 commit 05d6ab2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/PAST/NQP.pir
Expand Up @@ -561,6 +561,11 @@ entry to produce the node to be returned.
maphash['isgt_s'] = 'isgt__Iss'
maphash['isge_s'] = 'isge__Iss'

# bigint ops
maphash['fromstr_I'] = 'nqp_bigint_from_str__PPs'
maphash['tostr_I'] = 'nqp_bigint_to_str__SP'
maphash['isbig_I'] = 'nqp_bigint_is_big__IP'

# boolean opcodes
maphash['not_i'] = 'not__Ii'

Expand Down
6 changes: 6 additions & 0 deletions src/ops/nqp_bigint.ops
Expand Up @@ -379,3 +379,9 @@ inline op nqp_bigint_pow(out PMC, in PMC, in PMC, in PMC) :base_core {
}
}

/* returns 1 if $2 is too large to fit into an INTVAL without loss of
information */
inline op nqp_bigint_is_big(out INT, in PMC) :base_core {
mp_int *a = get_bigint(interp, $2);
$1 = a->used > 1;
}
2 changes: 0 additions & 2 deletions t/nqp/60-bigint.t
Expand Up @@ -3,8 +3,6 @@ use nqpmo;

plan(22);

pir::nqp_bigint_setup__v();

my $knowhow := pir::get_knowhow__P();
my $bi_type := $knowhow.new_type(:name('TestBigInt'), :repr('P6bigint'));
$bi_type.HOW.compose($bi_type);
Expand Down

0 comments on commit 05d6ab2

Please sign in to comment.