mescc: Enhance sizeof support.
* module/language/c99/compiler.mes (expr->accu): Support sizeof (simple-type), sizeof (var).
This commit is contained in:
parent
ed3aa5be35
commit
5d0202bbf7
|
@ -523,6 +523,7 @@
|
|||
(locals (cons (make-local name type pointer id) locals)))
|
||||
locals))
|
||||
(pmatch o
|
||||
((expr) info)
|
||||
((p-expr (string ,string))
|
||||
(let* ((globals (append globals (list (string->global string))))
|
||||
(info (clone info #:globals globals)))
|
||||
|
@ -558,6 +559,18 @@
|
|||
((ref-to (array-ref ,index (p-expr (ident ,array))))
|
||||
((expr->accu* info) `(array-ref ,index (p-expr (ident ,array)))))
|
||||
|
||||
((sizeof-expr (p-expr (ident ,name)))
|
||||
(let* ((type (ident->type info name))
|
||||
(fields (or (type->description info type) '()))
|
||||
(size (type->size info type)))
|
||||
(append-text info (wrap-as (i386:value->accu size)))))
|
||||
|
||||
((sizeof-type (type-name (decl-spec-list (type-spec (fixed-type ,name)))))
|
||||
(let* ((type name)
|
||||
(fields (or (type->description info type) '()))
|
||||
(size (type->size info type)))
|
||||
(append-text info (wrap-as (i386:value->accu size)))))
|
||||
|
||||
((sizeof-type (type-name (decl-spec-list (type-spec (struct-ref (ident ,name))))))
|
||||
(let* ((type (list "struct" name))
|
||||
(fields (or (type->description info type) '()))
|
||||
|
@ -1453,9 +1466,6 @@
|
|||
(list (lambda (f g ta t d)
|
||||
(jump (- (label-offset (.function info) label f) offset))))))))
|
||||
|
||||
((return (expr))
|
||||
(append-text info (append (wrap-as (i386:ret)))))
|
||||
|
||||
((return ,expr)
|
||||
(let ((info ((expr->accu info) expr)))
|
||||
(append-text info (append (wrap-as (i386:ret))))))
|
||||
|
|
Loading…
Reference in a new issue