Mercurial Hosting > luan
view core/src/luan/impl/SetStmt.java @ 557:6268c1ce6ea8
sane queryparser update
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 21 Jun 2015 16:15:52 -0600 |
parents | 3dcb0f9bee82 |
children |
line wrap: on
line source
package luan.impl; import luan.Luan; import luan.LuanException; final class SetStmt implements Stmt { private final Settable[] vars; private final Expressions expressions; SetStmt(Settable var,Expr expr) { this( new Settable[]{var}, expr ); } SetStmt(Settable[] vars,Expressions expressions) { this.vars = vars; this.expressions = expressions; } @Override public void eval(LuanStateImpl luan) throws LuanException { final Object obj = expressions.eval(luan); if( obj instanceof Object[] ) { Object[] vals = (Object[])obj; for( int i=0; i<vars.length; i++ ) { Object val = i < vals.length ? vals[i] : null; vars[i].set(luan,val); } } else { vars[0].set(luan,obj); for( int i=1; i<vars.length; i++ ) { vars[i].set(luan,null); } } } }