Mercurial Hosting > luan
view core/src/luan/impl/SetTableEntry.java @ 580:1e69d9c21461
add Table.clear();
add Http.response.reset();
fix http/run;
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 21 Jul 2015 14:56:41 -0600 |
parents | 60c549d43988 |
children | 859c0dedc8b6 |
line wrap: on
line source
package luan.impl; import luan.LuanException; import luan.LuanTable; import luan.Luan; import luan.LuanFunction; import luan.LuanElement; import luan.LuanMeta; import luan.modules.JavaLuan; final class SetTableEntry extends CodeImpl implements Settable { private final Expr tableExpr; private final Expr keyExpr; SetTableEntry(LuanElement el,Expr tableExpr,Expr keyExpr) { super(el); 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 { luan.push(el,null); try { if( t instanceof LuanTable ) { LuanTable tbl = (LuanTable)t; tbl.put(luan,key,value); return; } if( t != null && luan.hasJava() ) JavaLuan.__new_index(luan,t,key,value); else throw new LuanException(luan, "attempt to index a " + Luan.type(t) + " value in '"+el.text()+"'" ); } finally { luan.pop(); } } }