src/codegen-proto.lisp: New instruction types `cond' and `for',
[sod] / src / codegen-proto.lisp
index 186f225..e663fb5 100644 (file)
 ;; Special kinds of expressions.
 (definst call (stream :export t) (#1=#:func &rest args)
   (format stream "~A(~@<~{~A~^, ~_~}~:>)" #1# args))
+(definst cond (stream :export t) (#1=#:cond conseq alt)
+  (format stream "~@<~A ~2I~@_~@<? ~A ~_: ~A~:>~:>" #1# conseq alt))
 
 ;; Simple statements.
 (definst return (stream :export t) (#1=#:expr)
     (write-string "do" stream))
   (format stream "while (~A);" #1#))
 
+(definst for (stream :export t) (init #1=#:cond update body)
+  (format-compound-statement (stream body)
+    (format stream "for (~@<~@[~A~];~@[ ~_~A~];~@[ ~_~A~]~:>)"
+           init #1# update)))
+
 ;;;--------------------------------------------------------------------------
 ;;; Code generation.