aboutsummaryrefslogtreecommitdiff
path: root/cc.h
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-04-04 12:12:58 -0700
committerMichael Forney <mforney@mforney.org>2019-04-04 12:31:18 -0700
commit6380b5cd6643bc0101e81c4da46d244466cda141 (patch)
tree2ff793b1cfd3549dcea6bf671754fd42126700fe /cc.h
parent6aee6c84fbfd0f11bbfd642610f783bc1b854234 (diff)
Move type definitions to the top of cc.h
Diffstat (limited to 'cc.h')
-rw-r--r--cc.h165
1 files changed, 81 insertions, 84 deletions
diff --git a/cc.h b/cc.h
index 20295f6..13e6a62 100644
--- a/cc.h
+++ b/cc.h
@@ -1,9 +1,4 @@
-struct expr;
struct func;
-struct scope;
-struct type;
-
-/* token */
enum tokenkind {
TNONE,
@@ -125,26 +120,6 @@ struct token {
char *lit;
};
-extern struct token tok;
-
-void tokprint(const struct token *);
-_Noreturn void error(const struct location *, const char *, ...);
-struct token;
-
-/* scan */
-
-int scanfrom(const char *file);
-void scan(struct token *);
-
-void ppinit(const char *);
-
-void next(void);
-_Bool peek(int);
-char *expect(int, const char *);
-_Bool consume(int);
-
-/* type */
-
enum typequal {
QUALNONE,
@@ -244,35 +219,6 @@ struct type {
};
};
-struct type *mktype(enum typekind);
-struct type *mkqualifiedtype(struct type *, enum typequal);
-struct type *mkpointertype(struct type *);
-struct type *mkarraytype(struct type *, uint64_t);
-
-_Bool typecompatible(struct type *, struct type *);
-_Bool typesame(struct type *, struct type *);
-struct type *typecomposite(struct type *, struct type *);
-struct type *typeunqual(struct type *, enum typequal *);
-struct type *typecommonreal(struct type *, struct type *);
-struct type *typeargpromote(struct type *);
-struct type *typeintpromote(struct type *);
-enum typeprop typeprop(struct type *);
-struct member *typemember(struct type *, const char *, uint64_t *);
-
-struct param *mkparam(char *, struct type *);
-
-extern struct type typevoid;
-extern struct type typebool;
-extern struct type typechar, typeschar, typeuchar;
-extern struct type typeshort, typeushort;
-extern struct type typeint, typeuint;
-extern struct type typelong, typeulong;
-extern struct type typellong, typeullong;
-extern struct type typefloat, typedouble, typelongdouble;
-extern struct type typevalist, typevalistptr;
-
-/* decl */
-
enum declkind {
DECLTYPE,
DECLOBJECT,
@@ -315,16 +261,6 @@ struct decl {
enum builtinkind builtin;
};
-struct decl *mkdecl(enum declkind, struct type *, enum linkage);
-_Bool decl(struct scope *, struct func *);
-struct type *typename(struct scope *);
-
-struct decl *stringdecl(struct expr *);
-
-void emittentativedefns(void);
-
-/* scope */
-
struct scope {
struct hashtable *tags;
struct hashtable *decls;
@@ -334,20 +270,6 @@ struct scope {
struct scope *parent;
};
-void scopeinit(void);
-struct scope *mkscope(struct scope *);
-struct scope *delscope(struct scope *);
-
-void scopeputdecl(struct scope *, const char *, struct decl *);
-struct decl *scopegetdecl(struct scope *, const char *, _Bool);
-
-void scopeputtag(struct scope *, const char *, struct type *);
-struct type *scopegettag(struct scope *, const char *, _Bool);
-
-extern struct scope filescope;
-
-/* expr */
-
enum exprkind {
/* primary expression */
EXPRIDENT,
@@ -434,6 +356,87 @@ struct expr {
};
};
+struct init {
+ uint64_t start, end;
+ struct expr *expr;
+ struct init *next;
+};
+
+/* token */
+
+extern struct token tok;
+
+void tokprint(const struct token *);
+_Noreturn void error(const struct location *, const char *, ...);
+struct token;
+
+/* scan */
+
+int scanfrom(const char *file);
+void scan(struct token *);
+
+void ppinit(const char *);
+
+void next(void);
+_Bool peek(int);
+char *expect(int, const char *);
+_Bool consume(int);
+
+/* type */
+
+struct type *mktype(enum typekind);
+struct type *mkqualifiedtype(struct type *, enum typequal);
+struct type *mkpointertype(struct type *);
+struct type *mkarraytype(struct type *, uint64_t);
+
+_Bool typecompatible(struct type *, struct type *);
+_Bool typesame(struct type *, struct type *);
+struct type *typecomposite(struct type *, struct type *);
+struct type *typeunqual(struct type *, enum typequal *);
+struct type *typecommonreal(struct type *, struct type *);
+struct type *typeargpromote(struct type *);
+struct type *typeintpromote(struct type *);
+enum typeprop typeprop(struct type *);
+struct member *typemember(struct type *, const char *, uint64_t *);
+
+struct param *mkparam(char *, struct type *);
+
+extern struct type typevoid;
+extern struct type typebool;
+extern struct type typechar, typeschar, typeuchar;
+extern struct type typeshort, typeushort;
+extern struct type typeint, typeuint;
+extern struct type typelong, typeulong;
+extern struct type typellong, typeullong;
+extern struct type typefloat, typedouble, typelongdouble;
+extern struct type typevalist, typevalistptr;
+
+/* decl */
+
+struct decl *mkdecl(enum declkind, struct type *, enum linkage);
+_Bool decl(struct scope *, struct func *);
+struct type *typename(struct scope *);
+
+struct decl *stringdecl(struct expr *);
+
+void emittentativedefns(void);
+
+/* scope */
+
+void scopeinit(void);
+struct scope *mkscope(struct scope *);
+struct scope *delscope(struct scope *);
+
+void scopeputdecl(struct scope *, const char *, struct decl *);
+struct decl *scopegetdecl(struct scope *, const char *, _Bool);
+
+void scopeputtag(struct scope *, const char *, struct type *);
+struct type *scopegettag(struct scope *, const char *, _Bool);
+
+extern struct scope filescope;
+
+/* expr */
+
struct expr *expr(struct scope *);
struct expr *assignexpr(struct scope *);
uint64_t intconstexpr(struct scope *, _Bool);
@@ -447,12 +450,6 @@ struct expr *eval(struct expr *);
/* init */
-struct init {
- uint64_t start, end;
- struct expr *expr;
- struct init *next;
-};
-
struct init *mkinit(uint64_t, uint64_t, struct expr *);
struct init *parseinit(struct scope *, struct type *);