summaryrefslogtreecommitdiff
path: root/ull
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-01-28 17:52:23 -0500
committerbd <bdunahu@operationnull.com>2025-01-28 17:52:23 -0500
commit5cea39649d613864f3e7a688cb2a7ecbde8bd6cd (patch)
tree9cfdeb42231f771b344fdf7b541d5f135eaf276f /ull
parent467357ef13ea5d935d2e3aa5baaeef6317cd9590 (diff)
Simplified declaring new IR nodes in (backend ast ir)
Diffstat (limited to 'ull')
-rwxr-xr-xull18
1 files changed, 10 insertions, 8 deletions
diff --git a/ull b/ull
index 6217544..7532be9 100755
--- a/ull
+++ b/ull
@@ -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))))