aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler.h
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-11-09 17:42:59 +0100
committerBad Diode <bd@badd10de.dev>2021-11-09 17:42:59 +0100
commited96e5e915c5380f0a073ed49d6786b07db68439 (patch)
treeb6c547806196844c8a5be5b9ae5db765327b24b7 /src/compiler.h
parent12ae1f331e79f769f01d2aa70608868f16667516 (diff)
downloadbdl-ed96e5e915c5380f0a073ed49d6786b07db68439.tar.gz
bdl-ed96e5e915c5380f0a073ed49d6786b07db68439.zip
Add display functionality for lambda objects
Diffstat (limited to 'src/compiler.h')
-rw-r--r--src/compiler.h17
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) {
509void 509void
510emit_data_section(void) { 510emit_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}