comparison core/src/luan/impl/SetTableEntry.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
4 import luan.LuanTable; 4 import luan.LuanTable;
5 import luan.Luan; 5 import luan.Luan;
6 import luan.LuanFunction; 6 import luan.LuanFunction;
7 import luan.LuanElement; 7 import luan.LuanElement;
8 import luan.LuanMeta; 8 import luan.LuanMeta;
9 import luan.LuanBit;
10 import luan.modules.JavaLuan; 9 import luan.modules.JavaLuan;
11 10
12 11
13 final class SetTableEntry extends CodeImpl implements Settable { 12 final class SetTableEntry extends CodeImpl implements Settable {
14 private final Expr tableExpr; 13 private final Expr tableExpr;
23 @Override public void set(LuanStateImpl luan,Object value) throws LuanException { 22 @Override public void set(LuanStateImpl luan,Object value) throws LuanException {
24 newIndex( luan, tableExpr.eval(luan), keyExpr.eval(luan), value ); 23 newIndex( luan, tableExpr.eval(luan), keyExpr.eval(luan), value );
25 } 24 }
26 25
27 private void newIndex(LuanStateImpl luan,Object t,Object key,Object value) throws LuanException { 26 private void newIndex(LuanStateImpl luan,Object t,Object key,Object value) throws LuanException {
28 LuanBit bit = luan.bit(el()); 27 luan.push(el,null);
29 if( t instanceof LuanTable ) { 28 try {
30 LuanTable tbl = (LuanTable)t; 29 if( t instanceof LuanTable ) {
31 bit.put(tbl,key,value); 30 LuanTable tbl = (LuanTable)t;
32 return; 31 tbl.put(luan,key,value);
32 return;
33 }
34 if( t != null && luan.hasJava() )
35 JavaLuan.__new_index(luan,t,key,value);
36 else
37 throw luan.exception( "attempt to index a " + Luan.type(t) + " value in '"+el.text()+"'" );
38 } finally {
39 luan.pop();
33 } 40 }
34 if( t != null && luan.hasJava() )
35 JavaLuan.__new_index(bit,t,key,value);
36 else
37 throw bit.exception( "attempt to index a " + Luan.type(t) + " value in '"+bit.el.text()+"'" );
38 } 41 }
39 42
40 } 43 }