aboutsummaryrefslogtreecommitdiffhomepage
path: root/c/c.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/c.h')
-rw-r--r--c/c.h38
1 files changed, 34 insertions, 4 deletions
diff --git a/c/c.h b/c/c.h
index 81c07f9..e8e797c 100644
--- a/c/c.h
+++ b/c/c.h
@@ -5,7 +5,7 @@
/*************/
enum exprkind {
- EXXX, ENUMLIT, ESTRLIT, ESYM, EINIT, EGETF, ECALL, ECOND,
+ EXXX, ENUMLIT, ESTRLIT, ESYM, EVAARG, EINIT, EGETF, ECALL, ECOND,
/* unary */
EPLUS, ENEG, ECOMPL, ELOGNOT, EDEREF, EADDROF, ECAST,
EPREINC, EPOSTINC, EPREDEC, EPOSTDEC,
@@ -59,6 +59,18 @@ struct init {
} *vals, **tail;
};
+/** C compiler state **/
+struct comp {
+ struct lexer *lx;
+ struct env *env;
+ struct arena *fnarena, *exarena;
+ struct span fnblkspan;
+ uint loopdepth, switchdepth;
+ struct block *breakto, *loopcont;
+ struct switchstmt *switchstmt;
+ struct label *labels;
+};
+
enum storageclass {
SCNONE,
SCTYPEDEF = 1<<0,
@@ -72,17 +84,35 @@ enum storageclass {
struct decl {
union type ty;
uchar scls;
- uchar qual : 2;
- uchar isenum : 1;
- uchar isdef : 1;
+ uchar qual : 2,
+ isenum : 1,
+ isdef : 1,
+ isbuiltin : 1;
struct span span;
const char *name;
union {
struct { ushort align; int id; };
vlong value;
+ const struct builtin *builtin;
};
};
+extern union type cvalistty;
+struct function;
+struct decl *envadddecl(struct env *env, const struct decl *d);
+bool assigncheck(union type t, const struct expr *src);
+union ref expraddr(struct function *, const struct expr *);
+union ref compileexpr(struct function *, const struct expr *, bool discard);
+
+/** builtin.c **/
+struct builtin {
+ bool (*sema)(struct comp *, struct expr *);
+ union ref (*comp)(struct function *, struct expr *, bool discard);
+};
+void putbuiltins(struct env *);
+union ref builtin_va_arg_comp(struct function *, const struct expr *, bool discard);
+
+/** eval.c **/
enum evalmode {
EVNONE,
EVINTCONST,