Mercurial Hosting > luan
comparison core/src/luan/impl/EqExpr.java @ 645:859c0dedc8b6
remove LuanSource
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 29 Mar 2016 18:09:51 -0600 |
parents | 4723d22062ce |
children | 8e8c30b72e9b |
comparison
equal
deleted
inserted
replaced
644:ba1e318377c5 | 645:859c0dedc8b6 |
---|---|
3 import java.util.Arrays; | 3 import java.util.Arrays; |
4 import luan.Luan; | 4 import luan.Luan; |
5 import luan.LuanFunction; | 5 import luan.LuanFunction; |
6 import luan.LuanTable; | 6 import luan.LuanTable; |
7 import luan.LuanException; | 7 import luan.LuanException; |
8 import luan.LuanElement; | |
9 | 8 |
10 | 9 |
11 final class EqExpr extends BinaryOpExpr { | 10 final class EqExpr extends BinaryOpExpr { |
12 | 11 |
13 EqExpr(LuanElement el,Expr op1,Expr op2) { | 12 EqExpr(Expr op1,Expr op2) { |
14 super(el,op1,op2); | 13 super(op1,op2); |
15 } | 14 } |
16 | 15 |
17 @Override public Object eval(LuanStateImpl luan) throws LuanException { | 16 @Override public Object eval(LuanStateImpl luan) throws LuanException { |
18 return eq(luan); | 17 return eq(luan); |
19 } | 18 } |
42 if( mt1==null || mt2==null ) | 41 if( mt1==null || mt2==null ) |
43 return false; | 42 return false; |
44 Object f = mt1.rawGet("__eq"); | 43 Object f = mt1.rawGet("__eq"); |
45 if( f == null || !f.equals(mt2.rawGet("__eq")) ) | 44 if( f == null || !f.equals(mt2.rawGet("__eq")) ) |
46 return false; | 45 return false; |
47 luan.push(el,"__eq"); | 46 LuanFunction fn = luan.checkFunction(f); |
48 try { | 47 return luan.checkBoolean( Luan.first(fn.call(luan,new Object[]{o1,o2})) ); |
49 LuanFunction fn = luan.checkFunction(f); | |
50 return luan.checkBoolean( Luan.first(fn.call(luan,new Object[]{o1,o2})) ); | |
51 } finally { | |
52 luan.pop(); | |
53 } | |
54 } | 48 } |
55 | 49 |
56 @Override public String toString() { | 50 @Override public String toString() { |
57 return "(EqExpr "+op1+" "+op2+")"; | 51 return "(EqExpr "+op1+" "+op2+")"; |
58 } | 52 } |