.const .LuaNumber n = "12.34"
I presume LuaNumber doesn't have new_from_string (Float hasn't either).
Attached is a patch that implements new_from_string() for LuaNumber.
In my opinion it's handy to say:
.const .LuaNumber n = "12.34"
kind regards,
klaas-jan
--- languages/lua/classes/luanumber.pmc 2006-01-13 13:58:04.000000000 +0100
+++ languages/lua/classes/newluanumber.pmc 2006-01-13 14:02:49.000000000
+0100
@@ -67,6 +67,31 @@
return 1;
}
+/*
+
+=item C<PMC* new_from_string(STRING *rep, INTVAL flags)>
+
+Return a LuaNumber PMC created from a string. Implementation
+is based on new_from_string() from Integer PMC.
+
+=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);
+
+ PMC_num_val(res) = string_to_num(INTERP, rep);
+ return res;
+ }
+
}
/*