In a library (languages/lua/lib/luastring.pir), I declare a global variable ("mt_string"):

.namespace [ "Lua" ]
.HLL "Lua", "lua_group"

.sub init :load, :anon
    ...
    .local pmc _lua_mt_string
    _lua_mt_string = new .LuaTable
    global "mt_string" = _lua_mt_string
    ...

In a PMC method, I want to access it :
Index: luabase.pmc
===================================================================
--- luabase.pmc (revision 11848)
+++ luabase.pmc (working copy)
@@ -559,6 +559,11 @@
             if (dynpmc_LuaTable == retval->vtable->base_type)
                 return retval;
         }
+        else if (dynpmc_LuaString == SELF->vtable->base_type) {
+            return Parrot_get_global(INTERP,
+                    const_string(INTERP, "Lua"),
+                    const_string(INTERP, "mt_string"), NULL);
+        }
         return pmc_new(INTERP, dynpmc_LuaNil);
     }

But I've the following result :
$ perl -I../../lib t/pmc/string.t
not ok 11 - check tostring
#     Failed test (t/pmc/string.t at line 224)
#          got: 'value
# Global 'mt_string' not found
# current instr.: '_main' pc 16 (C:\fperrad\parrot\trunk\languages\lua\t\pmc\string_11.pir:8)
# '

What is it wrong ?

François.

Reply via email to