Mercurial Hosting > luan
comparison src/luan/interp/UnmExpr.java @ 7:bca8fc5d928b
work on expressions
git-svn-id: https://luan-java.googlecode.com/svn/trunk@8 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 20 Nov 2012 10:06:27 +0000 |
parents | |
children | b7d7069fee58 |
comparison
equal
deleted
inserted
replaced
6:a315783c9524 | 7:bca8fc5d928b |
---|---|
1 package luan.interp; | |
2 | |
3 import luan.Lua; | |
4 import luan.LuaNumber; | |
5 import luan.LuaException; | |
6 import luan.LuaState; | |
7 | |
8 | |
9 // unary minus | |
10 final class UnmExpr extends UnaryOpExpr { | |
11 | |
12 UnmExpr(Expr op) { | |
13 super(op); | |
14 } | |
15 | |
16 @Override Object eval(LuaState lua) throws LuaException { | |
17 double n = Lua.checkNumber(op.eval(lua)).value(); | |
18 return new LuaNumber( -n ); | |
19 } | |
20 } |