Fix for table initializers greater than 50 elements.
This commit is contained in:
@@ -58,7 +58,6 @@ public class LuaC extends Lua implements LuaCompiler {
|
||||
public static final int MAXSTACK = 250;
|
||||
static final int LUAI_MAXUPVALUES = 60;
|
||||
static final int LUAI_MAXVARS = 200;
|
||||
static final int LFIELDS_PER_FLUSH = 50;
|
||||
static final int NO_REG = MAXARG_A;
|
||||
|
||||
/* masks for new-style vararg */
|
||||
|
||||
@@ -25,10 +25,6 @@ package org.luaj.vm;
|
||||
/**
|
||||
* Constants for lua limits and opcodes
|
||||
*
|
||||
* @author jim_roseborough
|
||||
*
|
||||
* @deprecated - this class will go away. Constants will probably move to LuaState
|
||||
*
|
||||
*/
|
||||
public class Lua {
|
||||
|
||||
@@ -324,6 +320,9 @@ public class Lua {
|
||||
return 0 != (luaP_opmodes[m] & (1 << 7));
|
||||
}
|
||||
|
||||
/* number of list items to accumulate before a SETLIST instruction */
|
||||
public static final int LFIELDS_PER_FLUSH = 50;
|
||||
|
||||
// type constants
|
||||
|
||||
public static final int LUA_TNONE = (-1);
|
||||
@@ -351,4 +350,5 @@ public class Lua {
|
||||
"value",
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -827,11 +827,10 @@ public class LuaState extends Lua {
|
||||
if (c == 0) {
|
||||
c = code[ci.pc++];
|
||||
}
|
||||
table = this.stack[base + a];
|
||||
for (int index = 1; index <= b; index++) {
|
||||
val = this.stack[listBase + index];
|
||||
table.luaSetTable(this, table, LInteger.valueOf(index),
|
||||
val);
|
||||
int offset = (c-1) * LFIELDS_PER_FLUSH;
|
||||
LTable tbl = (LTable) this.stack[base + a];
|
||||
for (int j=1; j<=b; j++) {
|
||||
tbl.put(offset+j, stack[listBase + j]);
|
||||
}
|
||||
top = base + a - 1;
|
||||
continue;
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
-- test table with more than 50 non-sequential integer elements
|
||||
-- test tables with more than 50 elements
|
||||
|
||||
local t = { 1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,1,1,
|
||||
}
|
||||
print ("#t=",#t,'t[1,50,51,59]', t[1], t[50], t[51], t[59])
|
||||
print (table.concat(t,','))
|
||||
|
||||
local t2= { 0,3,4,7,9,8,12,15,23,5,
|
||||
10,13,14,17,19,18,112,115,123,15,
|
||||
20,33,24,27,29,28,212,215,223,25,
|
||||
40,43,44,47,49,48,412,415,423,45,
|
||||
50,53,54,57,59,58,512,515,523,55,
|
||||
60,63,64,67,69,68,612,615,623,65,
|
||||
70,73,74,77,79,78,72,715,723,75,
|
||||
}
|
||||
|
||||
print ("#t2=",#t2,'t[1,50,51,59]', t[1], t[50], t[51], t[59])
|
||||
print (table.concat(t2,','))
|
||||
|
||||
local t = {
|
||||
[2000]='a', [2001]='b', [2002]='c', [2003]='d', [2004]='e', [2005]='f', [2006]='g', [2007]='h', [2008]='i', [2009]='j',
|
||||
[3000]='a', [3001]='b', [3002]='c', [3003]='d', [3004]='e', [3005]='f', [3006]='g', [3007]='h', [3008]='i', [3009]='j',
|
||||
|
||||
Reference in New Issue
Block a user