Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move !op implementation functions from assign.pir to new metaops.pir.
  • Loading branch information
colomon committed Mar 15, 2010
1 parent 3bc40d3 commit ef3cd20
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
1 change: 1 addition & 0 deletions build/Makefile.in
Expand Up @@ -130,6 +130,7 @@ BUILTINS_PIR = \
src/builtins/Junction.pir \
src/builtins/Capture.pir \
src/builtins/assign.pir \
src/builtins/metaops.pir \
src/builtins/control.pir \

# Make sure parrot cheats are last in this list.
Expand Down
27 changes: 0 additions & 27 deletions src/builtins/assign.pir
Expand Up @@ -89,33 +89,6 @@ src/builtins/assign.pir - assignment operations
.tailcall '&infix:<=>'(a, $P1)
.end

.sub '!gen_not_metaop'
.param string sym
.local string opname, metaname
$S0 = concat sym, '>'
opname = concat '&infix:<', $S0
metaname = concat '&infix:<!', $S0
$P0 = get_global metaname
unless null $P0 goto done
$P1 = box opname
.lex '$opname', $P1
.const 'Sub' metasub = '!not_metaop'
$P0 = newclosure metasub
set_global metaname, $P0
done:
.end

# XXX -- we might want this to be a Perl6MultiSub
.sub '!not_metaop' :anon :outer('!gen_not_metaop')
.param pmc a
.param pmc b
$P0 = find_lex '$opname'
$S0 = $P0
$P0 = get_global $S0
$P1 = $P0(a, b)
.tailcall '&prefix:<!>'($P1)
.end

# Local Variables:
# mode: pir
# fill-column: 100
Expand Down
42 changes: 42 additions & 0 deletions src/builtins/metaops.pir
@@ -0,0 +1,42 @@
=head1 NAME

src/builtins/metaops.pir - meta-op operations

=head1 Functions

=over 2

=cut

.sub '!gen_not_metaop'
.param string sym
.local string opname, metaname
$S0 = concat sym, '>'
opname = concat '&infix:<', $S0
metaname = concat '&infix:<!', $S0
$P0 = get_global metaname
unless null $P0 goto done
$P1 = box opname
.lex '$opname', $P1
.const 'Sub' metasub = '!not_metaop'
$P0 = newclosure metasub
set_global metaname, $P0
done:
.end

# XXX -- we might want this to be a Perl6MultiSub
.sub '!not_metaop' :anon :outer('!gen_not_metaop')
.param pmc a
.param pmc b
$P0 = find_lex '$opname'
$S0 = $P0
$P0 = get_global $S0
$P1 = $P0(a, b)
.tailcall '&prefix:<!>'($P1)
.end

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

0 comments on commit ef3cd20

Please sign in to comment.