Mercurial Hosting > luan
annotate core/src/luan/impl/DivExpr.java @ 532:9bf9ad733827
add logging/init so that logging can be used if initialized elsewhere
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 27 May 2015 22:19:46 -0600 |
parents | b48cfa14ba60 |
children | 859c0dedc8b6 |
rev | line source |
---|---|
166
4eaee12f6c65
move luan/interp to impl
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
49
diff
changeset
|
1 package luan.impl; |
7
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.LuanException; |
460 | 4 import luan.LuanElement; |
7
bca8fc5d928b
work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
5 |
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 final class DivExpr extends BinaryOpExpr { |
bca8fc5d928b
work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
8 |
460 | 9 DivExpr(LuanElement 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
|
10 super(se,op1,op2); |
7
bca8fc5d928b
work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
11 } |
bca8fc5d928b
work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
12 |
49
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
48
diff
changeset
|
13 @Override public Object eval(LuanStateImpl luan) throws LuanException { |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
48
diff
changeset
|
14 Object o1 = op1.eval(luan); |
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
48
diff
changeset
|
15 Object o2 = op2.eval(luan); |
446
bbad2d06f728
remove automatic conversion from string to number
Franklin Schmidt <fschmidt@gmail.com>
parents:
171
diff
changeset
|
16 if( o1 instanceof Number && o2 instanceof Number ) |
bbad2d06f728
remove automatic conversion from string to number
Franklin Schmidt <fschmidt@gmail.com>
parents:
171
diff
changeset
|
17 return ((Number)o1).doubleValue() / ((Number)o2).doubleValue(); |
49
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
48
diff
changeset
|
18 return arithmetic(luan,"__div",o1,o2); |
7
bca8fc5d928b
work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
19 } |
bca8fc5d928b
work on expressions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
20 } |