mescc: Tinycc support: Function addresses.

This commit is contained in:
Jan Nieuwenhuizen 2018-05-11 19:46:26 +02:00
parent b254f12d5e
commit 330404125e
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
3 changed files with 12 additions and 3 deletions

View file

@ -1767,10 +1767,10 @@
(define (ast->name o)
(pmatch o
((ident ,name) name)
((ptr-declr ,pointer (ident ,name)) name)
((array-of ,array . ,_) (ast->name array))
((ftn-declr (scope (ptr-declr ,pointer (ident ,name)))) name)
((ftn-declr (scope (ptr-declr ,pointer (ident ,name))) . _) name)
((ptr-declr ,pointer ,decl . ,_) (ast->name decl))
((ptr-declr ,pointer (ident ,name)) name)
(_ (error "ast->name not supported: " o))))
(define (init-declr->count info o)

View file

@ -96,6 +96,7 @@
function:name
function:type
function:text
function->string
->type
->rank
@ -196,6 +197,9 @@
(type function:type)
(text function:text))
(define (function->string o)
(function:name o))
(define (structured-type? o)
(cond ((type? o) (memq (type:type o) '(struct union)))
((global? o) ((compose structured-type? global:type) o))

View file

@ -129,6 +129,10 @@
(hex2:address address))
((#:address (#:address ,global)) (guard (global? global))
(hex2:address (global->string global)))
((#:address ,function) (guard (function? function))
(hex2:address (function->string function)))
((#:address ,number) (guard (number? number))
(string-join (map text->M1 (int->bv32 number))))
((#:string ,string)
(hex2:address (string->label o)))
((#:address ,address) (guard (string? address)) (hex2:address address))
@ -137,7 +141,8 @@
((#:offset ,offset) (hex2:offset offset))
((#:offset1 ,offset1) (hex2:offset1 offset1))
((#:immediate ,immediate) (hex2:immediate immediate))
((#:immediate1 ,immediate1) (hex2:immediate1 immediate1))))
((#:immediate1 ,immediate1) (hex2:immediate1 immediate1))
(_ (error "text->M1 no match o" o))))
((pair? o) (string-join (map text->M1 o)))))
(define (write-function o)
(let ((name (car o))