Mercurial Hosting > luan
comparison src/luan/interp/UnmExpr.java @ 49:8ede219cd111
add WebShell
git-svn-id: https://luan-java.googlecode.com/svn/trunk@50 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 28 Dec 2012 19:35:04 +0000 |
parents | 64ecb7a3aad7 |
children | 6ca02b188dba |
comparison
equal
deleted
inserted
replaced
48:64ecb7a3aad7 | 49:8ede219cd111 |
---|---|
11 | 11 |
12 UnmExpr(LuanSource.Element se,Expr op) { | 12 UnmExpr(LuanSource.Element se,Expr op) { |
13 super(se,op); | 13 super(se,op); |
14 } | 14 } |
15 | 15 |
16 @Override public Object eval(LuanStateImpl lua) throws LuanException { | 16 @Override public Object eval(LuanStateImpl luan) throws LuanException { |
17 Object o = op.eval(lua); | 17 Object o = op.eval(luan); |
18 Number n = Luan.toNumber(o); | 18 Number n = Luan.toNumber(o); |
19 if( n != null ) | 19 if( n != null ) |
20 return -n.doubleValue(); | 20 return -n.doubleValue(); |
21 LuanFunction fn = lua.getHandlerFunction(se,"__unm",o); | 21 LuanFunction fn = luan.getHandlerFunction(se,"__unm",o); |
22 if( fn != null ) { | 22 if( fn != null ) { |
23 return Luan.first(lua.call(fn,se,"__unm",o)); | 23 return Luan.first(luan.call(fn,se,"__unm",o)); |
24 } | 24 } |
25 throw new LuanException(lua,se,"attempt to perform arithmetic on a "+Luan.type(o)+" value"); | 25 throw new LuanException(luan,se,"attempt to perform arithmetic on a "+Luan.type(o)+" value"); |
26 } | 26 } |
27 } | 27 } |