Mercurial Hosting > luan
view core/src/luan/impl/UnmExpr.java @ 449:e89bf64a0d05
fix parse error
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 04 May 2015 20:36:30 -0600 |
parents | bbad2d06f728 |
children | b48cfa14ba60 |
line wrap: on
line source
package luan.impl; import luan.Luan; import luan.LuanFunction; import luan.LuanException; import luan.LuanSource; import luan.LuanBit; import luan.LuanTable; // unary minus final class UnmExpr extends UnaryOpExpr { UnmExpr(LuanSource.Element se,Expr op) { super(se,op); } @Override public Object eval(LuanStateImpl luan) throws LuanException { Object o = op.eval(luan); if( o instanceof Number ) return -((Number)o).doubleValue(); LuanBit bit = luan.bit(se); if( o instanceof LuanTable ) { LuanFunction fn = bit.getHandlerFunction("__unm",(LuanTable)o); if( fn != null ) { return Luan.first(bit.call(fn,"__unm",new Object[]{o})); } } throw bit.exception("attempt to perform arithmetic on a "+Luan.type(o)+" value"); } }