Skip to content

Commit

Permalink
Set *print-circle* t when dumping code so that gensym works
Browse files Browse the repository at this point in the history
  • Loading branch information
jbouwman authored and stylewarning committed Aug 15, 2024
1 parent 734a6de commit 2c84a6e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/codegen/ast-substitutions.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ a subtree of `node`."
(action (:after node-lisp node)
(multiple-value-bind (let-bindings lisp-var-bindings)
(loop :for (lisp-var . coalton-var) :in (node-lisp-vars node)
:for new-var := (gentemp (symbol-name coalton-var))
:for new-var := (gensym (symbol-name coalton-var))
:for res := (find coalton-var subs :key #'ast-substitution-from)
:if (and res (node-variable-p (ast-substitution-to res)))
:collect (cons lisp-var (node-variable-value (ast-substitution-to res)))
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/codegen-expression.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
(let ((match-expr (codegen-expression (node-while-let-expr expr) env))
(body-expr (codegen-expression (node-while-let-body expr) env))
(label (node-while-let-label expr))
(match-var (gentemp "MATCH")))
(match-var (gensym "MATCH")))

(multiple-value-bind (pred bindings)
(codegen-pattern (node-while-let-pattern expr) match-var env)
Expand Down Expand Up @@ -174,7 +174,7 @@

;; Otherwise do the thing
(let ((subexpr (codegen-expression (node-match-expr expr) env))
(match-var (gentemp "MATCH")))
(match-var (gensym "MATCH")))
`(let ((,match-var
,(if settings:*emit-type-annotations*
`(the ,(tc:lisp-type (node-type (node-match-expr expr)) env) ,subexpr)
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/optimizer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@
:if orig-param-names
:collect (let ((param (nth (+ i (length args)) orig-param-names)))
(if (parser:pattern-var-p param)
(gentemp (concatenate 'string
(gensym (concatenate 'string
(symbol-name (parser:pattern-var-name param))
"-"))
(gentemp)))
(gensym)))
:else
:collect (gentemp)))
:collect (gensym)))

(param-types (subseq (tc:function-type-arguments (node-type function)) (length args)))

Expand Down Expand Up @@ -379,7 +379,7 @@ requires direct constructor calls."
;; a unique xi').
:for var :in vars
:for val :in vals
:for new-var := (gentemp (symbol-name var))
:for new-var := (gensym (symbol-name var))
:collect (cons new-var val)
:into bindings
:collect (make-ast-substitution
Expand Down
12 changes: 6 additions & 6 deletions src/codegen/translate-expression.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ TRANSLATE-EXPRESSION when an abstraction is being translated.")
:if (tc:pattern-var-p param)
:collect (tc:pattern-var-name param)
:else :if (tc:pattern-wildcard-p param)
:collect (gentemp "_")
:collect (gensym "_")
:else
:collect (let ((name (gentemp)))
:collect (let ((name (gensym)))
(push (cons name param) pattern-params)
name)))

Expand Down Expand Up @@ -109,7 +109,7 @@ TRANSLATE-EXPRESSION when an abstraction is being translated.")
:if (tc:pattern-var-p param)
:collect (tc:pattern-var-name param)
:else :if (tc:pattern-wildcard-p param)
:collect (gentemp "_")
:collect (gensym "_")
:else
:collect (let ((name (gensym)))
(push (cons name param) pattern-params)
Expand Down Expand Up @@ -337,7 +337,7 @@ Returns a `node'.")
:if (tc:pattern-var-p param)
:collect (tc:pattern-var-name param)
:else
:collect (let ((name (gentemp)))
:collect (let ((name (gensym)))
(push (cons name param) pattern-params)
name)))))

Expand Down Expand Up @@ -838,7 +838,7 @@ Returns a `node'.")

(callback-ty (tc:make-function-type var-type (node-type out-node)))

(var-name (gentemp)))
(var-name (gensym)))

(make-node-application
:type (node-type out-node)
Expand Down Expand Up @@ -874,7 +874,7 @@ Returns a `node'.")

(callback-ty (tc:make-function-type var-type (node-type out-node)))

(var-name (gentemp)))
(var-name (gensym)))

(make-node-application
:type (node-type out-node)
Expand Down
3 changes: 3 additions & 0 deletions src/entry.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@
(with-standard-io-syntax
(let ((*package* (find-package package))
(*print-case* ':downcase)
;; *print-circle* t allows gensym-generated, uninterned
;; *symbols to serve as variables in readable source.
(*print-circle* t)
(*print-pretty* t)
(*print-right-margin* 80))
(prin1 form stream)
Expand Down

0 comments on commit 2c84a6e

Please sign in to comment.