From d6bb2ccd1acd7d3ed72e26d7d9a2ec6f72d96e1a Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 9 Jan 2016 20:41:01 +0000 Subject: [PATCH] src/codegen-proto.lisp: Fix printing of `if`/`else if' ladders. Should be in a nice column, rather than marching across to the right margin like a mad thing. --- src/codegen-proto.lisp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/codegen-proto.lisp b/src/codegen-proto.lisp index c115671..7a6be33 100644 --- a/src/codegen-proto.lisp +++ b/src/codegen-proto.lisp @@ -255,11 +255,18 @@ decls body)) (definst if (stream :export t) (#1=#:cond conseq &optional alt) - (format-compound-statement (stream conseq alt) - (format stream "if (~A)" #1#)) - (when alt - (format-compound-statement (stream alt) - (write-string "else" stream)))) + (let ((stmt "if")) + (loop (format-compound-statement (stream conseq (if alt t nil)) + (format stream "~A (~A)" stmt #1#)) + (typecase alt + (null (return)) + (if-inst (setf stmt "else if" + #1# (inst-cond alt) + conseq (inst-conseq alt) + alt (inst-alt alt))) + (t (format-compound-statement (stream alt) + (format stream "else")) + (return)))))) (definst while (stream :export t) (#1=#:cond body) (format-compound-statement (stream body) -- 2.11.0