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;
|
public static final int MAXSTACK = 250;
|
||||||
static final int LUAI_MAXUPVALUES = 60;
|
static final int LUAI_MAXUPVALUES = 60;
|
||||||
static final int LUAI_MAXVARS = 200;
|
static final int LUAI_MAXVARS = 200;
|
||||||
static final int LFIELDS_PER_FLUSH = 50;
|
|
||||||
static final int NO_REG = MAXARG_A;
|
static final int NO_REG = MAXARG_A;
|
||||||
|
|
||||||
/* masks for new-style vararg */
|
/* masks for new-style vararg */
|
||||||
|
|||||||
@@ -24,11 +24,7 @@ package org.luaj.vm;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants for lua limits and opcodes
|
* Constants for lua limits and opcodes
|
||||||
*
|
*
|
||||||
* @author jim_roseborough
|
|
||||||
*
|
|
||||||
* @deprecated - this class will go away. Constants will probably move to LuaState
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Lua {
|
public class Lua {
|
||||||
|
|
||||||
@@ -324,6 +320,9 @@ public class Lua {
|
|||||||
return 0 != (luaP_opmodes[m] & (1 << 7));
|
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
|
// type constants
|
||||||
|
|
||||||
public static final int LUA_TNONE = (-1);
|
public static final int LUA_TNONE = (-1);
|
||||||
@@ -351,4 +350,5 @@ public class Lua {
|
|||||||
"value",
|
"value",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -827,11 +827,10 @@ public class LuaState extends Lua {
|
|||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
c = code[ci.pc++];
|
c = code[ci.pc++];
|
||||||
}
|
}
|
||||||
table = this.stack[base + a];
|
int offset = (c-1) * LFIELDS_PER_FLUSH;
|
||||||
for (int index = 1; index <= b; index++) {
|
LTable tbl = (LTable) this.stack[base + a];
|
||||||
val = this.stack[listBase + index];
|
for (int j=1; j<=b; j++) {
|
||||||
table.luaSetTable(this, table, LInteger.valueOf(index),
|
tbl.put(offset+j, stack[listBase + j]);
|
||||||
val);
|
|
||||||
}
|
}
|
||||||
top = base + a - 1;
|
top = base + a - 1;
|
||||||
continue;
|
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 = {
|
local t = {
|
||||||
[2000]='a', [2001]='b', [2002]='c', [2003]='d', [2004]='e', [2005]='f', [2006]='g', [2007]='h', [2008]='i', [2009]='j',
|
[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',
|
[3000]='a', [3001]='b', [3002]='c', [3003]='d', [3004]='e', [3005]='f', [3006]='g', [3007]='h', [3008]='i', [3009]='j',
|
||||||
@@ -13,4 +40,4 @@ for i=2000,8000,1000 do
|
|||||||
for j=0,9,1 do
|
for j=0,9,1 do
|
||||||
print( 't['..tostring(i+j)..']', t[i+j] )
|
print( 't['..tostring(i+j)..']', t[i+j] )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user