read every trailing array bound as a dimension
[m 1 2] lost its second index, and [int 2 3] came out int 2 x[3]. Each index now subscripts what the one before it gave, and [int 2 3] declares what it indexes, int[2][3]. An inline struct's fields, once more than one bound was looked for, were taken for one; their shape tells them apart.
This commit is contained in:
16
semen.scm
16
semen.scm
@@ -675,6 +675,16 @@
|
||||
|
||||
((dot-access) (walk-member-path form env))
|
||||
|
||||
;; [m 1 2] is [[m 1] 2], m[1][2]
|
||||
((¤)
|
||||
(if (> (length form) 3)
|
||||
(walk-statement
|
||||
(copy-form-source!
|
||||
form
|
||||
(list '¤ (copy-form-source! form (drop-right form 1)) (last form)))
|
||||
env)
|
||||
(walk-parts form env)))
|
||||
|
||||
((sizeof)
|
||||
(if (and (= 2 (length form)) (written-type? (second form) env))
|
||||
(copy-form-source!
|
||||
@@ -757,7 +767,7 @@
|
||||
;;; nothing here can count
|
||||
(define (array-length type)
|
||||
(and (array-bound? type)
|
||||
(let ((bound (last type)))
|
||||
(let ((bound (array-bound type)))
|
||||
(cond ((and (integer? bound) (exact? bound)) bound)
|
||||
((symbol? bound)
|
||||
(let ((info (get-type-info bound)))
|
||||
@@ -798,10 +808,10 @@
|
||||
;;; there that is a type:
|
||||
;;;
|
||||
;;; (* char) (* const char) (* size-t) (unsigned int) types
|
||||
;;; (* p) (* (g)) (¤ xs 0) expressions
|
||||
;;; (* p) (* (g)) (¤ xs 0) (¤ m 1 2) expressions
|
||||
(define (written-type? form env)
|
||||
(match form
|
||||
((or ('* operand) ('¤ operand _))
|
||||
((or ('* operand) ('¤ operand _ . _))
|
||||
(if (symbol? operand)
|
||||
(not (or (lookup-name env operand) (get-name-type operand)))
|
||||
(written-type? operand env)))
|
||||
|
||||
Reference in New Issue
Block a user