Move bytecode offsets from lj_vm.* to generated header.

This commit is contained in:
Mike Pall
2010-02-05 20:15:01 +01:00
parent a0914c409b
commit c4dadf1d67
11 changed files with 49 additions and 62 deletions

View File

@@ -251,6 +251,19 @@ static const char *lower(char *buf, const char *s)
return buf;
}
/* Emit C source code for bytecode-related definitions. */
static void emit_bcdef(BuildCtx *ctx)
{
int i;
fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n");
fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_ofs[BC__MAX+1] = {\n ");
for (i = 0; i < ctx->npc; i++) {
fprintf(ctx->fp, "%4d, ", ctx->sym_ofs[i]);
if ((i & 7) == 7) fprintf(ctx->fp, "\n ");
}
fprintf(ctx->fp, "0\n};\n\n");
}
/* Emit VM definitions as Lua code for debug modules. */
static void emit_vmdef(BuildCtx *ctx)
{
@@ -418,6 +431,9 @@ int main(int argc, char **argv)
case BUILD_raw:
emit_raw(ctx);
break;
case BUILD_bcdef:
emit_bcdef(ctx);
break;
case BUILD_vmdef:
emit_vmdef(ctx);
/* fallthrough */