Mercurial Hosting > luan
comparison src/luan/impl/DivExpr.java @ 166:4eaee12f6c65
move luan/interp to impl
git-svn-id: https://luan-java.googlecode.com/svn/trunk@167 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sun, 22 Jun 2014 04:17:38 +0000 |
parents | src/luan/interp/DivExpr.java@8ede219cd111 |
children |
comparison
equal
deleted
inserted
replaced
165:94bbc4cbc106 | 166:4eaee12f6c65 |
---|---|
1 package luan.impl; | |
2 | |
3 import luan.Luan; | |
4 import luan.LuanException; | |
5 import luan.LuanSource; | |
6 | |
7 | |
8 final class DivExpr extends BinaryOpExpr { | |
9 | |
10 DivExpr(LuanSource.Element se,Expr op1,Expr op2) { | |
11 super(se,op1,op2); | |
12 } | |
13 | |
14 @Override public Object eval(LuanStateImpl luan) throws LuanException { | |
15 Object o1 = op1.eval(luan); | |
16 Object o2 = op2.eval(luan); | |
17 Number n1 = Luan.toNumber(o1); | |
18 Number n2 = Luan.toNumber(o2); | |
19 if( n1 != null && n2 != null ) | |
20 return n1.doubleValue() / n2.doubleValue(); | |
21 return arithmetic(luan,"__div",o1,o2); | |
22 } | |
23 } |