[svn:mod_parrot] r243 - in mod_parrot/trunk: . lib/ModParrot/HLL

[email protected]
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Fri Aug 31 18:42:08 2007
New Revision: 243

Added:
   mod_parrot/trunk/lib/ModParrot/HLL/nqp.pir
Modified:
   mod_parrot/trunk/Makefile.in

Log:
add support for NQP


Modified: mod_parrot/trunk/Makefile.in
==============================================================================
--- mod_parrot/trunk/Makefile.in	(original)
+++ mod_parrot/trunk/Makefile.in	Fri Aug 31 18:42:08 2007
@@ -30,7 +30,9 @@
 	lib/Apache/Constants \
 	lib/APR/Table \
 	lib/ModParrot/init \
-	lib/ModParrot/HLL/pir
+	lib/ModParrot/HLL/pir \
+	lib/ModParrot/HLL/perl6 \
+	lib/ModParrot/HLL/nqp
 
 all: gen-src src/mod_parrot.la
 

Added: mod_parrot/trunk/lib/ModParrot/HLL/nqp.pir
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/lib/ModParrot/HLL/nqp.pir	Fri Aug 31 18:42:08 2007
@@ -0,0 +1,79 @@
+# $Id$
+
+# Copyright (c) 2007 Jeff Horwitz
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+.namespace [ 'ModParrot::HLL::nqp' ]
+
+# XXX should replace with .HLL eventually
+.sub __onload :anon :load
+    # this might need an absolute path until we can tweak the runtime prefix
+    load_bytecode 'nqp.pbc'
+.end
+
+.sub _load
+    .param string path
+    .local string rpath
+    .local pmc env
+
+    # prepend runtime path, if set
+    env = new 'Env'
+    rpath = env['PARROT_RUNTIME']
+    if_null rpath, LOAD_HANDLER
+    $S0 = rpath
+    concat $S0, "/"
+    concat $S0, path
+    path = $S0
+
+LOAD_HANDLER:
+    # load & compile the NQP handler
+    $P0 = compreg 'NQP'
+    $P1 = $P0.'evalfiles'(path)
+
+    .return($P1)
+.end
+
+#.sub _config
+
+# response handler
+.sub _handler
+    .param string handler_name
+    .local string handler_path
+    .local string handler_sub
+    .local pmc handler
+    .local pmc r
+    .local pmc ap_const
+    .local int status
+
+    # mod_perl uses NS::handler, but until NQP compiler supports namespaces,
+    # we'll use the subroutine name as the name of the handlers
+    $P0 = split '::', handler_name
+    handler_sub = pop $P0
+    handler_path = join '/', $P0
+    concat handler_path, '.nqp'
+    handler = get_hll_global handler_sub
+    unless_null handler, RUN_HANDLER
+
+LOAD_HANDLER:
+    $P0 = _load(handler_path)
+    handler = get_hll_global handler_sub
+
+RUN_HANDLER:
+    # run the handler, passing in Apache::RequestRec object
+    r = new [ 'Apache'; 'RequestRec' ]
+    status = handler(r)
+
+    # return status code
+    .return(status)
+.end
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.