comparison core/src/luan/impl/BinaryOpExpr.java @ 647:8e8c30b72e9b

move methods from LuanState to Luan
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 29 Mar 2016 20:39:14 -0600
parents cdc70de628b5
children
comparison
equal deleted inserted replaced
646:cdc70de628b5 647:8e8c30b72e9b
14 this.op1 = op1; 14 this.op1 = op1;
15 this.op2 = op2; 15 this.op2 = op2;
16 } 16 }
17 17
18 Object arithmetic(LuanStateImpl luan,String op,Object o1,Object o2) throws LuanException { 18 Object arithmetic(LuanStateImpl luan,String op,Object o1,Object o2) throws LuanException {
19 LuanFunction fn = luan.getBinHandler(op,o1,o2); 19 LuanFunction fn = Luan.getBinHandler(op,o1,o2);
20 if( fn != null ) 20 if( fn != null )
21 return Luan.first(fn.call(luan,new Object[]{o1,o2})); 21 return Luan.first(fn.call(luan,new Object[]{o1,o2}));
22 String type = !(o1 instanceof Number) ? Luan.type(o1) : Luan.type(o2); 22 String type = !(o1 instanceof Number) ? Luan.type(o1) : Luan.type(o2);
23 throw new LuanException("attempt to perform arithmetic on a "+type+" value"); 23 throw new LuanException("attempt to perform arithmetic on a "+type+" value");
24 } 24 }