Mercurial Hosting > luan
comparison src/luan/interp/EqExpr.java @ 40:e3624b7cd603
implement stack trace
git-svn-id: https://luan-java.googlecode.com/svn/trunk@41 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 21 Dec 2012 10:45:54 +0000 |
parents | 8a57ebfdfd78 |
children | a443637829c1 |
comparison
equal
deleted
inserted
replaced
39:e5bcb1eeafc1 | 40:e3624b7cd603 |
---|---|
3 import luan.Lua; | 3 import luan.Lua; |
4 import luan.LuaNumber; | 4 import luan.LuaNumber; |
5 import luan.LuaFunction; | 5 import luan.LuaFunction; |
6 import luan.LuaTable; | 6 import luan.LuaTable; |
7 import luan.LuaException; | 7 import luan.LuaException; |
8 import luan.LuaSource; | |
8 | 9 |
9 | 10 |
10 final class EqExpr extends BinaryOpExpr { | 11 final class EqExpr extends BinaryOpExpr { |
11 | 12 |
12 EqExpr(Expr op1,Expr op2) { | 13 EqExpr(LuaSource.Element se,Expr op1,Expr op2) { |
13 super(op1,op2); | 14 super(se,op1,op2); |
14 } | 15 } |
15 | 16 |
16 @Override public Object eval(LuaStateImpl lua) throws LuaException { | 17 @Override public Object eval(LuaStateImpl lua) throws LuaException { |
17 Object o1 = op1.eval(lua); | 18 Object o1 = op1.eval(lua); |
18 Object o2 = op2.eval(lua); | 19 Object o2 = op2.eval(lua); |
25 if( mt1==null || mt2==null ) | 26 if( mt1==null || mt2==null ) |
26 return false; | 27 return false; |
27 Object f = mt1.get("__eq"); | 28 Object f = mt1.get("__eq"); |
28 if( f == null || !f.equals(mt2.get("__eq")) ) | 29 if( f == null || !f.equals(mt2.get("__eq")) ) |
29 return null; | 30 return null; |
30 LuaFunction fn = Lua.checkFunction(f); | 31 LuaFunction fn = lua.checkFunction(se,f); |
31 return Lua.toBoolean( Utils.first(fn.call(lua,o1,o2)) ); | 32 return Lua.toBoolean( Lua.first(lua.call(fn,se,"__eq",o1,o2)) ); |
32 } | 33 } |
33 } | 34 } |