diff options
author | Bad Diode <bd@badd10de.dev> | 2021-11-09 17:42:59 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-11-09 17:42:59 +0100 |
commit | ed96e5e915c5380f0a073ed49d6786b07db68439 (patch) | |
tree | b6c547806196844c8a5be5b9ae5db765327b24b7 /src/compiler.h | |
parent | 12ae1f331e79f769f01d2aa70608868f16667516 (diff) | |
download | bdl-ed96e5e915c5380f0a073ed49d6786b07db68439.tar.gz bdl-ed96e5e915c5380f0a073ed49d6786b07db68439.zip |
Add display functionality for lambda objects
Diffstat (limited to 'src/compiler.h')
-rw-r--r-- | src/compiler.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/compiler.h b/src/compiler.h index 897b7bb..0223269 100644 --- a/src/compiler.h +++ b/src/compiler.h | |||
@@ -509,8 +509,15 @@ emit_bss_section(void) { | |||
509 | void | 509 | void |
510 | emit_data_section(void) { | 510 | emit_data_section(void) { |
511 | printf("section .data\n"); | 511 | printf("section .data\n"); |
512 | printf("true_str: db \"true\", 10, 0, 0, 0\n"); | 512 | printf("true_str:\n db \"true\", 10\n"); |
513 | printf("false_str: db \"false\", 10, 0, 0\n"); | 513 | printf(" alignb 8\n"); |
514 | printf("false_str:\n db \"false\", 10\n"); | ||
515 | printf(" alignb 8\n"); | ||
516 | printf("lambda_str:\n"); | ||
517 | char lambda_str[] = "#{lambda}"; | ||
518 | printf(" dq %ld\n", sizeof(lambda_str)); | ||
519 | printf(" db \"%s\", 10\n", lambda_str); | ||
520 | printf(" alignb 8\n"); | ||
514 | for (size_t i = 0; i < array_size(constants); i++) { | 521 | for (size_t i = 0; i < array_size(constants); i++) { |
515 | // NOTE: Only supporting string constants for now. | 522 | // NOTE: Only supporting string constants for now. |
516 | Constant c = constants[i]; | 523 | Constant c = constants[i]; |
@@ -520,11 +527,7 @@ emit_data_section(void) { | |||
520 | printf("%s:\n", c.label); | 527 | printf("%s:\n", c.label); |
521 | printf(" dq %d\n", n + 1); | 528 | printf(" dq %d\n", n + 1); |
522 | printf(" db \"%.*s\", 10\n", n, c.obj->text.start); | 529 | printf(" db \"%.*s\", 10\n", n, c.obj->text.start); |
523 | // Ensure alignment to 8 bytes. | 530 | printf(" alignb 8\n"); |
524 | int remainder = (n + 1) % 8; | ||
525 | if (remainder != 0) { | ||
526 | printf(" times %d db 0\n", 8 - (n + 1) % 8); | ||
527 | } | ||
528 | } | 531 | } |
529 | printf("\n"); | 532 | printf("\n"); |
530 | } | 533 | } |