Mercurial Hosting > luan
view core/src/luan/impl/SetTableEntry.java @ 428:df95199ca4c0
rename __newindex to __new_index
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 02 May 2015 20:10:31 -0600 |
parents | dae264ad6a7b |
children | b48cfa14ba60 |
line wrap: on
line source
package luan.impl; import luan.LuanException; import luan.LuanTable; import luan.Luan; import luan.LuanFunction; import luan.LuanSource; import luan.LuanMeta; import luan.modules.JavaLuan; final class SetTableEntry extends CodeImpl implements Settable { private final Expr tableExpr; private final Expr keyExpr; SetTableEntry(LuanSource.Element se,Expr tableExpr,Expr keyExpr) { super(se); this.tableExpr = tableExpr; this.keyExpr = keyExpr; } @Override public void set(LuanStateImpl luan,Object value) throws LuanException { newIndex( luan, tableExpr.eval(luan), keyExpr.eval(luan), value ); } private void newIndex(LuanStateImpl luan,Object t,Object key,Object value) throws LuanException { if( t instanceof LuanTable ) { LuanTable tbl = (LuanTable)t; tbl.put(luan,key,value); return; } if( t != null && luan.currentEnvironment().hasJava() ) JavaLuan.__new_index(luan,t,key,value); else throw luan.bit(se).exception( "attempt to index '"+tableExpr.se().text()+"' (a " + Luan.type(t) + " value)" ); } }