Mercurial Hosting > luan
view src/luan/interp/AddExpr.java @ 44:57054fa43189
implement table lib
git-svn-id: https://luan-java.googlecode.com/svn/trunk@45 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 26 Dec 2012 23:53:25 +0000 |
parents | e3624b7cd603 |
children | a443637829c1 |
line wrap: on
line source
package luan.interp; import luan.Lua; import luan.LuaNumber; import luan.LuaException; import luan.LuaSource; final class AddExpr extends BinaryOpExpr { AddExpr(LuaSource.Element se,Expr op1,Expr op2) { super(se,op1,op2); } @Override public Object eval(LuaStateImpl lua) throws LuaException { Object o1 = op1.eval(lua); Object o2 = op2.eval(lua); LuaNumber n1 = Lua.toNumber(o1); LuaNumber n2 = Lua.toNumber(o2); if( n1 != null && n2 != null ) return LuaNumber.of( n1.value() + n2.value() ); return arithmetic(lua,"__add",o1,o2); } }