[svn:parrot] r39990 - in branches/ops_pct: compilers/opsc compilers/opsc/ops config/gen/makefiles

bacek at svn.parrot.org bacek at svn.parrot.org
Sat Jul 11 02:37:38 UTC 2009


Author: bacek
Date: Sat Jul 11 02:37:37 2009
New Revision: 39990
URL: https://trac.parrot.org/parrot/changeset/39990

Log:
[opsc] Add skeleton for Ops::OpLib

Added:
   branches/ops_pct/compilers/opsc/ops/oplib.pir
   branches/ops_pct/compilers/opsc/ops/oplib.pm
Modified:
   branches/ops_pct/compilers/opsc/builtins.pir
   branches/ops_pct/compilers/opsc/opsc.pir
   branches/ops_pct/config/gen/makefiles/opsc.in

Modified: branches/ops_pct/compilers/opsc/builtins.pir
==============================================================================
--- branches/ops_pct/compilers/opsc/builtins.pir	Sat Jul 11 02:36:16 2009	(r39989)
+++ branches/ops_pct/compilers/opsc/builtins.pir	Sat Jul 11 02:37:37 2009	(r39990)
@@ -93,6 +93,12 @@
     .return (1)
 .end
 
+.sub 'die'
+    .param string why       :optional
+    .param int    has_why   :opt_flag
+
+    die why
+.end
 
 
 # Local Variables:

Added: branches/ops_pct/compilers/opsc/ops/oplib.pir
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/ops_pct/compilers/opsc/ops/oplib.pir	Sat Jul 11 02:37:37 2009	(r39990)
@@ -0,0 +1,32 @@
+# $Id$
+
+=head1 DESCRIPTION
+
+Not everything possible to implement in NQP.
+
+=cut
+
+.namespace ['Ops';'OpLib']
+
+# Cheat-cheat! 
+.sub '' :anon :load :init
+    ##   create the classes
+    .local pmc p6meta
+    p6meta = new 'P6metaclass'
+
+    p6meta.'new_class'('Ops::OpLib', 'parent'=>'Hash')
+
+    .return ()
+.end
+
+=head1 COPYRIGHT
+
+Copyright (C) 2009, Parrot Foundation.
+
+=cut
+
+# Local Variables:
+#   mode: pir
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:

Added: branches/ops_pct/compilers/opsc/ops/oplib.pm
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/ops_pct/compilers/opsc/ops/oplib.pm	Sat Jul 11 02:37:37 2009	(r39990)
@@ -0,0 +1,62 @@
+# Copyright (C) 2009, Parrot Foundation.
+# $Id$
+
+class Ops::OpLib;
+
+=head1 NAME
+
+C<Ops::OpLib> - library of Parrot Operations.
+
+=head1 DESCRIPTION
+
+Responsible for loading F<src/ops/ops.num> and F<src/ops/ops.skip> files,
+parse F<.ops> files, sort them, etc.
+
+Heavily inspired by Perl5 Parrot::Ops2pm.
+
+=head1 SYNOPSIS
+
+  my $oplib := Ops::OpLib.new.BUILD;
+
+=head1 ATTRIBUTES
+
+=over 4
+
+=item C<@.files>
+
+Op files. Mandatory argument of C<BUILD> method.
+
+=cut
+
+=head1 METHODS
+
+=over 4
+
+=item BUILD
+
+Build OpLib.
+
+(It's NQP. In Perl 6 it should be submethod 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;
+}
+
+
+method files() {
+    my $self := self;
+    $self<files>;
+}
+
+# Local Variables:
+#   mode: perl6
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=perl6:

Modified: branches/ops_pct/compilers/opsc/opsc.pir
==============================================================================
--- branches/ops_pct/compilers/opsc/opsc.pir	Sat Jul 11 02:36:16 2009	(r39989)
+++ branches/ops_pct/compilers/opsc/opsc.pir	Sat Jul 11 02:37:37 2009	(r39990)
@@ -47,6 +47,8 @@
 .include 'compiler/gen_actions.pir'
 .include 'ops/op.pir'
 .include 'ops/gen_op.pir'
+.include 'ops/oplib.pir'
+.include 'ops/gen_oplib.pir'
 
 .include 'runcore/gen_base.pir'
 .include 'runcore/gen_c.pir'

Modified: branches/ops_pct/config/gen/makefiles/opsc.in
==============================================================================
--- branches/ops_pct/config/gen/makefiles/opsc.in	Sat Jul 11 02:36:16 2009	(r39989)
+++ branches/ops_pct/config/gen/makefiles/opsc.in	Sat Jul 11 02:37:37 2009	(r39990)
@@ -19,6 +19,8 @@
   builtins.pir \
   ops/op.pir \
   ops/gen_op.pir \
+  ops/oplib.pir \
+  ops/gen_oplib.pir \
   compiler/gen_grammar.pir \
   compiler/gen_actions.pir \
   runcore/gen_base.pir \
@@ -36,7 +38,7 @@
 	$(PARROT) $(PARROT_ARGS) $(PGE_LIBRARY)/Perl6Grammar.pir \
 	    --output=compiler/gen_grammar.pir compiler/grammar.pg
 
-compiler/gen_actions.pir: $(NQP) $(PCT) compiler/actions.pm op/gen_op.pir
+compiler/gen_actions.pir: $(NQP) $(PCT) compiler/actions.pm
 	$(PARROT) $(PARROT_ARGS) $(NQP) --output=compiler/gen_actions.pir \
 	    --target=pir compiler/actions.pm
 
@@ -44,6 +46,10 @@
 	$(PARROT) $(PARROT_ARGS) $(NQP) --output=ops/gen_op.pir \
 	    --target=pir ops/op.pm
 
+ops/gen_oplib.pir: $(NQP) $(PCT) ops/oplib.pm
+	$(PARROT) $(PARROT_ARGS) $(NQP) --output=ops/gen_oplib.pir \
+	    --target=pir ops/oplib.pm
+
 runcore/gen_base.pir: $(NQP) $(PCT) runcore/base.pm
 	$(PARROT) $(PARROT_ARGS) $(NQP) --output=runcore/gen_base.pir \
 	    --target=pir runcore/base.pm
@@ -99,6 +105,7 @@
   compiler/gen_grammar.pir \
   compiler/gen_actions.pir \
   ops/gen_op.pir \
+  ops/gen_oplib.pir \
   runcore/gen_base.pir \
   runcore/gen_c.pir \
 


More information about the parrot-commits mailing list