Mercurial Hosting > luan
comparison src/luan/Luan.java @ 1562:b89212fd04b5
remove table.luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 08 Nov 2020 16:50:59 -0700 |
parents | e1a13e707bf3 |
children | 8fbcc4747091 |
comparison
equal
deleted
inserted
replaced
1561:e1a13e707bf3 | 1562:b89212fd04b5 |
---|---|
91 } | 91 } |
92 | 92 |
93 public Object index(Object obj,Object key) throws LuanException { | 93 public Object index(Object obj,Object key) throws LuanException { |
94 if( obj instanceof LuanTable ) { | 94 if( obj instanceof LuanTable ) { |
95 LuanTable tbl = (LuanTable)obj; | 95 LuanTable tbl = (LuanTable)obj; |
96 return tbl.get(key); | 96 return tbl.get(this,key); |
97 } | 97 } |
98 if( obj != null && peek().javaOk ) | 98 if( obj != null && peek().javaOk ) |
99 return JavaLuan.__index(this,obj,key); | 99 return JavaLuan.__index(this,obj,key); |
100 throw new LuanException("attempt to index a " + Luan.type(obj) + " value" ); | 100 throw new LuanException("attempt to index a " + Luan.type(obj) + " value" ); |
101 } | 101 } |
138 if( obj == null ) | 138 if( obj == null ) |
139 return null; | 139 return null; |
140 if( obj instanceof LuanTable ) | 140 if( obj instanceof LuanTable ) |
141 return (LuanTable)obj; | 141 return (LuanTable)obj; |
142 if( obj instanceof List ) { | 142 if( obj instanceof List ) { |
143 return new LuanTable(this,(List)obj); | 143 return new LuanTable((List)obj); |
144 } | 144 } |
145 if( obj instanceof Map ) { | 145 if( obj instanceof Map ) { |
146 return new LuanTable(this,(Map)obj); | 146 return new LuanTable((Map)obj); |
147 } | 147 } |
148 if( obj instanceof Set ) { | 148 if( obj instanceof Set ) { |
149 return new LuanTable(this,(Set)obj); | 149 return new LuanTable((Set)obj); |
150 } | 150 } |
151 Class cls = obj.getClass(); | 151 Class cls = obj.getClass(); |
152 if( cls.isArray() ) { | 152 if( cls.isArray() ) { |
153 if( cls.getComponentType().isPrimitive() ) { | 153 if( cls.getComponentType().isPrimitive() ) { |
154 int len = Array.getLength(obj); | 154 int len = Array.getLength(obj); |
155 List list = new ArrayList(); | 155 List list = new ArrayList(); |
156 for( int i=0; i<len; i++ ) { | 156 for( int i=0; i<len; i++ ) { |
157 list.add(Array.get(obj,i)); | 157 list.add(Array.get(obj,i)); |
158 } | 158 } |
159 return new LuanTable(this,list); | 159 return new LuanTable(list); |
160 } else { | 160 } else { |
161 Object[] a = (Object[])obj; | 161 Object[] a = (Object[])obj; |
162 return new LuanTable(this,Arrays.asList(a)); | 162 return new LuanTable(Arrays.asList(a)); |
163 } | 163 } |
164 } | 164 } |
165 return null; | 165 return null; |
166 } | 166 } |
167 | 167 |