Mercurial Hosting > luan
comparison src/luan/interp/LenExpr.java @ 31:5cf15507d77e
separate interpreter from interface
git-svn-id: https://luan-java.googlecode.com/svn/trunk@32 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 13 Dec 2012 02:50:04 +0000 |
parents | b7d7069fee58 |
children | e51906de0f11 |
comparison
equal
deleted
inserted
replaced
30:8d8f4f5caef4 | 31:5cf15507d77e |
---|---|
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; | |
8 | 7 |
9 | 8 |
10 final class LenExpr extends UnaryOpExpr { | 9 final class LenExpr extends UnaryOpExpr { |
11 | 10 |
12 LenExpr(Expr op) { | 11 LenExpr(Expr op) { |
13 super(op); | 12 super(op); |
14 } | 13 } |
15 | 14 |
16 @Override public Object eval(LuaState lua) throws LuaException { | 15 @Override public Object eval(LuaStateImpl lua) throws LuaException { |
17 return new LuaNumber( length(op.eval(lua)) ); | 16 return new LuaNumber( length(op.eval(lua)) ); |
18 } | 17 } |
19 | 18 |
20 private static int length(Object obj) throws LuaException { | 19 private static int length(Object obj) throws LuaException { |
21 if( obj instanceof String ) { | 20 if( obj instanceof String ) { |