Mercurial Hosting > luan
comparison src/luan/interp/LtExpr.java @ 44:57054fa43189
implement table lib
git-svn-id: https://luan-java.googlecode.com/svn/trunk@45 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 26 Dec 2012 23:53:25 +0000 |
parents | e3624b7cd603 |
children | a443637829c1 |
comparison
equal
deleted
inserted
replaced
43:80b67b1a653c | 44:57054fa43189 |
---|---|
14 } | 14 } |
15 | 15 |
16 @Override public Object eval(LuaStateImpl lua) throws LuaException { | 16 @Override public Object eval(LuaStateImpl lua) throws LuaException { |
17 Object o1 = op1.eval(lua); | 17 Object o1 = op1.eval(lua); |
18 Object o2 = op2.eval(lua); | 18 Object o2 = op2.eval(lua); |
19 if( o1 instanceof LuaNumber && o2 instanceof LuaNumber ) { | 19 return lua.isLessThan(se,o1,o2); |
20 LuaNumber n1 = (LuaNumber)o1; | |
21 LuaNumber n2 = (LuaNumber)o2; | |
22 return n1.compareTo(n2) < 0; | |
23 } | |
24 if( o1 instanceof String && o2 instanceof String ) { | |
25 String s1 = (String)o1; | |
26 String s2 = (String)o2; | |
27 return s1.compareTo(s2) < 0; | |
28 } | |
29 LuaFunction fn = lua.getBinHandler(se,"__lt",o1,o2); | |
30 if( fn != null ) | |
31 return Lua.toBoolean( Lua.first(lua.call(fn,se,"__lt",o1,o2)) ); | |
32 throw new LuaException( lua, se, "attempt to compare " + Lua.type(o1) + " with " + Lua.type(o2) ); | |
33 } | 20 } |
34 } | 21 } |