Improve table lib error reporting.

This commit is contained in:
James Roseborough
2010-05-12 03:48:21 +00:00
parent 536b27330d
commit cd4cb03525
2 changed files with 22 additions and 17 deletions

View File

@@ -21,6 +21,9 @@
******************************************************************************/
package org.luaj.vm2.lib;
import org.luaj.vm.LNil;
import org.luaj.vm.LTable;
import org.luaj.vm.LValue;
import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Varargs;
@@ -74,7 +77,9 @@ public class TableLib extends OneArgFunction {
return NONE;
}
case 3: { // "sort" (table [, comp]) -> void
args.checktable(1).sort( args.optvalue(2,NIL) );
LuaTable table = args.checktable(1);
LuaValue compare = (args.isnoneornil(2)? NIL: args.checkfunction(2));
table.sort( compare );
return NONE;
}
case 4: { // (table, func) -> void