Mercurial Hosting > luan
comparison core/src/luan/impl/LenExpr.java @ 576:4723d22062ce
remove LuanBit
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 13 Jul 2015 20:38:26 -0600 |
parents | 7c3ad6db8ac3 |
children | 60c549d43988 |
comparison
equal
deleted
inserted
replaced
575:7c3ad6db8ac3 | 576:4723d22062ce |
---|---|
3 import luan.Luan; | 3 import luan.Luan; |
4 import luan.LuanTable; | 4 import luan.LuanTable; |
5 import luan.LuanFunction; | 5 import luan.LuanFunction; |
6 import luan.LuanException; | 6 import luan.LuanException; |
7 import luan.LuanElement; | 7 import luan.LuanElement; |
8 import luan.LuanBit; | |
9 | 8 |
10 | 9 |
11 final class LenExpr extends UnaryOpExpr { | 10 final class LenExpr extends UnaryOpExpr { |
12 | 11 |
13 LenExpr(LuanElement el,Expr op) { | 12 LenExpr(LuanElement el,Expr op) { |
22 } | 21 } |
23 if( o instanceof byte[] ) { | 22 if( o instanceof byte[] ) { |
24 byte[] a = (byte[])o; | 23 byte[] a = (byte[])o; |
25 return a.length; | 24 return a.length; |
26 } | 25 } |
27 LuanBit bit = luan.bit(el); | 26 luan.push(el,null); |
28 if( !(o instanceof LuanTable) ) | 27 try { |
29 throw bit.exception( "attempt to get length of a " + Luan.type(o) + " value" ); | 28 if( !(o instanceof LuanTable) ) |
30 LuanTable t = (LuanTable)o; | 29 throw luan.exception( "attempt to get length of a " + Luan.type(o) + " value" ); |
31 return bit.length(t); | 30 LuanTable t = (LuanTable)o; |
31 return t.length(luan); | |
32 } finally { | |
33 luan.pop(); | |
34 } | |
32 } | 35 } |
33 } | 36 } |