Skip to content

Commit

Permalink
Add a .count method to Code objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Mar 9, 2009
1 parent 8bbc31c commit 2d5f157
Showing 1 changed file with 45 additions and 25 deletions.
70 changes: 45 additions & 25 deletions src/classes/Code.pir
Expand Up @@ -90,31 +90,6 @@ for executable objects.
.tailcall 'prefix:!'(match)
.end

=item perl()

Return a response to .perl.

=cut

.sub 'perl' :method
.return ('{ ... }')
.end

=item signature()

Gets the signature for the block, or returns Failure if it lacks one.

=cut

.sub 'signature' :method
$P0 = getprop '$!signature', self
if null $P0 goto no_sig
.return ($P0)
no_sig:
$P0 = get_hll_global 'Failure'
.return ($P0)
.end

=item assumming()

Returns a curried version of self.
Expand Down Expand Up @@ -144,6 +119,51 @@ Returns a curried version of self.
.return (result)
.end


=item count()

Return the number of required and optional parameters for a Block.
Note that we currently do this by adding the method to Parrot's
"Sub" PMC, so that it works for non-Rakudo subs.
=cut
.namespace ['Sub']
.sub 'count' :method
$P0 = inspect self, "pos_required"
$P1 = inspect self, "pos_optional"
add $P0, $P1
.return ($P0)
.end
=item perl()
Return a response to .perl.
=cut
.namespace ['Code']
.sub 'perl' :method
.return ('{ ... }')
.end
=item signature()
Gets the signature for the block, or returns Failure if it lacks one.
=cut
.sub 'signature' :method
$P0 = getprop '$!signature', self
if null $P0 goto no_sig
.return ($P0)
no_sig:
$P0 = get_hll_global 'Failure'
.return ($P0)
.end
=item !invoke
Currently we don't have an easy way to distinguish Regex objects
Expand Down

0 comments on commit 2d5f157

Please sign in to comment.