Make editor's compile command save files (source and binary)
This commit is contained in:
parent
1e4a823a80
commit
ad297f0c09
1 changed files with 24 additions and 7 deletions
|
@ -754,13 +754,30 @@ Additionally ensures correct line numbers on the way, as a bonus."
|
|||
(redisplay-view (current-view *editor*)))
|
||||
|
||||
(defun com-compile-buffer ()
|
||||
(let ((bytes
|
||||
(handler-case
|
||||
(usc:compile-string-to-bytes
|
||||
(buffer-string (current-buffer *editor*)))
|
||||
(usc:usc-error (c)
|
||||
(let ((source (cdr (usc:source c))))
|
||||
(compile-fail-prompt c (car source) (cdr source)))))))))
|
||||
(let* ((src (buffer-string (current-buffer *editor*)))
|
||||
(bytes
|
||||
(handler-case
|
||||
(usc:compile-string-to-bytes src)
|
||||
(usc:usc-error (c)
|
||||
(let ((source (cdr (usc:source c))))
|
||||
(compile-fail-prompt c (car source) (cdr source)))
|
||||
nil))))
|
||||
(unless (null bytes)
|
||||
(let* ((timestring (multiple-value-bind (seconds minutes hours day month year)
|
||||
(get-decoded-time)
|
||||
(format nil "~D-~2,'0D-~2,'0D_~2,'0D-~2,'0D-~2,'0D"
|
||||
year month day
|
||||
hours minutes seconds)))
|
||||
(bin-name (format nil "compiled-program_~A.bin" timestring))
|
||||
(src-name (format nil "source-program_~A.c6l" timestring)))
|
||||
(with-open-file (output src-name :direction :output
|
||||
:if-exists :supersede)
|
||||
(write-string src output))
|
||||
(with-open-file (output bin-name :direction :output
|
||||
:element-type '(unsigned-byte 8)
|
||||
:if-exists :supersede)
|
||||
(dolist (byte bytes)
|
||||
(write-byte byte output)))))))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue