Mercurial Hosting > luan
comparison src/luan/interp/PowExpr.java @ 46:a443637829c1
remove LuaNumber
git-svn-id: https://luan-java.googlecode.com/svn/trunk@47 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 27 Dec 2012 01:48:36 +0000 |
parents | 57054fa43189 |
children | 64ecb7a3aad7 |
comparison
equal
deleted
inserted
replaced
45:b1b14d09fc98 | 46:a443637829c1 |
---|---|
1 package luan.interp; | 1 package luan.interp; |
2 | 2 |
3 import luan.Lua; | 3 import luan.Lua; |
4 import luan.LuaNumber; | |
5 import luan.LuaException; | 4 import luan.LuaException; |
6 import luan.LuaSource; | 5 import luan.LuaSource; |
7 | 6 |
8 | 7 |
9 final class PowExpr extends BinaryOpExpr { | 8 final class PowExpr extends BinaryOpExpr { |
13 } | 12 } |
14 | 13 |
15 @Override public Object eval(LuaStateImpl lua) throws LuaException { | 14 @Override public Object eval(LuaStateImpl lua) throws LuaException { |
16 Object o1 = op1.eval(lua); | 15 Object o1 = op1.eval(lua); |
17 Object o2 = op2.eval(lua); | 16 Object o2 = op2.eval(lua); |
18 LuaNumber n1 = Lua.toNumber(o1); | 17 Number n1 = Lua.toNumber(o1); |
19 LuaNumber n2 = Lua.toNumber(o2); | 18 Number n2 = Lua.toNumber(o2); |
20 if( n1 != null && n2 != null ) | 19 if( n1 != null && n2 != null ) |
21 return LuaNumber.of( Math.pow( n1.value(), n2.value() ) ); | 20 return Math.pow( n1.doubleValue(), n2.doubleValue() ); |
22 return arithmetic(lua,"__pow",o1,o2); | 21 return arithmetic(lua,"__pow",o1,o2); |
23 } | 22 } |
24 } | 23 } |