On Sunday 05 August 2007 21:57:05 chromatic wrote:

> Here's a patch which cleans up the issue somewhat, but doesn't fix up the
> typemaps.

Actually, use this patch instead.

-- c

=== src/pmc/parrotinterpreter.pmc
==================================================================
--- src/pmc/parrotinterpreter.pmc	(revision 5223)
+++ src/pmc/parrotinterpreter.pmc	(local)
@@ -605,50 +605,48 @@
     }
 
     void thawfinish(visit_info *info) {
-        INTVAL i, n, m;
-        PMC *hll_info, *entry, *lib_pmc, *new_info, *ns_hash;
-        STRING *lib_name, *hll_name;
+        PMC    *hll_info = INTERP->HLL_info;
+        PMC    *new_info = PMC_pmc_val(SELF);
+        INTVAL  n        = VTABLE_elements(INTERP, hll_info);
+        INTVAL  m        = VTABLE_elements(INTERP, new_info);
 
-        hll_info = INTERP->HLL_info;
-        n = VTABLE_elements(INTERP, hll_info);
-        new_info = PMC_pmc_val(SELF);
+        INTVAL i;
+
         PMC_pmc_val(SELF) = NULL;
-        m = VTABLE_elements(INTERP, new_info);
         /* merge new_info */
         /* TODO compare old entries */
+
         for (i = n; i < m; ++i) {
-            entry = VTABLE_get_pmc_keyed_int(INTERP, new_info, i);
-            lib_pmc = VTABLE_get_pmc_keyed_int(INTERP, entry, 1);
+            PMC *entry    = VTABLE_get_pmc_keyed_int(INTERP, new_info, i);
+            PMC *lib_pmc  = VTABLE_get_pmc_keyed_int(INTERP, entry, e_HLL_lib);
+            PMC *name_pmc = VTABLE_get_pmc_keyed_int(INTERP, entry, e_HLL_name);
+
+            STRING *lib_name = NULL;
+            STRING *hll_name = NULL;
+
             if (!PMC_IS_NULL(lib_pmc)) {
                 lib_name = VTABLE_get_string(INTERP, lib_pmc);
-                if (lib_name->strlen)
-                    Parrot_load_lib(INTERP, lib_name, NULL);
+                PObj_constant_SET(lib_name);
             }
-            entry = VTABLE_get_pmc_keyed_int(INTERP, entry, 0);
-            if (!PMC_IS_NULL(entry)) {
+
+            if (!PMC_IS_NULL(name_pmc)) {
                 hll_name = VTABLE_get_string(INTERP, entry);
-                /* create HLL namespace */
-                hll_name = string_downcase(INTERP, hll_name);
+                PObj_constant_SET(hll_name);
+            }
 
-                /* HLL type mappings aren't yet created, we can't create
-                 * a namespace in HLL's flavor yet - maybe promote the
-                 * ns_hash to another type later, if mappings provide one?
-                 * XXX - FIXME
-                 */
-                ns_hash =
-                    Parrot_make_namespace_keyed_str(interp,
-                                                    interp->root_namespace,
-                                                    hll_name);
+            if (hll_name || lib_name) {
+                INTVAL id = Parrot_register_HLL(INTERP, hll_name, lib_name);
+                    PMC *typemap  =
+                        VTABLE_get_pmc_keyed_int(INTERP, entry, e_HLL_typemap);
+                    PMC *hll_info =
+                        VTABLE_get_pmc_keyed_int(INTERP, INTERP->HLL_info, id);
 
-                /* cache HLLs toplevel namespace */
-                VTABLE_set_pmc_keyed_int(INTERP,
-                                         INTERP->HLL_namespace, i, ns_hash);
+                    fprintf( stderr, "Storing typemap for HLL %d\n", id );
+                    dod_register_pmc(INTERP, typemap);
+                    VTABLE_set_pmc_keyed_int(INTERP, hll_info, e_HLL_typemap,
+                        typemap);
             }
         }
-
-        /* TODO destruct old HLL_info are constants */
-        if (m > n)
-            INTERP->HLL_info = new_info;
     }
 
     METHOD void run_gc() {
=== include/parrot/hll.h
==================================================================
--- include/parrot/hll.h	(revision 5224)
+++ include/parrot/hll.h	(local)
@@ -71,6 +71,13 @@
 
 /* HEADERIZER END: src/hll.c */
 
+enum {
+    e_HLL_name,
+    e_HLL_lib,
+    e_HLL_typemap,
+    e_HLL_MAX
+} HLL_enum_t;
+
 #endif /* PARROT_HLL_H_GUARD */
 
 /*

Reply via email to