[svn:parrot] r46849 - branches/ops_pct/ext/nqp-rx/src/stage0
cotto at svn.parrot.org
cotto at svn.parrot.org
Fri May 21 08:47:19 UTC 2010
Author: cotto
Date: Fri May 21 08:47:19 2010
New Revision: 46849
URL: https://trac.parrot.org/parrot/changeset/46849
Log:
[nqp] move nqp-setting.pm to nqp-setting.nqp
Added:
branches/ops_pct/ext/nqp-rx/src/stage0/nqp-setting.nqp
- copied unchanged from r46848, branches/ops_pct/ext/nqp-rx/src/stage0/nqp-setting.pm
Deleted:
branches/ops_pct/ext/nqp-rx/src/stage0/nqp-setting.pm
Copied: branches/ops_pct/ext/nqp-rx/src/stage0/nqp-setting.nqp (from r46848, branches/ops_pct/ext/nqp-rx/src/stage0/nqp-setting.pm)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/ops_pct/ext/nqp-rx/src/stage0/nqp-setting.nqp Fri May 21 08:47:19 2010 (r46849, copy of r46848, branches/ops_pct/ext/nqp-rx/src/stage0/nqp-setting.pm)
@@ -0,0 +1,233 @@
+
+# This file automatically generated by build/gen_setting.pl.
+
+# From src/setting/ResizablePMCArray.pm
+
+#! nqp
+
+=begin
+
+ResizablePMCArray Methods
+
+These methods extend Parrot's ResizablePMCArray type to include
+more methods typical of Perl 6 lists and arrays.
+
+=end
+
+module ResizablePMCArray {
+
+ =begin item join
+ Return all elements joined by $sep.
+ =end item
+
+ method join ($separator) {
+ pir::join($separator, self);
+ }
+
+ =begin item map
+ Return an array with the results of applying C<&code> to
+ each element of the invocant. Note that NQP doesn't have
+ a flattening list context, so the number of elements returned
+ is exactly the same as the original.
+ =end item
+
+ method map (&code) {
+ my @mapped;
+ for self { @mapped.push( &code($_) ); }
+ @mapped;
+ }
+
+ =begin item reverse
+ Return a reversed copy of the invocant.
+ =end item
+
+ method reverse () {
+ my @reversed;
+ for self { @reversed.unshift($_); }
+ @reversed;
+ }
+}
+
+
+sub join ($separator, *@values) { @values.join($separator); }
+sub map (&code, *@values) { @values.map(&code); }
+sub list (*@values) { @values; }
+
+# vim: ft=perl6
+# From src/setting/Hash.pm
+
+#! nqp
+
+=begin
+
+Hash methods and functions
+
+These methods extend Parrot's Hash type to include more
+methods typical of Perl 6 hashes.
+
+=end
+
+module Hash {
+
+ =begin item delete
+ Delete C<$key> from the hash.
+ =end item
+
+ method delete($key) {
+ Q:PIR {
+ $P1 = find_lex '$key'
+ delete self[$P1]
+ }
+ }
+
+
+ =begin item exists
+ Returns true if C<$key> exists in the hash.
+ =end item
+
+ method exists($key) {
+ Q:PIR {
+ $P1 = find_lex '$key'
+ $I0 = exists self[$P1]
+ %r = box $I0
+ }
+ }
+
+
+ =begin item keys
+ Returns a list of all of the keys in the hash.
+ =end item
+
+ method keys () {
+ my @keys;
+ for self { @keys.push($_.key); }
+ @keys;
+ }
+
+
+ =begin item kv
+ Return a list of key, value, key, value, ...
+ =end item
+
+ method kv () {
+ my @kv;
+ for self { @kv.push($_.key); @kv.push($_.value); }
+ @kv;
+ }
+
+
+ =begin item values
+ Returns a list of all of the values in the hash.
+ =end item
+
+ method values () {
+ my @values;
+ for self { @values.push($_.value); }
+ @values;
+ }
+
+}
+
+
+=begin item hash
+Construct a hash from named arguments.
+=end item
+
+sub hash(*%h) { %h }
+
+# vim: ft=perl6
+# From src/setting/Regex.pm
+
+#! nqp
+
+=begin
+
+Regex methods and functions
+
+=end
+
+=begin item match
+Match C<$text> against C<$regex>. If the C<$global> flag is
+given, then return an array of all non-overlapping matches.
+=end item
+
+sub match ($text, $regex, :$global?) {
+ my $match := $text ~~ $regex;
+ if $global {
+ my @matches;
+ while $match {
+ @matches.push($match);
+ $match := $match.CURSOR.parse($text, :rule($regex), :c($match.to));
+ }
+ @matches;
+ }
+ else {
+ $match;
+ }
+}
+
+
+=begin item subst
+Substitute an match of C<$regex> in C<$text> with C<$replacement>,
+returning the substituted string. If C<$global> is given, then
+perform the replacement on all matches of C<$text>.
+=end item
+
+sub subst ($text, $regex, $repl, :$global?) {
+ my @matches := $global ?? match($text, $regex, :global)
+ !! [ $text ~~ $regex ];
+ my $is_code := pir::isa($repl, 'Sub');
+ my $offset := 0;
+ my @pieces;
+
+ for @matches -> $match {
+ my $repl_string := $is_code ?? $repl($match) !! $repl;
+ @pieces.push( pir::substr($text, $offset, $match.from - $offset))
+ if $match.from > $offset;
+ @pieces.push($repl_string);
+ $offset := $match.to;
+ }
+
+ my $chars := pir::length($text);
+ @pieces.push(pir::substr($text, $offset, $chars))
+ if $chars > $offset;
+
+ @pieces.join('');
+}
+
+# vim: ft=perl6
+# From src/setting/IO.pm
+
+#! nqp
+
+=begin
+
+IO Methods and Functions
+
+=end
+
+=begin item slurp
+Returns the contents of C<$filename> as a single string.
+=end
+
+sub slurp ($filename) {
+ my $handle := pir::open__Pss($file, 'r');
+ my $contents := $handle.readall;
+ pir::close($handle);
+ $contents;
+}
+
+
+=begin item spew
+Write the string value of C<$contents> to C<$filename>.
+=end item
+
+sub spew($filename, $contents) {
+ my $handle := pir::open__Pss($filename, 'w');
+ $handle.print($contents);
+ pir::close($handle);
+}
+
+# vim: ft=perl6
+
+# vim: set ft=perl6 nomodifiable :
Deleted: branches/ops_pct/ext/nqp-rx/src/stage0/nqp-setting.pm
==============================================================================
--- branches/ops_pct/ext/nqp-rx/src/stage0/nqp-setting.pm Fri May 21 08:47:19 2010 (r46848)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,233 +0,0 @@
-
-# This file automatically generated by build/gen_setting.pl.
-
-# From src/setting/ResizablePMCArray.pm
-
-#! nqp
-
-=begin
-
-ResizablePMCArray Methods
-
-These methods extend Parrot's ResizablePMCArray type to include
-more methods typical of Perl 6 lists and arrays.
-
-=end
-
-module ResizablePMCArray {
-
- =begin item join
- Return all elements joined by $sep.
- =end item
-
- method join ($separator) {
- pir::join($separator, self);
- }
-
- =begin item map
- Return an array with the results of applying C<&code> to
- each element of the invocant. Note that NQP doesn't have
- a flattening list context, so the number of elements returned
- is exactly the same as the original.
- =end item
-
- method map (&code) {
- my @mapped;
- for self { @mapped.push( &code($_) ); }
- @mapped;
- }
-
- =begin item reverse
- Return a reversed copy of the invocant.
- =end item
-
- method reverse () {
- my @reversed;
- for self { @reversed.unshift($_); }
- @reversed;
- }
-}
-
-
-sub join ($separator, *@values) { @values.join($separator); }
-sub map (&code, *@values) { @values.map(&code); }
-sub list (*@values) { @values; }
-
-# vim: ft=perl6
-# From src/setting/Hash.pm
-
-#! nqp
-
-=begin
-
-Hash methods and functions
-
-These methods extend Parrot's Hash type to include more
-methods typical of Perl 6 hashes.
-
-=end
-
-module Hash {
-
- =begin item delete
- Delete C<$key> from the hash.
- =end item
-
- method delete($key) {
- Q:PIR {
- $P1 = find_lex '$key'
- delete self[$P1]
- }
- }
-
-
- =begin item exists
- Returns true if C<$key> exists in the hash.
- =end item
-
- method exists($key) {
- Q:PIR {
- $P1 = find_lex '$key'
- $I0 = exists self[$P1]
- %r = box $I0
- }
- }
-
-
- =begin item keys
- Returns a list of all of the keys in the hash.
- =end item
-
- method keys () {
- my @keys;
- for self { @keys.push($_.key); }
- @keys;
- }
-
-
- =begin item kv
- Return a list of key, value, key, value, ...
- =end item
-
- method kv () {
- my @kv;
- for self { @kv.push($_.key); @kv.push($_.value); }
- @kv;
- }
-
-
- =begin item values
- Returns a list of all of the values in the hash.
- =end item
-
- method values () {
- my @values;
- for self { @values.push($_.value); }
- @values;
- }
-
-}
-
-
-=begin item hash
-Construct a hash from named arguments.
-=end item
-
-sub hash(*%h) { %h }
-
-# vim: ft=perl6
-# From src/setting/Regex.pm
-
-#! nqp
-
-=begin
-
-Regex methods and functions
-
-=end
-
-=begin item match
-Match C<$text> against C<$regex>. If the C<$global> flag is
-given, then return an array of all non-overlapping matches.
-=end item
-
-sub match ($text, $regex, :$global?) {
- my $match := $text ~~ $regex;
- if $global {
- my @matches;
- while $match {
- @matches.push($match);
- $match := $match.CURSOR.parse($text, :rule($regex), :c($match.to));
- }
- @matches;
- }
- else {
- $match;
- }
-}
-
-
-=begin item subst
-Substitute an match of C<$regex> in C<$text> with C<$replacement>,
-returning the substituted string. If C<$global> is given, then
-perform the replacement on all matches of C<$text>.
-=end item
-
-sub subst ($text, $regex, $repl, :$global?) {
- my @matches := $global ?? match($text, $regex, :global)
- !! [ $text ~~ $regex ];
- my $is_code := pir::isa($repl, 'Sub');
- my $offset := 0;
- my @pieces;
-
- for @matches -> $match {
- my $repl_string := $is_code ?? $repl($match) !! $repl;
- @pieces.push( pir::substr($text, $offset, $match.from - $offset))
- if $match.from > $offset;
- @pieces.push($repl_string);
- $offset := $match.to;
- }
-
- my $chars := pir::length($text);
- @pieces.push(pir::substr($text, $offset, $chars))
- if $chars > $offset;
-
- @pieces.join('');
-}
-
-# vim: ft=perl6
-# From src/setting/IO.pm
-
-#! nqp
-
-=begin
-
-IO Methods and Functions
-
-=end
-
-=begin item slurp
-Returns the contents of C<$filename> as a single string.
-=end
-
-sub slurp ($filename) {
- my $handle := pir::open__Pss($file, 'r');
- my $contents := $handle.readall;
- pir::close($handle);
- $contents;
-}
-
-
-=begin item spew
-Write the string value of C<$contents> to C<$filename>.
-=end item
-
-sub spew($filename, $contents) {
- my $handle := pir::open__Pss($filename, 'w');
- $handle.print($contents);
- pir::close($handle);
-}
-
-# vim: ft=perl6
-
-# vim: set ft=perl6 nomodifiable :
More information about the parrot-commits
mailing list