summaryrefslogtreecommitdiff
path: root/parse
diff options
context:
space:
mode:
Diffstat (limited to 'parse')
-rw-r--r--parse/dump.c7
-rw-r--r--parse/infer.c1
-rw-r--r--parse/lits.def1
-rw-r--r--parse/node.c3
-rw-r--r--parse/parse.h9
-rw-r--r--parse/specialize.c23
-rw-r--r--parse/use.c16
7 files changed, 46 insertions, 14 deletions
diff --git a/parse/dump.c b/parse/dump.c
index 43b5d31..97622a2 100644
--- a/parse/dump.c
+++ b/parse/dump.c
@@ -206,6 +206,13 @@ static void outnode(Node *n, FILE *fd, int depth)
case Lflt: fprintf(fd, " Lflt %lf\n", n->lit.fltval); break;
case Lstr: fprintf(fd, " Lstr %.*s\n", (int)n->lit.strval.len, n->lit.strval.buf); break;
case Llbl: fprintf(fd, " Llbl %s\n", n->lit.lblval); break;
+ case Ljtab:
+ fprintf(fd, "Ljtab\n");
+ for (i = 0; i < n->lit.jtab->nval; i++) {
+ outnode(n->lit.jtab->val[i], fd, depth+1);
+ outnode(n->lit.jtab->dst[i], fd, depth+1);
+ }
+ break;
case Lfunc:
fprintf(fd, " Lfunc\n");
outnode(n->lit.fnval, fd, depth+1);
diff --git a/parse/infer.c b/parse/infer.c
index 937f116..3161a7c 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -528,6 +528,7 @@ static Type *littype(Node *n)
case Lstr: t = mktyslice(n->loc, mktype(n->loc, Tybyte)); break;
case Llbl: t = mktyptr(n->loc, mktype(n->loc, Tyvoid)); break;
case Lfunc: t = n->lit.fnval->func.type; break;
+ case Ljtab: t = mktype(n->loc, Tyvoid); break;
}
n->lit.type = t;
}
diff --git a/parse/lits.def b/parse/lits.def
index 2e5342f..9dd2c18 100644
--- a/parse/lits.def
+++ b/parse/lits.def
@@ -5,3 +5,4 @@ L(Lflt)
L(Lstr)
L(Lfunc)
L(Llbl)
+L(Ljtab)
diff --git a/parse/node.c b/parse/node.c
index ba3cd3c..f33e9ca 100644
--- a/parse/node.c
+++ b/parse/node.c
@@ -405,6 +405,9 @@ int liteq(Node *a, Node *b)
case Llbl:
return !strcmp(a->lit.lblval, b->lit.lblval);
break;
+ case Ljtab:
+ return 0;
+ break;
}
return 0;
}
diff --git a/parse/parse.h b/parse/parse.h
index fa7b99e..6070744 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -23,6 +23,7 @@ typedef struct Tok Tok;
typedef struct Node Node;
typedef struct Ucon Ucon;
typedef struct Stab Stab;
+typedef struct Jtab Jtab;
typedef struct Type Type;
typedef struct Trait Trait;
@@ -174,6 +175,13 @@ struct Type {
char isreflect; /* Tyname: whether this type has reflection info */
};
+struct Jtab {
+ Node **val;
+ size_t nval;
+ Node **dst;
+ size_t ndst;
+};
+
struct Ucon {
Srcloc loc;
size_t id; /* unique id */
@@ -248,6 +256,7 @@ struct Node {
char *lblval;
int boolval;
Node *fnval;
+ Jtab *jtab;
};
} lit;
diff --git a/parse/specialize.c b/parse/specialize.c
index 6cf5aa9..f7315e2 100644
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -177,10 +177,18 @@ static void fixup(Node *n)
break;
case Nlit:
switch (n->lit.littype) {
- case Lfunc: fixup(n->lit.fnval); break;
case Lchr: case Lint: case Lflt:
case Lstr: case Llbl: case Lbool:
break;
+ case Lfunc:
+ fixup(n->lit.fnval);
+ break;
+ case Ljtab:
+ for (i = 0; i < n->lit.jtab->nval; i++) {
+ fixup(n->lit.jtab->val[i]);
+ fixup(n->lit.jtab->dst[i]);
+ }
+ break;
}
break;
case Nifstmt:
@@ -271,12 +279,13 @@ static Node *specializenode(Node *n, Htab *tsmap)
r->lit.littype = n->lit.littype;
r->lit.type = tysubst(n->expr.type, tsmap);
switch (n->lit.littype) {
- case Lchr: r->lit.chrval = n->lit.chrval; break;
- case Lint: r->lit.intval = n->lit.intval; break;
- case Lflt: r->lit.fltval = n->lit.fltval; break;
- case Lstr: r->lit.strval = n->lit.strval; break;
- case Llbl: r->lit.lblval = n->lit.lblval; break;
- case Lbool: r->lit.boolval = n->lit.boolval; break;
+ case Ljtab: die("jtab in frontend?"); break;
+ case Lchr: r->lit.chrval = n->lit.chrval; break;
+ case Lint: r->lit.intval = n->lit.intval; break;
+ case Lflt: r->lit.fltval = n->lit.fltval; break;
+ case Lstr: r->lit.strval = n->lit.strval; break;
+ case Llbl: r->lit.lblval = n->lit.lblval; break;
+ case Lbool: r->lit.boolval = n->lit.boolval; break;
case Lfunc: r->lit.fnval = specializenode(n->lit.fnval, tsmap); break;
}
break;
diff --git a/parse/use.c b/parse/use.c
index 546a3cf..e7e2f6b 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -484,6 +484,7 @@ static void pickle(FILE *fd, Node *n)
case Llbl: wrstr(fd, n->lit.lblval); break;
case Lbool: wrbool(fd, n->lit.boolval); break;
case Lfunc: pickle(fd, n->lit.fnval); break;
+ case Ljtab: die("jtab in frontend?"); break;
}
break;
case Nloopstmt:
@@ -608,13 +609,14 @@ static Node *unpickle(FILE *fd)
rdtype(fd, &n->lit.type);
n->lit.nelt = rdint(fd);
switch (n->lit.littype) {
- case Lchr: n->lit.chrval = rdint(fd); break;
- case Lint: n->lit.intval = rdint(fd); break;
- case Lflt: n->lit.fltval = rdflt(fd); break;
- case Lstr: rdstrbuf(fd, &n->lit.strval); break;
- case Llbl: n->lit.lblval = rdstr(fd); break;
- case Lbool: n->lit.boolval = rdbool(fd); break;
- case Lfunc: n->lit.fnval = unpickle(fd); break;
+ case Lchr: n->lit.chrval = rdint(fd); break;
+ case Lint: n->lit.intval = rdint(fd); break;
+ case Lflt: n->lit.fltval = rdflt(fd); break;
+ case Lstr: rdstrbuf(fd, &n->lit.strval); break;
+ case Llbl: n->lit.lblval = rdstr(fd); break;
+ case Lbool: n->lit.boolval = rdbool(fd); break;
+ case Lfunc: n->lit.fnval = unpickle(fd); break;
+ case Ljtab: die("jtab in frontend?"); break;
}
break;
case Nloopstmt: