Add cross-32/64 bit and deterministic bytecode generation.
Contributed by Peter Cawley. #993 #1008
This commit is contained in:
@@ -122,11 +122,25 @@ static int writer_buf(lua_State *L, const void *p, size_t size, void *sb)
|
||||
|
||||
LJLIB_CF(string_dump)
|
||||
{
|
||||
GCfunc *fn = lj_lib_checkfunc(L, 1);
|
||||
int strip = L->base+1 < L->top && tvistruecond(L->base+1);
|
||||
SBuf *sb = lj_buf_tmp_(L); /* Assumes lj_bcwrite() doesn't use tmpbuf. */
|
||||
GCproto *pt = lj_lib_checkLproto(L, 1, 1);
|
||||
uint32_t flags = 0;
|
||||
SBuf *sb;
|
||||
TValue *o = L->base+1;
|
||||
if (o < L->top) {
|
||||
if (tvisstr(o)) {
|
||||
const char *mode = strVdata(o);
|
||||
char c;
|
||||
while ((c = *mode++)) {
|
||||
if (c == 's') flags |= BCDUMP_F_STRIP;
|
||||
if (c == 'd') flags |= BCDUMP_F_DETERMINISTIC;
|
||||
}
|
||||
} else if (tvistruecond(o)) {
|
||||
flags |= BCDUMP_F_STRIP;
|
||||
}
|
||||
}
|
||||
sb = lj_buf_tmp_(L); /* Assumes lj_bcwrite() doesn't use tmpbuf. */
|
||||
L->top = L->base+1;
|
||||
if (!isluafunc(fn) || lj_bcwrite(L, funcproto(fn), writer_buf, sb, strip))
|
||||
if (!pt || lj_bcwrite(L, pt, writer_buf, sb, flags))
|
||||
lj_err_caller(L, LJ_ERR_STRDUMP);
|
||||
setstrV(L, L->top-1, lj_buf_str(L, sb));
|
||||
lj_gc_check(L);
|
||||
|
||||
Reference in New Issue
Block a user