forked from alex-eg/sex
let sizeof take a type that looks like an expression
(* char) is a pointer type and (* p) a dereference, and only the names in scope tell them apart, so semen decides and marks a type for the writer. Before, both were walked as expressions: sizeof(*char). Fixes #52.
This commit is contained in:
@@ -201,6 +201,9 @@ forms, and what remains."
|
||||
;; path lowers to where the thing it reads from is a pointer
|
||||
(('%-> . rest) (cons '%-> (map walk-expr rest)))
|
||||
(('var . _) (walk-var form))
|
||||
;; semen has told a type from an expression; only it knows the names
|
||||
;; in scope that make `(* p)' one or the other
|
||||
(('sizeof ('%type type)) `(%sizeof-type ,(walk-type type)))
|
||||
;; semen has already put the target first, the way C writes it
|
||||
(('typedef type name)
|
||||
`(typedef ,(walk-type type) ,(atom-to-fmt-c name)))
|
||||
|
||||
Reference in New Issue
Block a user