<commit_before>## $Id$

=head1 TITLE

Num - Perl 6 numbers

=head1 SUBROUTINES

=over 4

=item onload()

=cut

.namespace [ 'Num' ]

.sub 'onload' :anon :init :load
    .local pmc p6meta, numproto
    p6meta = get_hll_global ['Perl6Object'], '$!P6META'
    numproto = p6meta.'new_class'('Num', 'parent'=>'parrot;Float Any')
    numproto.'!IMMUTABLE'()
    p6meta.'register'('Float', 'parent'=>numproto, 'protoobject'=>numproto)

    # Override the proto's ACCEPT method so we also accept Ints.
    .const 'Sub' $P0 = "Num::ACCEPTS"
    $P1 = typeof numproto
    $P1.'add_method'('ACCEPTS', $P0)
.end


.sub 'Num::ACCEPTS' :anon :method
    .param pmc topic

    ##  first, try our superclass .ACCEPTS
    $P0 = get_hll_global 'Any'
    $P1 = find_method $P0, 'ACCEPTS'
    $I0 = self.$P1(topic)
    unless $I0 goto try_int
    .return ($I0)

  try_int:
    $P0 = get_hll_global 'Int'
    $I0 = $P0.'ACCEPTS'(topic)
    .return ($I0)
.end


=item ACCEPTS()

=cut

.sub 'ACCEPTS' :method
    .param num topic
    $S0 = self
    if $S0 == 'NaN' goto test_nan
    .tailcall 'infix:=='(topic, self)
  test_nan:
    $S0 = topic
    $I0 = iseq $S0, 'NaN'
    .tailcall 'prefix:?'($I0)
.end


=item succ and pred

Increment and Decrement Methods

=cut

.sub 'pred' :method
    $P0 = clone self
    dec $P0
    .return ($P0)
.end

.sub 'succ' :method
    $P0 = clone self
    inc $P0
    .return ($P0)
.end


=item WHICH()

Returns the identify value.

=cut

.sub 'WHICH' :method
    $N0 = self
    .return ($N0)
.end


=item infix:===

Overridden for Num.

=cut

.namespace []
.sub 'infix:===' :multi(Float,Float)
    .param num a
    .param num b
    .tailcall 'infix:=='(a, b)
.end


=back

=cut

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
<commit_msg>Clean up Num.succ and Num.pred, which were infinite looping.<commit_after>## $Id$

=head1 TITLE

Num - Perl 6 numbers

=head1 SUBROUTINES

=over 4

=item onload()

=cut

.namespace [ 'Num' ]

.sub 'onload' :anon :init :load
    .local pmc p6meta, numproto
    p6meta = get_hll_global ['Perl6Object'], '$!P6META'
    numproto = p6meta.'new_class'('Num', 'parent'=>'parrot;Float Any')
    numproto.'!IMMUTABLE'()
    p6meta.'register'('Float', 'parent'=>numproto, 'protoobject'=>numproto)

    # Override the proto's ACCEPT method so we also accept Ints.
    .const 'Sub' $P0 = "Num::ACCEPTS"
    $P1 = typeof numproto
    $P1.'add_method'('ACCEPTS', $P0)
.end


.sub 'Num::ACCEPTS' :anon :method
    .param pmc topic

    ##  first, try our superclass .ACCEPTS
    $P0 = get_hll_global 'Any'
    $P1 = find_method $P0, 'ACCEPTS'
    $I0 = self.$P1(topic)
    unless $I0 goto try_int
    .return ($I0)

  try_int:
    $P0 = get_hll_global 'Int'
    $I0 = $P0.'ACCEPTS'(topic)
    .return ($I0)
.end


=item ACCEPTS()

=cut

.sub 'ACCEPTS' :method
    .param num topic
    $S0 = self
    if $S0 == 'NaN' goto test_nan
    .tailcall 'infix:=='(topic, self)
  test_nan:
    $S0 = topic
    $I0 = iseq $S0, 'NaN'
    .tailcall 'prefix:?'($I0)
.end


=item succ and pred

Increment and Decrement Methods

=cut

.sub 'pred' :method
    $N0 = self
    dec $N0
    .return ($N0)
.end

.sub 'succ' :method
    $N0 = self
    inc $N0
    .return ($N0)
.end


=item WHICH()

Returns the identify value.

=cut

.sub 'WHICH' :method
    $N0 = self
    .return ($N0)
.end


=item infix:===

Overridden for Num.

=cut

.namespace []
.sub 'infix:===' :multi(Float,Float)
    .param num a
    .param num b
    .tailcall 'infix:=='(a, b)
.end


=back

=cut

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:

{'fraction_non_alphanumeric': 0.15883484473756526, 'fraction_numerical': 0.023632866172025282, 'mean_word_length': 2.872340425531915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1735025', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1516, 'n_words': 410}