comparison src/luan/interp/LengthExpr.java @ 3:7a2cdbc5767f

add LuaState git-svn-id: https://luan-java.googlecode.com/svn/trunk@4 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 16 Nov 2012 05:23:12 +0000
parents 4da26b11d12a
children
comparison
equal deleted inserted replaced
2:4da26b11d12a 3:7a2cdbc5767f
2 2
3 import luan.Lua; 3 import luan.Lua;
4 import luan.LuaNumber; 4 import luan.LuaNumber;
5 import luan.LuaTable; 5 import luan.LuaTable;
6 import luan.LuaException; 6 import luan.LuaException;
7 import luan.LuaState;
7 8
8 9
9 final class LengthExpr extends UnaryOpExpr { 10 final class LengthExpr extends UnaryOpExpr {
10 11
11 LengthExpr(Expr op) { 12 LengthExpr(Expr op) {
12 super(op); 13 super(op);
13 } 14 }
14 15
15 @Override Object eval() throws LuaException { 16 @Override Object eval(LuaState lua) throws LuaException {
16 return new LuaNumber( length(op.eval()) ); 17 return new LuaNumber( length(op.eval(lua)) );
17 } 18 }
18 19
19 private static int length(Object obj) throws LuaException { 20 private static int length(Object obj) throws LuaException {
20 if( obj instanceof String ) { 21 if( obj instanceof String ) {
21 String s = (String)obj; 22 String s = (String)obj;