X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/2d8d81c52aded8f15e37b061971d493742f55751..f458e64e36509fa8c204f1dbcafff1d3dc059619:/src/codegen-proto.lisp diff --git a/src/codegen-proto.lisp b/src/codegen-proto.lisp index e663fb5..856e44e 100644 --- a/src/codegen-proto.lisp +++ b/src/codegen-proto.lisp @@ -66,6 +66,10 @@ (make-instance 'temporary-name :tag "sod__tmp_ap")) (defparameter *sod-tmp-val* (make-instance 'temporary-name :tag "sod__t")) +(defparameter *sod-keywords* + (make-instance 'temporary-name :tag "sod__kw")) +(defparameter *sod-key-pointer* + (make-instance 'temporary-name :tag "sod__keys")) (export '*null-pointer*) (defparameter *null-pointer* "NULL") @@ -191,13 +195,13 @@ (pprint-indent :block 2 stream) (pprint-newline :linear stream) (princ child stream) - (pprint-indent :block 0 stream) - (case morep - (:space - (write-char #\space stream) - (pprint-newline :linear stream)) - ((t) - (pprint-newline :mandatory stream))))))) + (pprint-indent :block 0 stream)) + (case morep + (:space + (write-char #\space stream) + (pprint-newline :linear stream)) + ((t) + (pprint-newline :mandatory stream)))))) (export 'format-compound-statement) (defmacro format-compound-statement @@ -221,10 +225,11 @@ ;; prevent them from leaking. (definst var (stream :export t) (name #1=#:type &optional init) - (pprint-c-type #1# stream name) - (when init - (format stream " = ~A" init)) - (write-char #\; stream)) + (pprint-logical-block (stream nil) + (pprint-c-type #1# stream name) + (when init + (format stream " = ~2I~_~A" init)) + (write-char #\; stream))) (definst function (stream :export t) (name #1=#:type body &optional #2=#:banner &rest banner-args) @@ -240,13 +245,13 @@ (definst expr (stream :export t) (#1=#:expr) (format stream "~A;" #1#)) (definst set (stream :export t) (var #1=#:expr) - (format stream "~@<~A = ~@_~2I~A;~:>" var #1#)) + (format stream "~@<~A = ~2I~_~A;~:>" var #1#)) (definst update (stream :export t) (var op #1=#:expr) - (format stream "~@<~A ~A= ~@_~2I~A;~:>" var op #1#)) + (format stream "~@<~A ~A= ~2I~_~A;~:>" var op #1#)) ;; Special kinds of expressions. (definst call (stream :export t) (#1=#:func &rest args) - (format stream "~A(~@<~{~A~^, ~_~}~:>)" #1# args)) + (format stream "~@<~A~4I~_(~@<~{~A~^, ~_~}~:>)~:>" #1# args)) (definst cond (stream :export t) (#1=#:cond conseq alt) (format stream "~@<~A ~2I~@_~@~:>" #1# conseq alt))