Fix tonumber()

This commit is contained in:
James Roseborough
2007-11-16 19:43:00 +00:00
parent 45f483f706
commit d2b58a3abf

View File

@@ -186,20 +186,27 @@ public class BaseLib extends LFunction {
break;
case TONUMBER: {
LValue input = vm.topointer(2);
vm.resettop();
if ( input instanceof LNumber ) {
vm.pushlvalue(input);
} else if ( input instanceof LString ) {
switch ( vm.type(2) ) {
case Lua.LUA_TNUMBER:
break;
case Lua.LUA_TSTRING:
LString s = vm.tolstring(2);
int base = 10;
if ( vm.gettop() >= 3 ) {
base = vm.tointeger(3);
if ( base < 2 || base > 36 )
vm.error("bad argument #2 to '?' (base out of range)");
}
vm.pushlvalue( ( (LString) input ).luaToNumber( base ) );
}
vm.pushlvalue( s.luaToNumber(base) );
break;
default:
vm.pushnil();
break;
}
vm.insert(1);
vm.settop(1);
break;
}
case RAWGET: {
LValue t = vm.topointer(2);
LValue k = vm.topointer(3);