Mercurial Hosting > luan
comparison src/luan/interp/SetTableEntry.java @ 17:09d41f7490a8
add local variables
git-svn-id: https://luan-java.googlecode.com/svn/trunk@18 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 30 Nov 2012 11:46:34 +0000 |
parents | |
children | 5cf15507d77e |
comparison
equal
deleted
inserted
replaced
16:2a30281ef47c | 17:09d41f7490a8 |
---|---|
1 package luan.interp; | |
2 | |
3 import luan.LuaState; | |
4 import luan.LuaException; | |
5 import luan.LuaTable; | |
6 import luan.Lua; | |
7 | |
8 | |
9 final class SetTableEntry implements Settable { | |
10 private final Expr tableExpr; | |
11 private final Expr keyExpr; | |
12 | |
13 SetTableEntry(Expr tableExpr,Expr keyExpr) { | |
14 this.tableExpr = tableExpr; | |
15 this.keyExpr = keyExpr; | |
16 } | |
17 | |
18 @Override public void set(LuaState lua,Object value) throws LuaException { | |
19 Object t = tableExpr.eval(lua); | |
20 if( !(t instanceof LuaTable) ) | |
21 throw new LuaException( "attempt to index a " + Lua.type(t) + " value" ); | |
22 LuaTable table = (LuaTable)t; | |
23 Object key = keyExpr.eval(lua); | |
24 table.set(key,value); | |
25 } | |
26 | |
27 } |