Author: jhorwitz
Date: Tue Jul 31 13:47:49 2007
New Revision: 236
Added:
mod_parrot/trunk/lib/ModParrot/HLL/perl6.pir
Log:
support for Perl6 HLL
Added: mod_parrot/trunk/lib/ModParrot/HLL/perl6.pir
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/lib/ModParrot/HLL/perl6.pir Tue Jul 31 13:47:49 2007
@@ -0,0 +1,76 @@
+# $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::perl6' ]
+
+# 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 'perl6.pbc'
+.end
+
+.sub _load
+ .param string module
+
+ # load & compile the Perl6 handler
+ $S0 = 'use '
+ concat $S0, module
+ $P0 = compreg 'Perl6'
+ $P1 = $P0.'compile'($S0)
+ $P1()
+
+ .return(0)
+.end
+
+#.sub _config
+
+# response handler
+.sub _handler
+ .param string handler_name
+ .local string handler_sub
+ .local string handler_module
+ .local pmc r
+ .local pmc handler
+ .local pmc ap_const
+ .local int status
+
+ # mod_perl uses NS::handler, but until Perl6 compiler supports namespaces,
+ # we'll use the subroutine name as the name of the handlers
+ $P0 = split '::', handler_name
+ push $P0, 'handler'
+ handler_sub = join '__', $P0
+ handler = get_hll_global handler_sub
+ unless_null handler, RUN_HANDLER
+
+LOAD_HANDLER:
+ $I0 = _load(handler_name)
+ handler = get_hll_global handler_sub
+
+RUN_HANDLER:
+ # run the handler, passing in Apache::RequestRec object
+ r = new 'Apache::RequestRec'
+ status = handler(r)
+
+ # XXX fake our reply until Perl6 supports the "return" statement
+ r.'content_type'('text/plain')
+ r.'puts'("This is mod_parrot answering on behalf of mod_perl6.\n")
+ r.'puts'("Your handler ran successfully. Squawk.\n")
+ ap_const = find_global 'Apache::Constants', 'ap_constants'
+ status = ap_const['OK']
+
+ # 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.