Author: fperrad
Date: Sun Nov 30 13:29:03 2008
New Revision: 33379
Modified:
trunk/languages/lua/src/lib/luamath.pir
trunk/languages/lua/src/pmc/lua.pmc
trunk/languages/lua/src/pmc/luanumber.pmc
Log:
[Lua]
- move frexp, ldexp & modf to LuaNumber PMC
Modified: trunk/languages/lua/src/lib/luamath.pir
==============================================================================
--- trunk/languages/lua/src/lib/luamath.pir (original)
+++ trunk/languages/lua/src/lib/luamath.pir Sun Nov 30 13:29:03 2008
@@ -256,8 +256,7 @@
.param pmc extra :slurpy
.local pmc res
lua_checknumber(1, x)
- new $P0, 'Lua'
- res = $P0.'frexp'(x)
+ res = x.'frexp'()
.return (res :flat)
.end
@@ -269,8 +268,7 @@
.local pmc res
lua_checknumber(1, x)
lua_checknumber(2, nexp)
- new $P0, 'Lua'
- res = $P0.'ldexp'(x, nexp)
+ res = x.'ldexp'(nexp)
.return (res)
.end
@@ -356,8 +354,7 @@
.param pmc extra :slurpy
.local pmc res
lua_checknumber(1, x)
- new $P0, 'Lua'
- res = $P0.'modf'(x)
+ res = x.'modf'()
.return (res :flat)
.end
Modified: trunk/languages/lua/src/pmc/lua.pmc
==============================================================================
--- trunk/languages/lua/src/pmc/lua.pmc (original)
+++ trunk/languages/lua/src/pmc/lua.pmc Sun Nov 30 13:29:03 2008
@@ -159,45 +159,6 @@
/*
-=item C<PMC* frexp(PMC *x)>
-
-=cut
-
-*/
- METHOD PMC* frexp(PMC *x) {
- PMC *y = pmc_new(INTERP, dynpmc_LuaNumber);
- PMC *expn = pmc_new(INTERP, dynpmc_LuaNumber);
- PMC *retval = pmc_new(INTERP, enum_class_Array);
- int e;
-
- VTABLE_set_number_native(INTERP, y,
- frexp(VTABLE_get_number(INTERP, x), &e));
- VTABLE_set_integer_native(INTERP, expn, e);
- VTABLE_set_integer_native(INTERP, retval, 2);
- VTABLE_set_pmc_keyed_int(INTERP, retval, 0, y);
- VTABLE_set_pmc_keyed_int(INTERP, retval, 1, expn);
-
- RETURN(PMC *retval);
- }
-
-/*
-
-=item C<PMC* ldexp(PMC *x, PMC *expn)>
-
-=cut
-
-*/
- METHOD PMC* ldexp(PMC *x, PMC *expn) {
- PMC *retval = pmc_new(INTERP, dynpmc_LuaNumber);
-
- VTABLE_set_number_native(INTERP, retval,
- ldexp(VTABLE_get_number(INTERP, x),
- VTABLE_get_integer(INTERP, expn)));
- RETURN(PMC *retval);
- }
-
-/*
-
=item C<PMC* mktime(PMC *tm)>
=cut
@@ -230,29 +191,6 @@
/*
-=item C<PMC* modf(PMC *x)>
-
-=cut
-
-*/
- METHOD PMC* modf(PMC *x) {
- PMC *y = pmc_new(INTERP, dynpmc_LuaNumber);
- PMC *d = pmc_new(INTERP, dynpmc_LuaNumber);
- PMC *retval = pmc_new(INTERP, enum_class_Array);
- FLOATVAL _d;
-
- VTABLE_set_number_native(INTERP, y,
- modf(VTABLE_get_number(INTERP, x), &_d));
- VTABLE_set_number_native(INTERP, d, _d);
- VTABLE_set_integer_native(INTERP, retval, 2);
- VTABLE_set_pmc_keyed_int(INTERP, retval, 0, d);
- VTABLE_set_pmc_keyed_int(INTERP, retval, 1, y);
-
- RETURN(PMC *retval);
- }
-
-/*
-
=item C<PMC* setlocale(INTVAL category, STRING *locale)>
=cut
Modified: trunk/languages/lua/src/pmc/luanumber.pmc
==============================================================================
--- trunk/languages/lua/src/pmc/luanumber.pmc (original)
+++ trunk/languages/lua/src/pmc/luanumber.pmc Sun Nov 30 13:29:03 2008
@@ -873,6 +873,68 @@
=over 4
+=item C<PMC* frexp()>
+
+=cut
+
+*/
+ METHOD PMC* frexp() {
+ PMC *y = pmc_new(INTERP, dynpmc_LuaNumber);
+ PMC *expn = pmc_new(INTERP, dynpmc_LuaNumber);
+ PMC *retval = pmc_new(INTERP, enum_class_Array);
+ int e;
+
+ VTABLE_set_number_native(INTERP, y,
+ frexp(VTABLE_get_number(INTERP, SELF), &e));
+ VTABLE_set_integer_native(INTERP, expn, e);
+ VTABLE_set_integer_native(INTERP, retval, 2);
+ VTABLE_set_pmc_keyed_int(INTERP, retval, 0, y);
+ VTABLE_set_pmc_keyed_int(INTERP, retval, 1, expn);
+
+ RETURN(PMC *retval);
+ }
+
+/*
+
+=item C<PMC* ldexp(PMC *x, PMC *expn)>
+
+=cut
+
+*/
+ METHOD PMC* ldexp(PMC *expn) {
+ PMC *retval = pmc_new(INTERP, dynpmc_LuaNumber);
+
+ VTABLE_set_number_native(INTERP, retval,
+ ldexp(VTABLE_get_number(INTERP, SELF),
+ VTABLE_get_integer(INTERP, expn)));
+ RETURN(PMC *retval);
+ }
+
+/*
+
+=item C<PMC* modf()>
+
+=cut
+
+*/
+ METHOD PMC* modf() {
+ PMC *y = pmc_new(INTERP, dynpmc_LuaNumber);
+ PMC *d = pmc_new(INTERP, dynpmc_LuaNumber);
+ PMC *retval = pmc_new(INTERP, enum_class_Array);
+ FLOATVAL _d;
+
+ VTABLE_set_number_native(INTERP, y,
+ modf(VTABLE_get_number(INTERP, SELF), &_d));
+ VTABLE_set_number_native(INTERP, d, _d);
+ VTABLE_set_integer_native(INTERP, retval, 2);
+ VTABLE_set_pmc_keyed_int(INTERP, retval, 0, d);
+ VTABLE_set_pmc_keyed_int(INTERP, retval, 1, y);
+
+ RETURN(PMC *retval);
+ }
+
+/*
+
=item C<PMC *rawequal(PMC *value)>
=cut