Mercurial Hosting > luan
comparison core/src/luan/impl/UnmExpr.java @ 446:bbad2d06f728
remove automatic conversion from string to number
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 04 May 2015 16:21:17 -0600 |
parents | d55e873e1f0d |
children | b48cfa14ba60 |
comparison
equal
deleted
inserted
replaced
445:cc7d246bda2a | 446:bbad2d06f728 |
---|---|
15 super(se,op); | 15 super(se,op); |
16 } | 16 } |
17 | 17 |
18 @Override public Object eval(LuanStateImpl luan) throws LuanException { | 18 @Override public Object eval(LuanStateImpl luan) throws LuanException { |
19 Object o = op.eval(luan); | 19 Object o = op.eval(luan); |
20 Number n = Luan.toNumber(o); | 20 if( o instanceof Number ) |
21 if( n != null ) | 21 return -((Number)o).doubleValue(); |
22 return -n.doubleValue(); | |
23 LuanBit bit = luan.bit(se); | 22 LuanBit bit = luan.bit(se); |
24 if( o instanceof LuanTable ) { | 23 if( o instanceof LuanTable ) { |
25 LuanFunction fn = bit.getHandlerFunction("__unm",(LuanTable)o); | 24 LuanFunction fn = bit.getHandlerFunction("__unm",(LuanTable)o); |
26 if( fn != null ) { | 25 if( fn != null ) { |
27 return Luan.first(bit.call(fn,"__unm",new Object[]{o})); | 26 return Luan.first(bit.call(fn,"__unm",new Object[]{o})); |