Author: kjs
Date: Wed Mar 26 04:55:22 2008
New Revision: 26564

Added:
   trunk/compilers/nqp/bootstrap/nqp.pir   (contents, props changed)
Modified:
   trunk/MANIFEST

Log:
[nqp] add compiler driver for bootstrap version of nqp.pir

update manifest, which also includes Whatever class for perl6 which wasn't 
added apparently.

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST      (original)
+++ trunk/MANIFEST      Wed Mar 26 04:55:22 2008
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools\dev\mk_manifest_and_skip.pl Tue Mar 25 16:27:43 2008 UT
+# generated by tools\dev\mk_manifest_and_skip.pl Wed Mar 26 11:53:05 2008 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -86,6 +86,7 @@
 compilers/nqp/README.pod                                    []
 compilers/nqp/TODO.pod                                      []
 compilers/nqp/bootstrap/actions.pm                          []
+compilers/nqp/bootstrap/nqp.pir                             []
 compilers/nqp/nqp.pir                                       []
 compilers/nqp/src/Grammar.pg                                []
 compilers/nqp/src/Grammar/Actions.pir                       []
@@ -1832,8 +1833,8 @@
 languages/perl6/src/classes/Role.pir                        [perl6]
 languages/perl6/src/classes/Str.pir                         [perl6]
 languages/perl6/src/classes/Sub.pir                         [perl6]
-languages/perl6/src/classes/Whatever.pir                    [perl6]
 languages/perl6/src/classes/Undef.pir                       [perl6]
+languages/perl6/src/classes/Whatever.pir                    [perl6]
 languages/perl6/src/parser/actions.pm                       [perl6]
 languages/perl6/src/parser/expression.pir                   [perl6]
 languages/perl6/src/parser/grammar-oper.pg                  [perl6]

Added: trunk/compilers/nqp/bootstrap/nqp.pir
==============================================================================
--- (empty file)
+++ trunk/compilers/nqp/bootstrap/nqp.pir       Wed Mar 26 04:55:22 2008
@@ -0,0 +1,209 @@
+=head1 TITLE
+
+nqp.pir - A nqp compiler.
+
+=head2 Description
+
+This is the base file for the nqp compiler.
+
+This file includes the parsing and grammar rules from
+the src/ directory, loads the relevant PGE libraries,
+and registers the compiler under the name 'nqp'.
+
+=head2 Functions
+
+=over 4
+
+=item onload()
+
+Creates the nqp compiler using a C<PCT::HLLCompiler>
+object.
+
+=cut
+
+.namespace [ 'NQP::Compiler' ]
+
+.loadlib 'nqp_group'
+
+.sub 'onload' :anon :load :init
+    load_bytecode 'PCT.pbc'
+
+    $P0 = get_hll_global ['PCT'], 'HLLCompiler'
+    $P1 = $P0.'new'()
+    $P1.'language'('NQP')
+    $P1.'parsegrammar'('NQP::Grammar')
+    $P1.'parseactions'('NQP::Grammar::Actions')
+.end
+
+=item main(args :slurpy)  :main
+
+Start compilation by passing any command line C<args>
+to the nqp compiler.
+
+=cut
+
+.sub 'main' :main
+    .param pmc args
+
+    $P0 = compreg 'NQP'
+    $P1 = $P0.'command_line'(args)
+.end
+
+
+.include '../src/Grammar_gen.pir'
+.include 'gen_actions.pir'
+
+
+.namespace
+
+.sub 'initlist' :anon :load :init
+    subclass $P0, 'ResizablePMCArray', 'List'
+    $P0 = new 'List'
+    set_hll_global ['NQP';'Grammar';'Actions'], '@?BLOCK', $P0
+.end
+
+
+.namespace [ 'List' ]
+
+.sub 'unshift' :method
+    .param pmc obj
+    unshift self, obj
+.end
+
+.sub 'shift' :method
+    shift $P0, self
+    .return ($P0)
+.end
+
+.sub 'push' :method
+    .param pmc obj
+    push self, obj
+.end
+
+
+#.namespace [ 'NQP::Grammar::Actions' ]
+#
+#.sub 'package_declarator_helper'
+#    .param pmc match
+#    .param pmc key
+#    .local pmc past
+#    $P0 = match[key]
+#    past = $P0.'get_scalar'()
+#    $P1 = match['name']
+#    $P1 = $P1['ident']
+#    past.'namespace'($P1)
+#    past.'blocktype'('declaration')
+#    past.'pirflags'(':init :load')
+#    past.'lexical'(0)
+#    $S0 = match['sym']
+#    if $S0 != 'class' goto class_done
+#    .local string inline
+#    inline = <<'        INLINE'
+#        $P0 = get_hll_global 'Protomaker'
+#        $P1 = split '::', '%s'
+#        push_eh subclass_done
+#        $P2 = $P0.'new_subclass'('Protoobject', $P1)
+#        pop_eh
+#      subclass_done:
+#        INLINE
+#    $S0 = match['name']
+#    $I0 = index inline, '%s'
+#    substr inline, $I0, 2, $S0
+#    $P0 = get_hll_global ['PAST'], 'Op'
+#    $P1 = $P0.'new'('inline'=>inline, 'pasttype'=>'inline')
+#    $P2 = past[0]
+#    $P2.'push'($P1)
+#  class_done:
+#    match.'result_object'(past)
+#.end
+
+
+
+.sub '__onload' :init :load
+
+    ##  initialize optable with inline PIR
+    .local pmc optable
+    optable = get_hll_global [ 'NQP::Grammar' ], '$optable'
+    optable['prefix:~'; 'inline'] = <<"        END"
+        ##  inline prefix:~
+        $S0 = %0
+        %r = new 'String'
+        %r = $S0
+        END
+
+    optable['prefix:+'; 'inline'] = <<"        END"
+        ##  inline prefix:+
+        $N0 = %0
+        %r = new 'Float'
+        %r = $N0
+        END
+
+    optable['infix:=='; 'inline'] = <<"        END"
+        ##  inline infix:==
+        $I0 = cmp_num %0, %1
+        $I0 = iseq $I0, 0
+        %r = new 'Integer'
+        %r = $I0
+        END
+
+    optable['infix:!='; 'inline'] = <<"        END"
+        ##  inline infix:!=
+        $I0 = cmp_num %0, %1
+        $I0 = isne $I0, 0
+        %r = new 'Integer'
+        %r = $I0
+        END
+
+    optable['infix:eq'; 'inline'] = <<"        END"
+        ##  inline infix:eq
+        $S0 = %0
+        $S1 = %1
+        $I0 = iseq $S0, $S1
+        %r = new 'Integer'
+        %r = $I0
+        END
+
+    optable['infix:ne'; 'inline'] = <<"        END"
+        ##  inline infix:ne
+        $S0 = %0
+        $S1 = %1
+        $I0 = isne $S0, $S1
+        %r = new 'Integer'
+        %r = $I0
+        END
+
+    optable['infix:=:='; 'inline'] = <<"        END"
+        ##  inline infix:=:=
+        $I0 = issame %0, %1
+        %r = new 'Integer'
+        %r = $I0
+        END
+
+    optable['prefix:!'; 'inline'] = <<"        END"
+        ##  inline prefix:!
+        $I0 = isfalse %0
+        %r = new 'Integer'
+        %r = $I0
+        END
+
+    optable['prefix:?'; 'inline'] = <<"        END"
+        ##  inline prefix:?
+        $I0 = istrue %0
+        %r = new 'Integer'
+        %r = $I0
+        END
+
+    .return ()
+.end
+
+
+=back
+
+=cut
+
+# Local Variables:
+#   mode: pir
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+

Reply via email to