[svn:parrot] r44552 - in branches/ops_pct/ext/nqp-rx: . src/gen

bacek at svn.parrot.org bacek at svn.parrot.org
Mon Mar 1 04:00:41 UTC 2010


Author: bacek
Date: Mon Mar  1 04:00:30 2010
New Revision: 44552
URL: https://trac.parrot.org/parrot/changeset/44552

Log:
Add to-be-nqp-settings

Added:
   branches/ops_pct/ext/nqp-rx/src/gen/
   branches/ops_pct/ext/nqp-rx/src/gen/settings.pm
Modified:
   branches/ops_pct/ext/nqp-rx/Defines.mak
   branches/ops_pct/ext/nqp-rx/Rules.mak

Modified: branches/ops_pct/ext/nqp-rx/Defines.mak
==============================================================================
--- branches/ops_pct/ext/nqp-rx/Defines.mak	Sun Feb 28 15:14:53 2010	(r44551)
+++ branches/ops_pct/ext/nqp-rx/Defines.mak	Mon Mar  1 04:00:30 2010	(r44552)
@@ -5,4 +5,5 @@
     $(LIBRARY_DIR)/nqp-rx.pbc \
     $(LIBRARY_DIR)/P6object.pbc \
     $(LIBRARY_DIR)/PCT/HLLCompiler.pbc \
-    $(LIBRARY_DIR)/PCT/PAST.pbc
+    $(LIBRARY_DIR)/PCT/PAST.pbc \
+	$(LIBRARY_DIR)/nqp-settings.pbc

Modified: branches/ops_pct/ext/nqp-rx/Rules.mak
==============================================================================
--- branches/ops_pct/ext/nqp-rx/Rules.mak	Sun Feb 28 15:14:53 2010	(r44551)
+++ branches/ops_pct/ext/nqp-rx/Rules.mak	Mon Mar  1 04:00:30 2010	(r44552)
@@ -12,6 +12,12 @@
 $(LIBRARY_DIR)/nqp-rx.pbc: ext/nqp-rx/src/stage0/NQP-s0.pir $(PARROT)
 	$(PARROT) -o $@ ext/nqp-rx/src/stage0/NQP-s0.pir
 
+ext/nqp-rx/src/gen/settings.pir: ext/nqp-rx/src/gen/settings.pm parrot-nqp.pbc
+	$(PARROT) parrot-nqp.pbc --target=pir -o $@ ext/nqp-rx/src/gen/settings.pm
+
+$(LIBRARY_DIR)/nqp-settings.pbc: ext/nqp-rx/src/gen/settings.pir $(PARROT)
+	$(PARROT) -o $@ ext/nqp-rx/src/gen/settings.pir
+
 ## TT #1398 - pbc_to_exe cannot generate a specified target file
 parrot-nqp.pbc : $(LIBRARY_DIR)/nqp-rx.pbc
 	$(CP) $(LIBRARY_DIR)/nqp-rx.pbc $@

Added: branches/ops_pct/ext/nqp-rx/src/gen/settings.pm
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/ops_pct/ext/nqp-rx/src/gen/settings.pm	Mon Mar  1 04:00:30 2010	(r44552)
@@ -0,0 +1,178 @@
+
+# This file automatically generated by build/gen_settings.pl.
+
+# From src/settings/Array.pm
+
+=begin
+
+=head2 Array Methods
+
+These methods extend the native NQP Array class to support more of the basic
+functionality expected for Perl 6 Hashes.
+
+=end
+
+module ResizablePMCArray {
+
+
+=begin
+
+=over 4
+
+=item @reversed := @array.reverse
+
+Return a C<@reversed> copy of the C<@array>.
+
+=end
+
+    method reverse () {
+        my @reversed;
+        for self { @reversed.unshift($_); }
+        @reversed;
+    }
+
+=begin
+
+=item $string := @array.join($join_string)
+
+Join C<@array> using C<$join_string>
+
+=end
+
+    method join ($join_string) {
+        return Q:PIR{
+            $P0 = find_lex '$join_string'
+            $S0 = $P0
+            $S1 = join $S0, self
+            %r  = box $S1
+        }
+    }
+
+=begin
+
+=back
+
+=end
+
+}
+
+sub join($join_string, *@list) { @list.join($join_string) }
+
+# vim: ft=perl6
+# From src/settings/Hash.pm
+
+=begin
+
+=head2 Hash Methods
+
+These methods extend the native NQP Hash class to support more of the basic
+functionality expected for Perl 6 Hashes.
+
+=end
+
+module Hash {
+
+
+=begin
+
+=over 4
+
+=item $found := %hash.exists($key)
+
+Return a true value if C<$key> exists in C<%hash>, or a false value otherwise.
+
+=end
+
+    method exists ($key) {
+        return Q:PIR{
+            $P1 = find_lex '$key'
+            $I0 = exists self[$P1]
+            %r  = box $I0
+        };
+    }
+
+=begin
+
+=item %hash.delete($key)
+
+Delete C<$key> from C<%hash>.
+
+=end
+
+    method delete ($key) {
+        Q:PIR{
+            $P1 = find_lex '$key'
+            delete self[$P1]
+        };
+    }
+
+
+=begin
+
+=item @keys := %hash.keys
+
+Return all the C<@keys> in the C<%hash> as an unordered array.
+
+=end
+
+    method keys () {
+        my @keys;
+        for self { @keys.push($_.key); }
+        @keys;
+    }
+
+
+=begin
+
+=item @values := %hash.values
+
+Return all the C<@values> in the C<%hash> as an unordered array.
+
+=end
+
+    method values () {
+        my @values;
+        for self { @values.push($_.value); }
+        @values;
+    }
+
+
+=begin
+
+=item @flattened := %hash.kv
+
+Flatten C<%hash> into an array, alternating key and value.  This is useful
+when iterating over key and value simultaneously:
+
+    for %hash.kv -> $k, $v { ... }
+
+=end
+
+    method kv () {
+        my @kv;
+        for self { @kv.push($_.key); @kv.push($_.value); }
+        @kv;
+    }
+
+
+=begin
+
+=back
+
+=end
+
+}
+
+=begin
+
+=item %hash := hash(:key1(value1), :key2(value2), ...)
+
+Coerce a list of pairs into a hash.
+
+=end
+
+sub hash (*%h) { return %h }
+
+# vim: ft=perl6
+
+# vim: set ft=perl6 nomodifiable :


More information about the parrot-commits mailing list