Mercurial Hosting > luan
comparison src/luan/interp/SubExpr.java @ 40:e3624b7cd603
implement stack trace
git-svn-id: https://luan-java.googlecode.com/svn/trunk@41 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 21 Dec 2012 10:45:54 +0000 |
parents | 8a57ebfdfd78 |
children | 57054fa43189 |
comparison
equal
deleted
inserted
replaced
39:e5bcb1eeafc1 | 40:e3624b7cd603 |
---|---|
1 package luan.interp; | 1 package luan.interp; |
2 | 2 |
3 import luan.Lua; | 3 import luan.Lua; |
4 import luan.LuaNumber; | 4 import luan.LuaNumber; |
5 import luan.LuaException; | 5 import luan.LuaException; |
6 import luan.LuaSource; | |
6 | 7 |
7 | 8 |
8 final class SubExpr extends BinaryOpExpr { | 9 final class SubExpr extends BinaryOpExpr { |
9 | 10 |
10 SubExpr(Expr op1,Expr op2) { | 11 SubExpr(LuaSource.Element se,Expr op1,Expr op2) { |
11 super(op1,op2); | 12 super(se,op1,op2); |
12 } | 13 } |
13 | 14 |
14 @Override public Object eval(LuaStateImpl lua) throws LuaException { | 15 @Override public Object eval(LuaStateImpl lua) throws LuaException { |
15 Object o1 = op1.eval(lua); | 16 Object o1 = op1.eval(lua); |
16 Object o2 = op2.eval(lua); | 17 Object o2 = op2.eval(lua); |
17 LuaNumber n1 = Lua.toNumber(o1); | 18 LuaNumber n1 = Lua.toNumber(o1); |
18 LuaNumber n2 = Lua.toNumber(o2); | 19 LuaNumber n2 = Lua.toNumber(o2); |
19 if( n1 != null && n2 != null ) | 20 if( n1 != null && n2 != null ) |
20 return new LuaNumber( n1.value() - n2.value() ); | 21 return new LuaNumber( n1.value() - n2.value() ); |
21 return lua.arithmetic("__sub",o1,o2); | 22 return arithmetic(lua,"__sub",o1,o2); |
22 } | 23 } |
23 } | 24 } |