Source

pynie / src / builtins / oper.pir

=head1 NAME

src/builtins/oper.pir - operators

=head1 Functions

=over 4

=cut

.namespace []
.loadlib 'trans_ops'

.sub 'infix:=='
    .param pmc a
    .param pmc b
    $I0 = iseq a, b
    .return ($I0)
.end


.sub 'infix:!='
    .param pmc a
    .param pmc b
    $I0 = isne a, b
    .return ($I0)
.end


.sub 'infix:<='
    .param pmc a
    .param pmc b
    $I0 = isle a, b
    .return ($I0)
.end


.sub 'infix:>='
    .param pmc a
    .param pmc b
    $I0 = isge a, b
    .return ($I0)
.end


.sub 'infix:<'
    .param pmc a
    .param pmc b
    $I0 = islt a, b
    .return ($I0)
.end


.sub 'infix:>'
    .param pmc a
    .param pmc b
    $I0 = isgt a, b
    .return ($I0)
.end

.sub 'prefix:+'
    .param pmc n
    .return (n)
.end

.sub 'prefix:++'
    .param pmc n
    inc n
    .return (n)
.end

.sub 'prefix:--'
    .param pmc n
    dec n
    .return (n)
.end

.sub 'postfix:++'
    .param pmc n
    $P0 = clone n
    inc n
    .return ($P0)
.end

.sub 'postfix:--'
    .param pmc n
    $P0 = clone n
    dec n
    .return ($P0)
.end

.sub 'infix:^'
    .param int a
    .param int b
    $I0 = bxor a, b
    .return ($I0)
.end

.sub 'infix:&'
    .param int a
    .param int b
    $I0 = band a, b
    .return ($I0)
.end

.sub 'infix:|'
    .param int a
    .param int b
    $I0 = bor a, b
    .return ($I0)
.end


.sub 'sqrt'
    .param num n
    n = sqrt n
    .return (n)
.end


.sub 'scale'
    .param pmc n
    $S0 = n
    $I0 = index $S0, '.'
    if $I0 >= 0 goto nonzero
    .return (0)
  nonzero:
    $I1 = length $S0
    $I0 = $I1 - $I0
    dec $I0
    .return ($I0)
.end

.sub 'length'
    .param pmc n
    $S0 = n
    $I0 = length $S0
    $I1 = index $S0, '.'
    if $I1 < 0 goto integer
    dec $I0
  integer:
    .return ($I0)
.end

.sub 'saynum'
    .param pmc n
    print n
    print "\n"
.end

.sub 'infix:**'
    .param num a
    .param num b
    $N0 = pow a, b
    .return($N0)
.end

=back

=head1 AUTHOR

Patrick Michaud <pmichaud@pobox.com> is the current author and
maintainer.  Patches and suggestions can be sent to
<parrot-dev@lists.parrot.org> or <perl-compiler@perl.org> .

=cut

# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.