Skip to content

Commit

Permalink
Move chr and ord methods to the setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
cspencer committed Apr 18, 2009
1 parent 616c0b7 commit f2c5829
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
13 changes: 1 addition & 12 deletions src/builtins/any-num.pir
Expand Up @@ -21,7 +21,7 @@ the size of that file down and to emphasize their generic,
.namespace []
.sub 'onload' :anon :init :load
$P0 = get_hll_namespace ['Any']
'!EXPORT'('abs,int,log,chr,polar,sqrt,truncate,unpolar', 'from'=>$P0)
'!EXPORT'('abs,int,log,polar,sqrt,truncate,unpolar', 'from'=>$P0)

## pre-seed a random number generator
$P0 = new 'Random'
Expand All @@ -41,18 +41,7 @@ the size of that file down and to emphasize their generic,
.return ($N1)
.end

=item chr()

=cut

.namespace ['Any']
.sub 'chr' :method :multi(_)
$I0 = self
$S0 = chr $I0
.return ($S0)
.end


.sub 'int' :method :multi(_)
.tailcall self.'truncate'()
.end
Expand Down
14 changes: 1 addition & 13 deletions src/builtins/any-str.pir
Expand Up @@ -23,7 +23,7 @@ the size of that file down and to emphasize their generic,
.namespace []
.sub 'onload' :anon :init :load
$P0 = get_hll_namespace ['Any']
'!EXPORT'('chomp,chars,:d,:e,:f,index,rindex,ord,substr', 'from'=>$P0)
'!EXPORT'('chomp,chars,:d,:e,:f,index,rindex,substr', 'from'=>$P0)
.end
Expand Down Expand Up @@ -848,18 +848,6 @@ Partial implementation. The :g modifier on regexps doesn't work, for example.
die "Must pass a non-negative integer to :x()"
.end


=item ord()

=cut

.namespace ['Any']
.sub 'ord' :method :multi(_)
$S0 = self
$I0 = ord $S0
.return ($I0)
.end

# Local Variables:
# mode: pir
# fill-column: 100
Expand Down
8 changes: 8 additions & 0 deletions src/setting/Any-num.pm
Expand Up @@ -7,6 +7,14 @@ class Any is also {
}
}
our Str multi method chr() is export {
Q:PIR {
$I0 = self
$S0 = chr $I0
%r = box $S0
}
}

our Complex multi method cis() is export {
(1.0).unpolar(self)
}
Expand Down
8 changes: 8 additions & 0 deletions src/setting/Any-str.pm
Expand Up @@ -23,6 +23,14 @@ class Any is also {
self gt '' ?? self.substr(0,1).lc ~ self.substr(1) !! ""
}
our Int multi method ord() is export {
Q:PIR {
$S0 = self
$I0 = ord $S0
%r = box $I0
}
}

our Int multi method p5chomp is export(:P5) {
my $num = 0;

Expand Down

0 comments on commit f2c5829

Please sign in to comment.