Mercurial Hosting > luan
view core/src/luan/impl/ModExpr.java @ 171:3dcb0f9bee82
add core component
git-svn-id: https://luan-java.googlecode.com/svn/trunk@172 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sun, 22 Jun 2014 05:41:22 +0000 |
parents | src/luan/impl/ModExpr.java@4eaee12f6c65 |
children | 6e11eace1091 |
line wrap: on
line source
package luan.impl; import luan.Luan; import luan.LuanException; import luan.LuanSource; final class ModExpr extends BinaryOpExpr { ModExpr(LuanSource.Element se,Expr op1,Expr op2) { super(se,op1,op2); } @Override public Object eval(LuanStateImpl luan) throws LuanException { Object o1 = op1.eval(luan); Object o2 = op2.eval(luan); Number n1 = Luan.toNumber(o1); Number n2 = Luan.toNumber(o2); if( n1 != null && n2 != null ) return n1.doubleValue() % n2.doubleValue(); return arithmetic(luan,"__mod",o1,o2); } }