[svn:mod_parrot] r284 - in mod_parrot/trunk: docs lib/ModParrot/HLL src

[email protected]
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Thu Dec 20 12:37:26 2007
New Revision: 284

Modified:
   mod_parrot/trunk/docs/handler-architecture.txt
   mod_parrot/trunk/lib/ModParrot/HLL/nqp.pir
   mod_parrot/trunk/lib/ModParrot/HLL/perl6.pir
   mod_parrot/trunk/lib/ModParrot/HLL/pir.pir
   mod_parrot/trunk/lib/ModParrot/HLL/plumhead.pir
   mod_parrot/trunk/src/mod_parrot.c
   mod_parrot/trunk/src/parrot_util.c

Log:
convert HLL layer to use nested namespaces.  this is necessary if we want to
write mod_perl6 in Perl 6


Modified: mod_parrot/trunk/docs/handler-architecture.txt
==============================================================================
--- mod_parrot/trunk/docs/handler-architecture.txt	(original)
+++ mod_parrot/trunk/docs/handler-architecture.txt	Thu Dec 20 12:37:26 2007
@@ -29,7 +29,7 @@
 preloaded in httpd.conf with ParrotLoad if desired.
 
 HLL layer PIR functions should be named _*_handler in the namespace
-ModParrot::HLL::Foo, where 'Foo' is the name of the language implemented by
+[ModParrot;HLL;Foo], where 'Foo' is the name of the language implemented by
 the HLL layer.  If a language does not support a particular phase, its handler
 should return HTTP_INTERNAL_SERVER_ERROR (500).  This behavior may be automatic
 in the future.

Modified: mod_parrot/trunk/lib/ModParrot/HLL/nqp.pir
==============================================================================
--- mod_parrot/trunk/lib/ModParrot/HLL/nqp.pir	(original)
+++ mod_parrot/trunk/lib/ModParrot/HLL/nqp.pir	Thu Dec 20 12:37:26 2007
@@ -14,9 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-.namespace [ 'ModParrot::HLL::nqp' ]
+.namespace [ 'ModParrot'; 'HLL'; 'nqp' ]
 
-# XXX should we replace this with .HLL?
 .sub __onload :anon :load
     load_bytecode 'compilers/nqp/nqp.pbc'
 .end

Modified: mod_parrot/trunk/lib/ModParrot/HLL/perl6.pir
==============================================================================
--- mod_parrot/trunk/lib/ModParrot/HLL/perl6.pir	(original)
+++ mod_parrot/trunk/lib/ModParrot/HLL/perl6.pir	Thu Dec 20 12:37:26 2007
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-.namespace [ 'ModParrot::HLL::perl6' ]
+.namespace [ 'ModParrot'; 'HLL'; 'perl6' ]
 
 # XXX should we replace this with .HLL?
 .sub __onload :anon :load

Modified: mod_parrot/trunk/lib/ModParrot/HLL/pir.pir
==============================================================================
--- mod_parrot/trunk/lib/ModParrot/HLL/pir.pir	(original)
+++ mod_parrot/trunk/lib/ModParrot/HLL/pir.pir	Thu Dec 20 12:37:26 2007
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-.namespace [ 'ModParrot::HLL::PIR' ]
+.namespace [ 'ModParrot'; 'HLL'; 'PIR' ]
 
 .sub _load
     .param string path

Modified: mod_parrot/trunk/lib/ModParrot/HLL/plumhead.pir
==============================================================================
--- mod_parrot/trunk/lib/ModParrot/HLL/plumhead.pir	(original)
+++ mod_parrot/trunk/lib/ModParrot/HLL/plumhead.pir	Thu Dec 20 12:37:26 2007
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-.namespace [ 'ModParrot::HLL::plumhead' ]
+.namespace [ 'ModParrot'; 'HLL'; 'plumhead' ]
 
 .sub __onload :anon :load
     load_bytecode 'languages/plumhead/plumhead.pbc'

Modified: mod_parrot/trunk/src/mod_parrot.c
==============================================================================
--- mod_parrot/trunk/src/mod_parrot.c	(original)
+++ mod_parrot/trunk/src/mod_parrot.c	Thu Dec 20 12:37:26 2007
@@ -138,8 +138,7 @@
     char hll_namespace[255];
 
     if (!hll) hll = MODPARROT_DEFAULT_HLL;
-    sprintf(hll_namespace, "ModParrot::HLL::%s", hll);
-    modparrot_call_sub_IS(interp, hll_namespace, hll_handler, ret, handler);
+    modparrot_call_sub_IS(interp, hll, hll_handler, ret, handler);
     return(1);
 }
 

Modified: mod_parrot/trunk/src/parrot_util.c
==============================================================================
--- mod_parrot/trunk/src/parrot_util.c	(original)
+++ mod_parrot/trunk/src/parrot_util.c	Thu Dec 20 12:37:26 2007
@@ -24,7 +24,7 @@
 
 extern void imcc_init(Parrot_Interp);
 
-Parrot_PMC get_sub_pmc(Parrot_Interp interp, char *namespace, char *name)
+static Parrot_PMC get_sub_pmc_s(Parrot_Interp interp, char *namespace, char *name)
 {
     Parrot_PMC sub;
 
@@ -36,6 +36,37 @@
     return(sub);
 }
 
+static Parrot_PMC get_sub_pmc_k(Parrot_Interp interp, char *hll, char *name)
+{
+    Parrot_PMC sub;
+    Parrot_PMC namespace;
+    int typenum;
+
+    typenum = Parrot_PMC_typenum(interp, "SArray");
+    namespace = (Parrot_PMC)Parrot_PMC_new(interp, typenum);
+    Parrot_PMC_set_intval(interp, namespace, 3);
+    Parrot_PMC_set_cstring_intkey(interp, namespace, 0, "ModParrot");
+    Parrot_PMC_set_cstring_intkey(interp, namespace, 1, "HLL");
+    Parrot_PMC_set_cstring_intkey(interp, namespace, 2, hll);
+
+    sub = Parrot_find_global_k(interp, namespace, MAKE_PARROT_STRING(name));
+
+    return(sub);
+}
+
+Parrot_PMC get_sub_pmc(Parrot_Interp interp, char *namespace, char *name)
+{
+    Parrot_PMC sub;
+
+    /* check for sub in raw namespace */
+    sub = get_sub_pmc_s(interp, namespace, name);
+    if (!sub) {
+        /* check for sub in mod_parrot HLL layer */
+        sub = get_sub_pmc_k(interp, namespace, name);
+    }
+    return sub;
+}
+
 Parrot_Interp modparrot_init_interpreter(void)
 {
     Parrot_Interp interp;
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.