annotate src/luan/interp/DivExpr.java @ 48:64ecb7a3aad7

rename Lua to Luan git-svn-id: https://luan-java.googlecode.com/svn/trunk@49 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 28 Dec 2012 03:29:12 +0000
parents a443637829c1
children 8ede219cd111
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
bca8fc5d928b work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
1 package luan.interp;
bca8fc5d928b work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
2
48
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
3 import luan.Luan;
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
4 import luan.LuanException;
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
5 import luan.LuanSource;
7
bca8fc5d928b work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
6
bca8fc5d928b work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
7
bca8fc5d928b work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
8 final class DivExpr extends BinaryOpExpr {
bca8fc5d928b work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
9
48
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
10 DivExpr(LuanSource.Element se,Expr op1,Expr op2) {
40
e3624b7cd603 implement stack trace
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 37
diff changeset
11 super(se,op1,op2);
7
bca8fc5d928b work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
12 }
bca8fc5d928b work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
13
48
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
14 @Override public Object eval(LuanStateImpl lua) throws LuanException {
35
e51906de0f11 implement metatables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 31
diff changeset
15 Object o1 = op1.eval(lua);
e51906de0f11 implement metatables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 31
diff changeset
16 Object o2 = op2.eval(lua);
48
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
17 Number n1 = Luan.toNumber(o1);
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
18 Number n2 = Luan.toNumber(o2);
35
e51906de0f11 implement metatables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 31
diff changeset
19 if( n1 != null && n2 != null )
46
a443637829c1 remove LuaNumber
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 44
diff changeset
20 return n1.doubleValue() / n2.doubleValue();
40
e3624b7cd603 implement stack trace
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 37
diff changeset
21 return arithmetic(lua,"__div",o1,o2);
7
bca8fc5d928b work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
22 }
bca8fc5d928b work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
23 }