From 029c0008404a1f734fc56ca5df25edb2a0b87745 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 21 May 2018 21:54:54 +0200 Subject: [PATCH] mescc: Align global data. * module/mes/M1.mes (object->M1): Align globals. --- module/mes/M1.mes | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/module/mes/M1.mes b/module/mes/M1.mes index 2713df2d..08a508e1 100644 --- a/module/mes/M1.mes +++ b/module/mes/M1.mes @@ -171,6 +171,11 @@ (cond ((and (pair? o) (global? (cdr o))) (string-append "&" (global->string o))) ((and (not string?) (not function?)) (stderr "warning: unresolved label: ~s\n" label)) (else (string-append "&" label)))))) + (define (display-align size) + (let ((alignment (- 4 (modulo size 4)))) + (when (> alignment 0) + (display " ") + (display-join (map text->M1 (map (const 0) (iota alignment))) " ")))) (let* ((label (cond ((and (pair? (car o)) (eq? (caar o) #:string)) (string->label (car o))) @@ -194,8 +199,12 @@ (or (and (not (memq ch '(#\tab #\newline))) (< (char->integer ch) #x20)) (>= (char->integer ch) #x80))) string-data))) - (display (string-append "\"" (list->string string-data) "\"")) - (display-join (map text->M1 data) " ")) + (let ((text string-data)) + (display (string-append "\"" (list->string string-data) "\"")) + (display-align (1+ (length string-data)))) + (let ((text (map text->M1 data))) + (display-join text " ") + (display-align (length text)))) (newline))) (display "M1: functions\n" (current-error-port)) (for-each write-function (filter cdr functions))