diff options
Diffstat (limited to 'src/buildvm.c')
-rw-r--r-- | src/buildvm.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/buildvm.c b/src/buildvm.c index 34f3df96..375e8b2b 100644 --- a/src/buildvm.c +++ b/src/buildvm.c | |||
@@ -251,6 +251,19 @@ static const char *lower(char *buf, const char *s) | |||
251 | return buf; | 251 | return buf; |
252 | } | 252 | } |
253 | 253 | ||
254 | /* Emit C source code for bytecode-related definitions. */ | ||
255 | static void emit_bcdef(BuildCtx *ctx) | ||
256 | { | ||
257 | int i; | ||
258 | fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); | ||
259 | fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_ofs[BC__MAX+1] = {\n "); | ||
260 | for (i = 0; i < ctx->npc; i++) { | ||
261 | fprintf(ctx->fp, "%4d, ", ctx->sym_ofs[i]); | ||
262 | if ((i & 7) == 7) fprintf(ctx->fp, "\n "); | ||
263 | } | ||
264 | fprintf(ctx->fp, "0\n};\n\n"); | ||
265 | } | ||
266 | |||
254 | /* Emit VM definitions as Lua code for debug modules. */ | 267 | /* Emit VM definitions as Lua code for debug modules. */ |
255 | static void emit_vmdef(BuildCtx *ctx) | 268 | static void emit_vmdef(BuildCtx *ctx) |
256 | { | 269 | { |
@@ -418,6 +431,9 @@ int main(int argc, char **argv) | |||
418 | case BUILD_raw: | 431 | case BUILD_raw: |
419 | emit_raw(ctx); | 432 | emit_raw(ctx); |
420 | break; | 433 | break; |
434 | case BUILD_bcdef: | ||
435 | emit_bcdef(ctx); | ||
436 | break; | ||
421 | case BUILD_vmdef: | 437 | case BUILD_vmdef: |
422 | emit_vmdef(ctx); | 438 | emit_vmdef(ctx); |
423 | /* fallthrough */ | 439 | /* fallthrough */ |