mescc: Tinycc support: Function variables.
This commit is contained in:
parent
8cc406c9ff
commit
ec13ccc19f
|
@ -176,6 +176,8 @@
|
|||
|
||||
(define (ast->type o info)
|
||||
(define (type-helper o info)
|
||||
(if (getenv "MESC_DEBUG")
|
||||
(stderr "type-helper: ~s\n" o))
|
||||
(pmatch o
|
||||
(,t (guard (type? t)) t)
|
||||
(,p (guard (pointer? p)) p)
|
||||
|
@ -202,8 +204,13 @@
|
|||
(let ((type (get-type name info)))
|
||||
(ast->type type info)))
|
||||
|
||||
((fctn-call (p-expr (ident ,name)) . _) (or (ident->type info name)
|
||||
(get-type "int" info)))
|
||||
((fctn-call (p-expr (ident ,name)) . _)
|
||||
(or (and=> (assoc-ref (.functions info) name) function:type)
|
||||
(get-type "int" info)))
|
||||
|
||||
((fctn-call (de-ref (p-expr (ident ,name))) . _)
|
||||
(or (and=> (assoc-ref (.functions info) name) function:type)
|
||||
(get-type "int" info)))
|
||||
|
||||
((fixed-type ,type) (ast->type type info))
|
||||
((float-type ,type) (ast->type type info))
|
||||
|
@ -1745,6 +1752,8 @@
|
|||
(strings (filter string-global? (.globals tmp))))
|
||||
(clone info #:globals (append (.globals info) strings)
|
||||
#:statics (append statics (.statics info)))))))
|
||||
(((decl-spec-list (stor-spec (,store)) (type-spec ,type)))
|
||||
(type->info type #f info))
|
||||
(((@ . _))
|
||||
(stderr "decl->info: skip: ~s\n" o)
|
||||
info)
|
||||
|
@ -1938,6 +1947,11 @@
|
|||
(type (rank+= type rank)))
|
||||
(if (.function info) (local->info type name o init info)
|
||||
(global->info type name o init info))))
|
||||
(((ftn-declr (scope (ptr-declr ,pointer (ident ,name))) ,param-list))
|
||||
(let* ((rank (pointer->rank pointer))
|
||||
(type (rank+= type rank)))
|
||||
(if (.function info) (local->info type name o '() info)
|
||||
(global->info type name o '() info))))
|
||||
(((ptr-declr ,pointer . ,_) . ,init)
|
||||
(let* ((rank (pointer->rank pointer))
|
||||
(type (rank+= type rank)))
|
||||
|
|
|
@ -34,7 +34,7 @@ char *list[2] = {"foo\n", "bar\n"};
|
|||
|
||||
struct foo {int length; char* string;};
|
||||
struct foo g_f = {3, "foo"};
|
||||
struct foo g_g = &g_f;
|
||||
struct foo *g_g = &g_f;
|
||||
struct foo g_foes[2];
|
||||
int g_foe;
|
||||
|
||||
|
@ -57,6 +57,12 @@ test (struct foo* p)
|
|||
p[0].length = 0;
|
||||
}
|
||||
|
||||
int
|
||||
next_main (int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char* argv[])
|
||||
{
|
||||
|
@ -131,6 +137,14 @@ main (int argc, char* argv[])
|
|||
char buf[sizeof (g_f.string)];
|
||||
char buf1[sizeof (g_g->string)];
|
||||
|
||||
int (*fun)(int, char **);
|
||||
fun = &next_main;
|
||||
//i = (*fun)(argc, argv);
|
||||
|
||||
int (*fun2)(int, char *[]);
|
||||
fun2 = &next_main;
|
||||
//i = (*fun2)(argc, argv);
|
||||
|
||||
i = 1;
|
||||
int lst[6] = {-1, 1 - 1, i, 2, 3};
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
|
Loading…
Reference in a new issue