Author: fperrad
Date: Sun Jan 22 22:36:04 2006
New Revision: 11316
Modified:
trunk/languages/lua/pmc/luanil.pmc
trunk/languages/lua/t/pmc/nil.t
trunk/languages/lua/t/pmc/string.t
Log:
Lua :
- PMC nil : add new_from_string
allows : .const .LuaNil nil = "dummy"
Modified: trunk/languages/lua/pmc/luanil.pmc
==============================================================================
--- trunk/languages/lua/pmc/luanil.pmc (original)
+++ trunk/languages/lua/pmc/luanil.pmc Sun Jan 22 22:36:04 2006
@@ -183,6 +183,30 @@ Morph to another Lua type.
pmc_reuse(INTERP, SELF, new_type, 0);
}
+/*
+
+=item C<PMC* new_from_string(STRING *rep, INTVAL flags)>
+
+Allow :
+
+ .const .LuaNil nil = "dummy"
+
+=cut
+
+*/
+ PMC* new_from_string(STRING *rep, INTVAL flags) {
+ INTVAL type;
+ PMC *res;
+
+ type = SELF->vtable->base_type;
+ if (flags & PObj_constant_FLAG)
+ res = constant_pmc_new(INTERP, type);
+ else
+ res = pmc_new(INTERP, type);
+
+ return res;
+ }
+
}
/*
Modified: trunk/languages/lua/t/pmc/nil.t
==============================================================================
--- trunk/languages/lua/t/pmc/nil.t (original)
+++ trunk/languages/lua/t/pmc/nil.t Sun Jan 22 22:36:04 2006
@@ -163,13 +163,10 @@ nil
1
OUTPUT
-TODO: {
-local $TODO = "not implemented.";
-
pir_output_is(<< 'CODE', << 'OUTPUT', "check HLL & .const");
.HLL "Lua", "lua_group"
.sub _main
- .const .LuaNil cst1 = ""
+ .const .LuaNil cst1 = "dummy"
print cst1
print "\n"
.local int bool1
@@ -181,7 +178,6 @@ CODE
nil
1
OUTPUT
-}
pir_output_is(<< 'CODE', << 'OUTPUT', "morph to string");
.HLL "Lua", "lua_group"
Modified: trunk/languages/lua/t/pmc/string.t
==============================================================================
--- trunk/languages/lua/t/pmc/string.t (original)
+++ trunk/languages/lua/t/pmc/string.t Sun Jan 22 22:36:04 2006
@@ -17,7 +17,7 @@ Tests C<LuaString> PMC
=cut
-use Parrot::Test tests => 9;
+use Parrot::Test tests => 10;
use Test::More;
pir_output_is(<< 'CODE', << 'OUTPUT', "check inheritance");
@@ -201,3 +201,22 @@ simple string
1
OUTPUT
+TODO: {
+local $TODO = "empty string not handled by PIR.";
+
+pir_output_is(<< 'CODE', << 'OUTPUT', ".const & empty string");
+.HLL "Lua", "lua_group"
+.sub _main
+ .const .LuaString cst1 = ""
+ print cst1
+ print "\n"
+ .local int bool1
+ bool1 = isa cst1, "LuaString"
+ print bool1
+ print "\n"
+.end
+CODE
+
+1
+OUTPUT
+}