Skip to content

Commit

Permalink
Hide unbase/unbase_bracket by uppercasing them
Browse files Browse the repository at this point in the history
Since these are leaked to the PROCESS:: namespace, and not documented in the
spec, we should probably hide them by obscurity for now.
  • Loading branch information
lizmat committed Oct 1, 2014
1 parent 298e811 commit d60a8fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Perl6/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -5607,11 +5607,11 @@ class Perl6::Actions is HLL::Actions does STDActions {
method rad_number($/) {
my $radix := +($<radix>.Str);
if $<bracket> {
make QAST::Op.new(:name('&unbase_bracket'), :op('call'),
make QAST::Op.new(:name('&UNBASE_BRACKET'), :op('call'),
$*W.add_numeric_constant($/, 'Int', $radix), $<bracket>.ast);
}
elsif $<circumfix> {
make QAST::Op.new(:name('&unbase'), :op('call'),
make QAST::Op.new(:name('&UNBASE'), :op('call'),
$*W.add_numeric_constant($/, 'Int', $radix), $<circumfix>.ast);
} else {
my $intpart := $<intpart>.Str;
Expand Down
8 changes: 4 additions & 4 deletions src/core/Str.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1382,11 +1382,11 @@ sub trim-leading (Str:D $s) returns Str:D { $s.trim-leading }
sub trim-trailing(Str:D $s) returns Str:D { $s.trim-trailing }

# the opposite of Real.base, used for :16($hex_str)
proto sub unbase (|) { * }
multi sub unbase(Int:D $base, Cool:D $num) is hidden_from_backtrace {
proto sub UNBASE (|) { * }
multi sub UNBASE(Int:D $base, Cool:D $num) is hidden_from_backtrace {
X::Numeric::Confused.new(:what($num)).throw;
}
multi sub unbase(Int:D $base, Str:D $str) is hidden_from_backtrace {
multi sub UNBASE(Int:D $base, Str:D $str) is hidden_from_backtrace {
my Str $prefix = $str.substr(0, 2);
if $base <= 10 && $prefix eq any(<0x 0d 0o 0b>)
or $base <= 24 && $prefix eq any <0o 0x>
Expand All @@ -1399,7 +1399,7 @@ multi sub unbase(Int:D $base, Str:D $str) is hidden_from_backtrace {
}

# for :16[1, 2, 3]
sub unbase_bracket($base, @a) is hidden_from_backtrace {
sub UNBASE_BRACKET($base, @a) is hidden_from_backtrace {
my $v = 0;
my $denom = 1;
my Bool $seen-dot = False;
Expand Down

0 comments on commit d60a8fa

Please sign in to comment.