Mercurial Hosting > luan
diff src/luan/Lua.java @ 2:4da26b11d12a
start interp
git-svn-id: https://luan-java.googlecode.com/svn/trunk@3 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 14 Nov 2012 08:53:25 +0000 |
parents | 2df768b926aa |
children | 7a2cdbc5767f |
line wrap: on
line diff
--- a/src/luan/Lua.java Tue Nov 13 05:54:32 2012 +0000 +++ b/src/luan/Lua.java Wed Nov 14 08:53:25 2012 +0000 @@ -3,12 +3,6 @@ public class Lua { - public static String toString(Object obj) { - if( obj == null ) - return "nil"; - return obj.toString(); - } - public static String type(Object obj) { if( obj == null ) return "nil"; @@ -21,19 +15,13 @@ return "userdata"; } - public static int length(Object obj) throws LuaException { - if( obj instanceof String ) { - String s = (String)obj; - return s.length(); - } - if( obj instanceof LuaTable ) { - LuaTable t = (LuaTable)obj; - return t.length(); - } - throw new LuaException( "attempt to get length of a " + type(obj) + " value" ); + public static String toString(Object obj) { + if( obj == null ) + return "nil"; + return obj.toString(); } - static LuaNumber toNumber(Object obj) throws LuaException { + public static LuaNumber toNumber(Object obj) throws LuaException { if( obj instanceof LuaNumber ) return (LuaNumber)obj; if( obj instanceof String ) { @@ -45,12 +33,10 @@ throw new LuaException( "attempt to perform arithmetic on a " + type(obj) + " value" ); } - static LuaNumber add(Object n1,Object n2) throws LuaException { - return new LuaNumber( toNumber(n1).n + toNumber(n2).n ); - } - - static LuaNumber sub(Object n1,Object n2) throws LuaException { - return new LuaNumber( toNumber(n1).n - toNumber(n2).n ); + public static LuaFunction toFunction(Object obj) throws LuaException { + if( obj instanceof LuaFunction ) + return (LuaFunction)obj; + throw new LuaException( "attempt to call a " + type(obj) + " value" ); } }