From cc043496045c5588cc969b5a75af60b084ecc69a Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Sun, 24 May 2020 12:43:03 -0700 Subject: feat: added prototype of type info --- sys/cmd/cc/cc.h | 56 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'sys/cmd/cc/cc.h') diff --git a/sys/cmd/cc/cc.h b/sys/cmd/cc/cc.h index 4b61346..e8ab05e 100644 --- a/sys/cmd/cc/cc.h +++ b/sys/cmd/cc/cc.h @@ -19,10 +19,12 @@ typedef struct Scope Scope; typedef struct Parser Parser; -typedef struct Node Node; typedef struct Ptr Ptr; typedef struct Name Name; typedef struct Dtor Dtor; +typedef struct Obj Obj; + +typedef struct Node Node; typedef struct Decl Decl; typedef struct Stmt Stmt; typedef struct Expr Expr; @@ -40,12 +42,12 @@ typedef struct Compiler Compiler; KEYWORD(Kextern,"extern") \ KEYWORD(Ktls,"thread_local") \ KEYWORD(Ktypedef,"typedef") \ + KEYWORD(Kinline,"inline") \ + KEYWORD(Knoret,"_Noreturn") \ KEYWORD(Kconst,"const") \ KEYWORD(Kvolatile,"volatile") \ KEYWORD(Krestrict,"restrict") \ KEYWORD(Katomic,"_Atomic") \ - KEYWORD(Kinline,"inline") \ - KEYWORD(Knoret,"_Noreturn") \ KEYWORD(Ksigned,"signed") \ KEYWORD(Kunsigned,"unsigned") \ KEYWORD(Kvoid,"void") \ @@ -242,7 +244,7 @@ struct Sym union { string macro; Decl *obj; - Type *tag; + Type *typ; Stmt *blk; }; }; @@ -524,7 +526,6 @@ enum MaskSgn = Tsign | Tunsign, Tvoid = iota(Kvoid), - Tfloat = iota(Kfloat), Tdouble = iota(Kdouble), Tcmplx = iota(Kcomplex), @@ -561,20 +562,12 @@ struct Ptr Ptr *link; }; -struct Param -{ - uint32 qual; - Type *type; - string name; -}; - struct Name { uint32 kind; union { string ident; struct Dtor *paren; - /* This is bloated ! */ struct { Name *name; union { @@ -584,7 +577,8 @@ struct Name } idx; struct { int n; - struct Param *arg; + int vararg : 1; + Obj *arg; } call; }; } sfx; @@ -605,6 +599,14 @@ struct Decls }; /* final ast node */ + +struct Obj +{ + uint32 qual; + Type *type; + string name; +}; + struct Decl { struct Node; @@ -633,21 +635,26 @@ enum /* types */ struct Type { - Sym *sym; + uint32 kind; string ident; - uint64 kind; + Sym *sym; uintptr size; - uint16 align; + uintptr max; + uint16 align : 8; + uint16 sign : 2; union { - Type *ptr; + struct { + uint32 qual; + Type *base; + } ptr; struct { int len; Type *elt; } arr; struct { - int len; - Dtor *d; - Expr *x; + int len; + Obj *f; + Expr *x; } agr; struct { int len; @@ -657,6 +664,13 @@ struct Type }; }; +/* platform specific */ +extern Type pointer; +extern Type basetypes[22]; +/* mandated by C standard */ +extern uint64 validtypespec[40]; +extern int indextypespec[40]; + struct Scope { SymTab tags; -- cgit v1.2.1