Mercurial Hosting > luan
comparison src/luan/interp/SetTableEntry.java @ 49:8ede219cd111
add WebShell
git-svn-id: https://luan-java.googlecode.com/svn/trunk@50 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 28 Dec 2012 19:35:04 +0000 |
parents | 64ecb7a3aad7 |
children | a68ccb7aaa9c |
comparison
equal
deleted
inserted
replaced
48:64ecb7a3aad7 | 49:8ede219cd111 |
---|---|
15 super(se); | 15 super(se); |
16 this.tableExpr = tableExpr; | 16 this.tableExpr = tableExpr; |
17 this.keyExpr = keyExpr; | 17 this.keyExpr = keyExpr; |
18 } | 18 } |
19 | 19 |
20 @Override public void set(LuanStateImpl lua,Object value) throws LuanException { | 20 @Override public void set(LuanStateImpl luan,Object value) throws LuanException { |
21 newindex( lua, tableExpr.eval(lua), keyExpr.eval(lua), value ); | 21 newindex( luan, tableExpr.eval(luan), keyExpr.eval(luan), value ); |
22 } | 22 } |
23 | 23 |
24 private void newindex(LuanStateImpl lua,Object t,Object key,Object value) throws LuanException { | 24 private void newindex(LuanStateImpl luan,Object t,Object key,Object value) throws LuanException { |
25 Object h; | 25 Object h; |
26 if( t instanceof LuanTable ) { | 26 if( t instanceof LuanTable ) { |
27 LuanTable table = (LuanTable)t; | 27 LuanTable table = (LuanTable)t; |
28 Object old = table.put(key,value); | 28 Object old = table.put(key,value); |
29 if( old != null ) | 29 if( old != null ) |
30 return; | 30 return; |
31 h = lua.getHandler("__newindex",t); | 31 h = luan.getHandler("__newindex",t); |
32 if( h==null ) | 32 if( h==null ) |
33 return; | 33 return; |
34 table.put(key,old); | 34 table.put(key,old); |
35 } else { | 35 } else { |
36 h = lua.getHandler("__newindex",t); | 36 h = luan.getHandler("__newindex",t); |
37 if( h==null ) | 37 if( h==null ) |
38 throw new LuanException( lua, se, "attempt to index a " + Luan.type(t) + " value" ); | 38 throw new LuanException( luan, se, "attempt to index a " + Luan.type(t) + " value" ); |
39 } | 39 } |
40 if( h instanceof LuanFunction ) { | 40 if( h instanceof LuanFunction ) { |
41 LuanFunction fn = (LuanFunction)h; | 41 LuanFunction fn = (LuanFunction)h; |
42 lua.call(fn,se,"__newindex",t,key,value); | 42 luan.call(fn,se,"__newindex",t,key,value); |
43 } | 43 } |
44 newindex(lua,h,key,value); | 44 newindex(luan,h,key,value); |
45 } | 45 } |
46 | 46 |
47 } | 47 } |