diff options
Diffstat (limited to 'ull')
-rwxr-xr-x | ull | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -68,12 +68,6 @@ Returns an string representing the generated assembly." (when write? (assembly->string ast))))))) -(define (postprocess src dest) - "Assembles and links SRC, producing executable DEST. -Returns #f on a failure, #t on a success." - (when (zero? (system (string-concatenate `("gcc " ,src " -o " ,dest)))) - (display (format #f "Postprocess reported success (wrote ~a).\n" dst)))) - (define (write str dst) "Writes STR to the file at DST." (cleanup-file dst) @@ -82,6 +76,12 @@ Returns #f on a failure, #t on a success." (close-port port)) (display (format #f "Assembly generation reported success (wrote ~a).\n" dst))) +(define (postprocess src dst) + "Assembles and links SRC, producing executable DST. +Returns #f on a failure, #t on a success." + (when (zero? (system (string-concatenate `("gcc " ,src " -o " ,dst)))) + (display (format #f "Postprocess reported success (wrote ~a).\n" dst)))) + (define (main args) "Entry point for ull. Handles user args and performs initial validity check." (let* ((option-spec @@ -110,7 +110,9 @@ Returns #f on a failure, #t on a success." (let* ((parse? (not (option-ref options 'lex #f))) (tack? (not (option-ref options 'parse #f))) (generate? (not (option-ref options 'tacky #f))) - (write? (not (option-ref options 'codegen #f))) + (write? (and (not (option-ref options 'codegen #f)) + generate? + tack?)) (executable-file-name (string-drop-right file-name 2)) (preprocessed-file-name @@ -126,7 +128,7 @@ Returns #f on a failure, #t on a success." ;; call the backend (begin (display "Parser reported success\n") (let ((program (backend c-ast tack? generate? write?))) - (when (and write? (not tack?) (not generate?)) + (when write? (write program assembly-file-name) ;; call postprocessing (postprocess assembly-file-name executable-file-name)))) |