chiark / gitweb /
src/codegen-proto.lisp: New instruction types `cond' and `for',
[sod] / src / codegen-proto.lisp
index 186f22583eb7c187a4b49c6733c05acf3a2722b9..e663fb566b9a2d4252785d4be9d691421785fa04 100644 (file)
@@ -247,6 +247,8 @@ (definst update (stream :export t) (var op #1=#:expr)
 ;; Special kinds of expressions.
 (definst call (stream :export t) (#1=#:func &rest args)
   (format stream "~A(~@<~{~A~^, ~_~}~:>)" #1# args))
 ;; 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)
 
 ;; Simple statements.
 (definst return (stream :export t) (#1=#:expr)
@@ -320,6 +322,11 @@ (definst do-while (stream :export t) (body #1=#:cond)
     (write-string "do" stream))
   (format stream "while (~A);" #1#))
 
     (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.
 
 ;;;--------------------------------------------------------------------------
 ;;; Code generation.