Fix NPE on error. #40
This commit is contained in:
@@ -50,7 +50,6 @@ public class FuncState extends Constants {
|
|||||||
Hashtable h; /* table to find (and reuse) elements in `k' */
|
Hashtable h; /* table to find (and reuse) elements in `k' */
|
||||||
FuncState prev; /* enclosing function */
|
FuncState prev; /* enclosing function */
|
||||||
LexState ls; /* lexical state */
|
LexState ls; /* lexical state */
|
||||||
LuaC.CompileState L; /* compiler being invoked */
|
|
||||||
BlockCnt bl; /* chain of current blocks */
|
BlockCnt bl; /* chain of current blocks */
|
||||||
int pc; /* next position to code (equivalent to `ncode') */
|
int pc; /* next position to code (equivalent to `ncode') */
|
||||||
int lasttarget; /* `pc' of last `jump target' */
|
int lasttarget; /* `pc' of last `jump target' */
|
||||||
@@ -113,8 +112,8 @@ public class FuncState extends Constants {
|
|||||||
void errorlimit (int limit, String what) {
|
void errorlimit (int limit, String what) {
|
||||||
// TODO: report message logic.
|
// TODO: report message logic.
|
||||||
String msg = (f.linedefined == 0) ?
|
String msg = (f.linedefined == 0) ?
|
||||||
L.pushfstring("main function has more than "+limit+" "+what) :
|
ls.L.pushfstring("main function has more than "+limit+" "+what) :
|
||||||
L.pushfstring("function at line "+f.linedefined+" has more than "+limit+" "+what);
|
ls.L.pushfstring("function at line "+f.linedefined+" has more than "+limit+" "+what);
|
||||||
ls.lexerror(msg, 0);
|
ls.lexerror(msg, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +295,7 @@ public class FuncState extends Constants {
|
|||||||
}
|
}
|
||||||
} /* else go through */
|
} /* else go through */
|
||||||
}
|
}
|
||||||
this.codeABC(OP_LOADNIL, from, n - 1, 0);
|
this.codeABC(OP_LOADNIL, from, n - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -478,7 +477,7 @@ public class FuncState extends Constants {
|
|||||||
this.h = new Hashtable();
|
this.h = new Hashtable();
|
||||||
} else if (this.h.containsKey(v)) {
|
} else if (this.h.containsKey(v)) {
|
||||||
return ((Integer) h.get(v)).intValue();
|
return ((Integer) h.get(v)).intValue();
|
||||||
}
|
}
|
||||||
final int idx = this.nk;
|
final int idx = this.nk;
|
||||||
this.h.put(v, new Integer(idx));
|
this.h.put(v, new Integer(idx));
|
||||||
final Prototype f = this.f;
|
final Prototype f = this.f;
|
||||||
@@ -496,7 +495,7 @@ public class FuncState extends Constants {
|
|||||||
if ( r instanceof LuaDouble ) {
|
if ( r instanceof LuaDouble ) {
|
||||||
double d = r.todouble();
|
double d = r.todouble();
|
||||||
int i = (int) d;
|
int i = (int) d;
|
||||||
if ( d == (double) i )
|
if ( d == (double) i )
|
||||||
r = LuaInteger.valueOf(i);
|
r = LuaInteger.valueOf(i);
|
||||||
}
|
}
|
||||||
return this.addk(r);
|
return this.addk(r);
|
||||||
@@ -688,7 +687,7 @@ public class FuncState extends Constants {
|
|||||||
case LexState.VKNUM: {
|
case LexState.VKNUM: {
|
||||||
e.u.info = this.numberK(e.u.nval());
|
e.u.info = this.numberK(e.u.nval());
|
||||||
e.k = LexState.VK;
|
e.k = LexState.VK;
|
||||||
/* go through */
|
/* go through */
|
||||||
}
|
}
|
||||||
case LexState.VK: {
|
case LexState.VK: {
|
||||||
if (e.u.info <= MAXINDEXRK) /* constant fit in argC? */
|
if (e.u.info <= MAXINDEXRK) /* constant fit in argC? */
|
||||||
|
|||||||
Reference in New Issue
Block a user