1
0
forked from alex-eg/sex

type an operator's result without qualifiers

The spelling was the first operand's, so (+ k 1) with k const was a
const int and (+ 1 k) was not; a value has no qualifiers either way.
This commit is contained in:
2026-10-16 17:04:20 +03:00
parent 47b98e41df
commit ad1825e8a8
3 changed files with 27 additions and 2 deletions

View File

@@ -39,6 +39,7 @@
underlying
c-primitive?
decay
unqualified
;; The boundary
parse-type
@@ -151,6 +152,16 @@
((fn-type? t) (make-ptr t (list)))
(else (resolve type)))))
;;; TYPE as a value has it: qualifiers belong to an object, not to what
;;; is read out of one. `(const int)' -> `int', `(* const char)' as is.
(define (unqualified type)
(let ((t (resolve type)))
(cond ((prim-type? t) (make-prim (prim-name t) (list)))
((ptr-type? t) (make-ptr (ptr-target t) (list)))
((agg-type? t) (make-agg (agg-kind t) (agg-name t) (agg-spelling t) (list)))
((alias-type? t) (make-alias (alias-name t) (alias-expansion t) (list)))
(else t))))
;;; ---------------------------------------------------------------
;;; Surface -> IR
;;; ---------------------------------------------------------------