Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:rakudo/rakudo
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Feb 25, 2010
2 parents cf150fc + d798874 commit b3fcd6c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 5 deletions.
16 changes: 16 additions & 0 deletions src/core/Any-list.pm
Expand Up @@ -171,6 +171,20 @@ augment class Any {
take $value;
}
}

multi method keys() {
my $i = 0;
gather for $.list -> $value {
my $key = $i++;
take $key;
}
}

multi method values() {
gather for $.list -> $value {
take $value;
}
}
}

our proto sub join (Str $separator = '', *@values) { @values.join($separator); }
Expand All @@ -185,5 +199,7 @@ our proto sub uniq(@values) { @values.uniq; }
our proto sub pick ($num, :$replace, *@values) { @values.pick($num, :$replace); }
our proto sub map(&mapper, @values) { @values.map(&mapper); }
our proto sub kv(@array) { @array.kv; }
our proto sub keys(@array) { @array.keys; }
our proto sub values(@array) { @array.values; }

# vim: ft=perl6
15 changes: 15 additions & 0 deletions src/core/Any-str.pm
Expand Up @@ -218,6 +218,18 @@ augment class Any {
our Str multi method ucfirst() is export {
self gt '' ?? self.substr(0,1).uc ~ self.substr(1) !! ""
}

our Str multi method sprintf(*@args) {
my $result;
try {
$result = pir::sprintf__SSP(~self, (|@args)!PARROT_POSITIONALS);
}
$! ?? fail( "Insufficient arguments supplied to sprintf") !! $result
}

method Str() {
self
}
}

our multi sub ord($string) {
Expand Down Expand Up @@ -252,5 +264,8 @@ our multi split ( Regex $delimiter, Str $input, Int $limit = * ) {
$input.split($delimiter, $limit);
}

our multi sub sprintf($str as Str, *@args) {
$str.sprintf(|@args)
}

# vim: ft=perl6
28 changes: 27 additions & 1 deletion src/glue/run.pir
Expand Up @@ -9,7 +9,10 @@ src/glue/run.pir - code to initiate execution of a Perl 6 program
=item !UNIT_START(mainline, args)

Invoke the code given by mainline, using C<args> as the initial
(command-line) arguments.
(command-line) arguments. The method C<comp_unit($/)> in
F<Perl6/Actions.pm> generates two calls to this sub, one for
executables and one for libraries, and pushes them into the AST
of the compilation unit.

=cut

Expand All @@ -18,6 +21,29 @@ Invoke the code given by mainline, using C<args> as the initial
.param pmc mainline
.param pmc args :slurpy

# Ignore the args when executed as a library (not main program)
unless args goto unit_start_0

# args is a ResizablePMCArray containing only one entry
# args[0] is also a ResizablePMCArray, of String entries, containing
# the program name or '-e' in args[0][0], followed by
# optional command line arguments in args[0][1] etc.
$P0 = args[0]
# Ignore the args when executed as a library (not main program)
unless $P0 goto unit_start_0

# The first args string belongs in $*PROGRAM_NAME
$P1 = shift $P0 # the first arg is the program name
set_hll_global '$PROGRAM_NAME', $P1

# The remaining args strings belong in @*ARGS
$P1 = new ['Parcel']
splice $P1, $P0, 0, 0
$P2 = new ['Array']
$P2.'!STORE'($P1)
set_hll_global '@ARGS', $P2
unit_start_0:

# INIT time
'!fire_phasers'('INIT')
$P0 = mainline()
Expand Down
15 changes: 15 additions & 0 deletions src/pmc/perl6multisub.pmc
Expand Up @@ -1162,6 +1162,21 @@ Makes a copy of this Perl6MultiSub PMC.
return copy;
}


/*

=item METHOD PMC * clone()

Makes a copy of this Perl6MultiSub PMC.

=cut

*/
METHOD PMC * clone() {
PMC *copy = VTABLE_clone(interp, SELF);
RETURN (PMC *copy);
}

/*

=item VTABLE STRING * get_string()
Expand Down
8 changes: 4 additions & 4 deletions t/spectest.data
Expand Up @@ -92,13 +92,13 @@ S02-literals/underscores.t
# S02-magicals/dollar_bang.t
# S02-magicals/dollar-underscore.t
# S02-magicals/env.t
# S02-magicals/progname.t
S02-magicals/progname.t
S02-names_and_variables/contextual.t
# S02-names_and_variables/fmt.t
# S02-names_and_variables/names.t
# S02-names_and_variables/perl.t
S02-names_and_variables/list_array_perl.t
# S02-names_and_variables/varnames.t
S02-names_and_variables/varnames.t
S02-names/identifier.t
# S02-names/our.t
# S02-one-pass-parsing/less-than.t
Expand Down Expand Up @@ -417,7 +417,7 @@ S29-conversions/ord_and_chr.t #icu
S32-array/elems.t
S32-array/end.t
# S32-array/exists.t
# S32-array/keys_values.t
S32-array/keys_values.t
S32-array/kv.t
# S32-array/pairs.t
S32-array/pop.t
Expand Down Expand Up @@ -484,7 +484,7 @@ S32-str/pos.t
# S32-str/split-simple.t
S32-str/split-simple2.t # CHEAT! simplified version of split-simple.t
# S32-str/split.t
# S32-str/sprintf.t
S32-str/sprintf.t
# S32-str/substr.t
S32-str/trim.t
S32-str/ucfirst.t
Expand Down

0 comments on commit b3fcd6c

Please sign in to comment.