aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap')
-rw-r--r--bootstrap/all.h1
-rwxr-xr-xbootstrap/cff1bin21520 -> 22816 bytes
-rw-r--r--bootstrap/cgen.c7
-rw-r--r--bootstrap/dump.c2
-rw-r--r--bootstrap/env.c4
-rw-r--r--bootstrap/obj1/main.cff.obin4288 -> 5360 bytes
-rw-r--r--bootstrap/obj1/parse.cff.obin0 -> 3864 bytes
-rw-r--r--bootstrap/parse.c8
8 files changed, 18 insertions, 4 deletions
diff --git a/bootstrap/all.h b/bootstrap/all.h
index 3cadd4c..2996f62 100644
--- a/bootstrap/all.h
+++ b/bootstrap/all.h
@@ -76,6 +76,7 @@ enum toktype {
TKtype,
TKexpr,
TKlabel,
+ TKstrify,
TKeof,
};
diff --git a/bootstrap/cff1 b/bootstrap/cff1
index 7b0e748..6a4b6ff 100755
--- a/bootstrap/cff1
+++ b/bootstrap/cff1
Binary files differ
diff --git a/bootstrap/cgen.c b/bootstrap/cgen.c
index 3151edf..62a808d 100644
--- a/bootstrap/cgen.c
+++ b/bootstrap/cgen.c
@@ -240,7 +240,7 @@ genexpr(struct expr *ex) {
goto intlit;
break;
case Ezeroini:
- if (ty->t == TYarr || ty->t == TYstruct)
+ if (ty->t == TYarr || ty->t == TYstruct || ty->t == TYunion || ty->t == TYeunion || ty->t == TYslice)
pri("((%t){0})", ty);
else
pri("((%t)0)", ty);
@@ -699,12 +699,15 @@ defctype(const struct type *ty, void *_) {
*cname = xasprintf("__ty%s%d", ty->agg.name ? ty->agg.name : "", id++);
pri("typedef %s %s %s;\n", kind, *cname, *cname);
if (!ty->agg.fwd) {
+ for (int i = 0; i < ty->agg.flds.n; ++i) {
+ struct aggfield fld = ty->agg.flds.d[i];
+ defctype(fld.ty, NULL);
+ }
pri("%s %s {\n", kind, *cname);
if (!ty->agg.flds.n)
pri("char _;\n");
for (int i = 0; i < ty->agg.flds.n; ++i) {
struct aggfield fld = ty->agg.flds.d[i];
- defctype(ty->agg.flds.d[i].ty, NULL);
pri("%t %s;\n", fld.ty, fld.name);
}
pri("};\n");
diff --git a/bootstrap/dump.c b/bootstrap/dump.c
index 157b12f..3bd915f 100644
--- a/bootstrap/dump.c
+++ b/bootstrap/dump.c
@@ -159,6 +159,8 @@ tok2str(struct tok tok) {
return "<type parameter>";
} else if (tok.t == TKexpr) {
return "<const parameter>";
+ } else if (tok.t == TKstrify) {
+ return "#strify";
} else {
snprintf(buf, sizeof buf - 1, "`%c'", tok.t);
}
diff --git a/bootstrap/env.c b/bootstrap/env.c
index b3652fa..601b446 100644
--- a/bootstrap/env.c
+++ b/bootstrap/env.c
@@ -48,8 +48,7 @@ envput(struct env *env, const struct decl *decl) {
}
}
if (d0->t == Dfn && d0->externp == decl->externp && d0->fn.selfty == decl->fn.selfty && !d0->fn.body && decl->fn.body) {
- d0->fn.body = decl->fn.body;
- return d0;
+ goto ok;
}
if (d0->t == Dfn && d0->externp == decl->externp && d0->fn.selfty == decl->fn.selfty && !d0->fn.body)
return d0;
@@ -61,6 +60,7 @@ envput(struct env *env, const struct decl *decl) {
return NULL;
}
}
+ok:
decls = xcalloc(1, sizeof *decls);
decls->next = env->decls;
diff --git a/bootstrap/obj1/main.cff.o b/bootstrap/obj1/main.cff.o
index 7264f1c..2210165 100644
--- a/bootstrap/obj1/main.cff.o
+++ b/bootstrap/obj1/main.cff.o
Binary files differ
diff --git a/bootstrap/obj1/parse.cff.o b/bootstrap/obj1/parse.cff.o
new file mode 100644
index 0000000..87687b9
--- /dev/null
+++ b/bootstrap/obj1/parse.cff.o
Binary files differ
diff --git a/bootstrap/parse.c b/bootstrap/parse.c
index 67ec66d..180ddea 100644
--- a/bootstrap/parse.c
+++ b/bootstrap/parse.c
@@ -381,6 +381,14 @@ lex(struct parser *P) {
} else if (!strncmp(s, "#'", 2)) {
tok.t = TKlabel;
tok.str = xstrdup(s);
+ } else if (!strcmp(s, "#FILE")) {
+ tok.t = TKstrlit;
+ tok.str = P->curfile;
+ tok.strlen = strlen(P->curfile);
+ } else if (!strcmp(s, "#LINE")) {
+ tok.t = TKintlit;
+ tok.ty = ty_uint;
+ tok.ilit.i = P->tokspan.line;
} else {
fatal(P, P->tokspan, "invalid #keyword");
}