[svn:parrot] r40048 - in branches/ops_pct/compilers/opsc: ops t

bacek at svn.parrot.org bacek at svn.parrot.org
Mon Jul 13 11:42:54 UTC 2009


Author: bacek
Date: Mon Jul 13 11:42:53 2009
New Revision: 40048
URL: https://trac.parrot.org/parrot/changeset/40048

Log:
[opsc][t] Add test for future ops files parsing.

Added:
   branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t
Modified:
   branches/ops_pct/compilers/opsc/ops/oplib.pm

Modified: branches/ops_pct/compilers/opsc/ops/oplib.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/ops/oplib.pm	Mon Jul 13 11:42:21 2009	(r40047)
+++ branches/ops_pct/compilers/opsc/ops/oplib.pm	Mon Jul 13 11:42:53 2009	(r40048)
@@ -36,25 +36,48 @@
 
 Build OpLib.
 
-(It's NQP. In Perl 6 it should be submethod invoked automatically)
+(It's NQP. In Perl 6 it should be submethod and invoked automatically)
 
 =cut
 
 method BUILD(*%args) {
-    my $self  := self; # NQP parser isn't full Perl6. So alias self to $self.
     my @files := %args<files>;
     if !+ at files {
         die("We need some files!")
     }
-    $self<files> := @files;
+    self<files> := @files;
+
+    self<ops>   := <>;
+
+    self;
 }
 
+=item C<parse_ops>
+
+Parse all ops files passed to BUILD method. Create self.ops list for parsed ops.
+
+=cut
+
+method parse_ops() {
+    for self.files() {
+        self.parse_ops_file($_);
+        self<ops>.push(self.parse_ops_file($_));
+    }
+}
+
+method parse_ops_file($file) {
+    <>;
+}
+
+method ops() {
+    self<ops>;
+}
 
 method files() {
-    my $self := self;
-    $self<files>;
+    self<files>;
 }
 
+
 # Local Variables:
 #   mode: perl6
 #   fill-column: 100

Added: branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t	Mon Jul 13 11:42:53 2009	(r40048)
@@ -0,0 +1,20 @@
+#!../../parrot ../nqp/nqp.pbc
+
+PIR q<
+    load_bytecode "opsc_core.pbc"
+>;
+
+
+my @files := qw{
+    src/ops/core.ops
+    src/ops/math.ops
+};
+
+my $lib := Ops::OpLib.new.BUILD(:files(@files));
+
+$lib.parse_ops();
+
+# Not a real number. But I'll adjust it soon.
+ok(+($lib.ops) == 42, "ops file parsed");
+
+# vim: expandtab shiftwidth=4 ft=perl6:


More information about the parrot-commits mailing list