forked from alex-eg/sex
answer where a written type ends in one place
An arglist entry, an array's bound and its element type ask one question, and disagreed: `(unsigned int)' was a name plus a type, a trailing typedef a bound, a subscript the type's second word.
This commit is contained in:
@@ -276,7 +276,7 @@
|
||||
;;; through untouched.
|
||||
(define (fn-type-of fn-form)
|
||||
`(fn ,(map (lambda (param)
|
||||
(if (and (pair? param) (= 2 (length param)))
|
||||
(if (and (pair? param) (= 2 (length param)) (named-arg? param))
|
||||
(list (second param))
|
||||
param))
|
||||
(sex-fn-arglist fn-form))
|
||||
@@ -550,9 +550,10 @@
|
||||
(and (symbol? (car expr)) (get-return-type (car expr))))
|
||||
(else
|
||||
(case (car expr)
|
||||
;; subscripting an array gives its element type, and a pointer
|
||||
;; subscripts the same way
|
||||
((¤) (let ((base (expression-type (second expr) env)))
|
||||
(and (list? base) (>= (length base) 2) (eq? '¤ (car base))
|
||||
(second base))))
|
||||
(or (array-element-type base) (pointer-target base))))
|
||||
((&) (and (= 2 (length expr))
|
||||
(let ((target (expression-type (second expr) env)))
|
||||
(and target `(* ,target)))))
|
||||
|
||||
Reference in New Issue
Block a user