Lua 5.2 fixes to compiler.
This commit is contained in:
@@ -312,9 +312,8 @@ public class LoadState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
n = loadInt();
|
n = loadInt();
|
||||||
f.upvalues = n>0? new Upvaldesc[n]: NOUPVALDESCS;
|
|
||||||
for ( int i=0; i<n; i++ )
|
for ( int i=0; i<n; i++ )
|
||||||
f.upvalues[i] = new Upvaldesc(loadString(), false, i);
|
f.upvalues[i].name = loadString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ package org.luaj.vm2;
|
|||||||
public class Upvaldesc {
|
public class Upvaldesc {
|
||||||
|
|
||||||
/* upvalue name (for debug information) */
|
/* upvalue name (for debug information) */
|
||||||
public final LuaString name;
|
public LuaString name;
|
||||||
|
|
||||||
/* whether it is in stack */
|
/* whether it is in stack */
|
||||||
public final boolean instack;
|
public final boolean instack;
|
||||||
|
|||||||
@@ -279,26 +279,24 @@ public class FuncState extends LuaC {
|
|||||||
// =============================================================
|
// =============================================================
|
||||||
|
|
||||||
void nil(int from, int n) {
|
void nil(int from, int n) {
|
||||||
InstructionPtr previous;
|
final int code_prev = f.code[pc - 1];
|
||||||
if (this.pc > this.lasttarget) { /* no jumps to current position? */
|
if (pc > 0 && GET_OPCODE(code_prev) == OP_LOADNIL) {
|
||||||
if (this.pc == 0) { /* function start? */
|
int l = from + n - 1; /* last register to set nil */
|
||||||
if (from >= this.nactvar)
|
int pfrom = GETARG_A(code_prev);
|
||||||
return; /* positions are already clean */
|
int pl = pfrom + GETARG_B(code_prev);
|
||||||
} else {
|
if ((pfrom <= from && from <= pl + 1)
|
||||||
previous = new InstructionPtr(this.f.code, this.pc - 1);
|
|| (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */
|
||||||
if (GET_OPCODE(previous.get()) == OP_LOADNIL) {
|
if (pfrom < from)
|
||||||
int pfrom = GETARG_A(previous.get());
|
from = pfrom; /* from = min(from, pfrom) */
|
||||||
int pto = GETARG_B(previous.get());
|
if (pl > l)
|
||||||
if (pfrom <= from && from <= pto + 1) { /* can connect both? */
|
l = pl; /* l = max(l, pl) */
|
||||||
if (from + n - 1 > pto)
|
InstructionPtr previous = new InstructionPtr(this.f.code, this.pc - 1);
|
||||||
SETARG_B(previous, from + n - 1);
|
SETARG_A(previous, from);
|
||||||
return;
|
SETARG_B(previous, l - from);
|
||||||
}
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} /* else go through */
|
||||||
/* else no optimization */
|
this.codeABC(OP_LOADNIL, from, n - 1, 0);
|
||||||
this.codeABC(OP_LOADNIL, from, from + n - 1, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1065,7 +1065,6 @@ public class LexState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void open_func (FuncState fs, BlockCnt bl) {
|
void open_func (FuncState fs, BlockCnt bl) {
|
||||||
Prototype f = new Prototype();
|
|
||||||
fs.prev = this.fs; /* linked list of funcstates */
|
fs.prev = this.fs; /* linked list of funcstates */
|
||||||
fs.ls = this;
|
fs.ls = this;
|
||||||
this.fs = fs;
|
this.fs = fs;
|
||||||
@@ -1080,7 +1079,8 @@ public class LexState {
|
|||||||
fs.nactvar = 0;
|
fs.nactvar = 0;
|
||||||
fs.firstlocal = dyd.n_actvar;
|
fs.firstlocal = dyd.n_actvar;
|
||||||
fs.bl = null;
|
fs.bl = null;
|
||||||
f.maxstacksize = 2; /* registers 0/1 are always valid */
|
fs.f.source = this.source;
|
||||||
|
fs.f.maxstacksize = 2; /* registers 0/1 are always valid */
|
||||||
fs.enterblock(bl, false);
|
fs.enterblock(bl, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user