Skip to content

Commit

Permalink
Strip '#<identifier...>' thing in cgen-generated commends
Browse files Browse the repository at this point in the history
  • Loading branch information
shirok committed Nov 24, 2024
1 parent 93f951c commit f7e5c4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
20 changes: 10 additions & 10 deletions lib/gauche/cgen/precomp.scm
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,9 @@
~a,\
~a);\n"
(if mod (tmodule-cname mod) "Scm_CurrentModule()")
(if mod (cgen-safe-comment (~ mod'name)) "")
(if mod (cgen-safe-comment-sexp (~ mod'name)) "")
(cgen-cexpr sym)
(cgen-safe-comment (unwrap-syntax id))
(cgen-safe-comment-sexp id)
tmp
(case flags
[(2) 'SCM_BINDING_CONST]
Expand Down Expand Up @@ -916,7 +916,7 @@
[inliner (check-packed-inliner code)])
(define (init-thunk)
(format #t " SCM_COMPILED_CODE_CONST_INITIALIZER( /* ~a */\n"
(cgen-safe-comment (~ code'name)))
(cgen-safe-comment-sexp (~ code'name)))
(format #t " (ScmWord*)(~a), ~a,\n"
cvn (length cv))
(format #t " ~a, ~a, ~a, ~a, ~a, ~a,\n"
Expand Down Expand Up @@ -951,7 +951,7 @@
(unless (cgen-literal-static? (~ self'code-name))
(print " SCM_COMPILED_CODE("(~ self'c-name)")->name = "
(cgen-cexpr (~ self'code-name))";"
"/* "(cgen-safe-comment (~ self'value'full-name))" */"))
"/* "(cgen-safe-comment-sexp (~ self'value'full-name))" */"))
(unless (cgen-literal-static? (~ self'signature-info))
(print " SCM_COMPILED_CODE("(~ self'c-name)")->signatureInfo = "
(cgen-cexpr (~ self'signature-info)) ";"))
Expand Down Expand Up @@ -1029,7 +1029,7 @@
[insnval (vm-build-insn insn)]
[name-info (if first-cexpr
""
(format "/* ~a */\n " (cgen-safe-comment full-name)))]
(format "/* ~a */\n " (cgen-safe-comment-sexp full-name)))]
[insn-cexpr
(alloc-word
;; We emit it as signed integer so that 64bit machine
Expand All @@ -1055,18 +1055,18 @@
(if (cgen-literal-static? (cadr lv))
(format "SCM_WORD(~a) /* ~a */"
(cgen-cexpr (cadr lv))
(cgen-safe-comment (write-to-string (cadr cv))))
(cgen-safe-comment-sexp (cadr cv)))
(format "SCM_WORD(SCM_UNDEFINED) /* ~a */"
(cgen-safe-comment (write-to-string (cadr cv))))))
(cgen-safe-comment-sexp (cadr cv)))))
(loop (cddr cv) (cddr lv) (+ count 2) first-cexpr)]
[(obj+label)
(alloc-word
(if (cgen-literal-static? (cadr lv))
(format "SCM_WORD(~a) /* ~a */"
(cgen-cexpr (cadr lv))
(cgen-safe-comment (write-to-string (cadr cv))))
(cgen-safe-comment-sexp (cadr cv)))
(format "SCM_WORD(SCM_UNDEFINED) /* ~a */"
(cgen-safe-comment (write-to-string (cadr cv))))))
(cgen-safe-comment-sexp (cadr cv)))))
(alloc-word
(format "SCM_WORD((ScmWord*)~a + ~d) /* ~3d */"
first-cexpr (caddr cv) (caddr cv)))
Expand Down Expand Up @@ -1192,5 +1192,5 @@
(init (self)
(format #t " ~a = Scm_MakeClosure(~a, NULL); /* ~a */\n"
(cgen-cexpr self) (cgen-cexpr (~ self'code))
(cgen-safe-comment (write-to-string (~ self'value)))))
(cgen-safe-comment-sexp (~ self'value))))
(static (self) #f))
7 changes: 6 additions & 1 deletion lib/gauche/cgen/unit.scm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
cgen-include cgen-define cpp-condition->string

cgen-safe-name cgen-safe-name-friendly
cgen-safe-string cgen-safe-comment
cgen-safe-string cgen-safe-comment cgen-safe-comment-sexp

;; semi-private routines
cgen-emit-static-data)
Expand Down Expand Up @@ -393,3 +393,8 @@
;; Escape '*/' so that str can be inserted safely within a comment.
(define (cgen-safe-comment str)
(regexp-replace-all* (x->string str) #/\/\*/ "/ *" #/\*\// "* /"))

;; Useful to include sexp in C comment. Strip #<identifier ...> away
;; for the readability.
(define (cgen-safe-comment-sexp obj)
(cgen-safe-comment (write-to-string (unwrap-syntax obj))))

0 comments on commit f7e5c4c

Please sign in to comment.