Mercurial Hosting > luan
annotate 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 |
rev | line source |
---|---|
166
4eaee12f6c65
move luan/interp to impl
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
112
diff
changeset
|
1 package luan.impl; |
17
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
2 |
48
64ecb7a3aad7
rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
40
diff
changeset
|
3 import luan.LuanException; |
64ecb7a3aad7
rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
40
diff
changeset
|
4 import luan.LuanTable; |
64ecb7a3aad7
rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
40
diff
changeset
|
5 import luan.Luan; |
64ecb7a3aad7
rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
40
diff
changeset
|
6 import luan.LuanFunction; |
460 | 7 import luan.LuanElement; |
405 | 8 import luan.LuanMeta; |
404
d55e873e1f0d
metatables now only apply to tables
Franklin Schmidt <fschmidt@gmail.com>
parents:
224
diff
changeset
|
9 import luan.modules.JavaLuan; |
17
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
10 |
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
11 |
40
e3624b7cd603
implement stack trace
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
37
diff
changeset
|
12 final class SetTableEntry extends CodeImpl implements Settable { |
17
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
13 private final Expr tableExpr; |
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
14 private final Expr keyExpr; |
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
15 |
460 | 16 SetTableEntry(LuanElement el,Expr tableExpr,Expr keyExpr) { |
17 super(el); | |
17
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
18 this.tableExpr = tableExpr; |
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
19 this.keyExpr = keyExpr; |
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
20 } |
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
21 |
49
8ede219cd111
add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
48
diff
changeset
|
22 @Override public void set(LuanStateImpl luan,Object value) throws LuanException { |
428
df95199ca4c0
rename __newindex to __new_index
Franklin Schmidt <fschmidt@gmail.com>
parents:
427
diff
changeset
|
23 newIndex( luan, tableExpr.eval(luan), keyExpr.eval(luan), value ); |
35
e51906de0f11
implement metatables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
31
diff
changeset
|
24 } |
e51906de0f11
implement metatables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
31
diff
changeset
|
25 |
428
df95199ca4c0
rename __newindex to __new_index
Franklin Schmidt <fschmidt@gmail.com>
parents:
427
diff
changeset
|
26 private void newIndex(LuanStateImpl luan,Object t,Object key,Object value) throws LuanException { |
576 | 27 luan.push(el,null); |
28 try { | |
29 if( t instanceof LuanTable ) { | |
30 LuanTable tbl = (LuanTable)t; | |
31 tbl.put(luan,key,value); | |
32 return; | |
33 } | |
34 if( t != null && luan.hasJava() ) | |
35 JavaLuan.__new_index(luan,t,key,value); | |
36 else | |
578
60c549d43988
remove LuanState.exception()
Franklin Schmidt <fschmidt@gmail.com>
parents:
576
diff
changeset
|
37 throw new LuanException(luan, "attempt to index a " + Luan.type(t) + " value in '"+el.text()+"'" ); |
576 | 38 } finally { |
39 luan.pop(); | |
35
e51906de0f11
implement metatables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
31
diff
changeset
|
40 } |
17
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
41 } |
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
42 |
09d41f7490a8
add local variables
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
43 } |