Mercurial Hosting > luan
comparison src/luan/interp/UnmExpr.java @ 36:2a35154aec14
implement more basic lib functions
git-svn-id: https://luan-java.googlecode.com/svn/trunk@37 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 18 Dec 2012 09:53:42 +0000 |
parents | e51906de0f11 |
children | 8a57ebfdfd78 |
comparison
equal
deleted
inserted
replaced
35:e51906de0f11 | 36:2a35154aec14 |
---|---|
16 @Override public Object eval(LuaStateImpl lua) throws LuaException { | 16 @Override public Object eval(LuaStateImpl lua) throws LuaException { |
17 Object o = op.eval(lua); | 17 Object o = op.eval(lua); |
18 LuaNumber n = Lua.toNumber(o); | 18 LuaNumber n = Lua.toNumber(o); |
19 if( n != null ) | 19 if( n != null ) |
20 return new LuaNumber( -n.value() ); | 20 return new LuaNumber( -n.value() ); |
21 LuaFunction fn = Utils.getHandler("__unm",o); | 21 LuaFunction fn = Utils.getHandlerFunction("__unm",o); |
22 if( fn != null ) | 22 if( fn != null ) |
23 return Utils.first(fn.call(lua,o)); | 23 return Utils.first(fn.call(lua,o)); |
24 throw new LuaException("attempt to perform arithmetic on a "+Lua.type(o)+" value"); | 24 throw new LuaException("attempt to perform arithmetic on a "+Lua.type(o)+" value"); |
25 } | 25 } |
26 } | 26 } |