Mercurial Hosting > luan
comparison src/luan/interp/SetStmt.java @ 11:b7d7069fee58
add assignment statement and CmdLine
git-svn-id: https://luan-java.googlecode.com/svn/trunk@12 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 22 Nov 2012 10:51:56 +0000 |
parents | 24fd6381caca |
children | 3b22ffbdb83a |
comparison
equal
deleted
inserted
replaced
10:8217d8485715 | 11:b7d7069fee58 |
---|---|
5 import luan.LuaState; | 5 import luan.LuaState; |
6 import luan.LuaException; | 6 import luan.LuaException; |
7 import luan.LuaTable; | 7 import luan.LuaTable; |
8 | 8 |
9 | 9 |
10 final class SetStmt extends Stmt { | 10 final class SetStmt implements Stmt { |
11 | 11 |
12 static class Var { | 12 static class Var { |
13 final Expr table; | 13 final Expr table; |
14 final Expr key; | 14 final Expr key; |
15 | 15 |
18 this.key = key; | 18 this.key = key; |
19 } | 19 } |
20 } | 20 } |
21 | 21 |
22 private final Var[] vars; | 22 private final Var[] vars; |
23 private final Values values; | 23 private final Expressions expressions; |
24 | 24 |
25 SetStmt(Var[] vars,Values values) { | 25 SetStmt(Var[] vars,Expressions expressions) { |
26 this.vars = vars; | 26 this.vars = vars; |
27 this.values = values; | 27 this.expressions = expressions; |
28 } | 28 } |
29 | 29 |
30 @Override void eval(LuaState lua) throws LuaException { | 30 @Override public void eval(LuaState lua) throws LuaException { |
31 List vals = values.eval(lua); | 31 List vals = expressions.eval(lua); |
32 int n = vals.size(); | 32 int n = vals.size(); |
33 for( int i=0; i<vars.length; i++ ) { | 33 for( int i=0; i<vars.length; i++ ) { |
34 Var var = vars[i]; | 34 Var var = vars[i]; |
35 Object t = var.table.eval(lua); | 35 Object t = var.table.eval(lua); |
36 if( !(t instanceof LuaTable) ) | 36 if( !(t instanceof LuaTable) ) |