summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2012-08-07 22:50:53 -0400
committerOri Bernstein <ori@eigenstate.org>2012-08-07 22:50:53 -0400
commit38f794994e2b62efdbaebabf18eb0cee84390a2f (patch)
tree91b160c093d5bfb518abbfc1ac5aa45e0a731798
parentda7a658feb3f1d785fc557747baf9557c7926520 (diff)
downloadmc-38f794994e2b62efdbaebabf18eb0cee84390a2f.tar.gz
Rename type names.
Tyname -> Tyunres (unresolved types) Tyalias -> Tyname (named types)
-rw-r--r--6/simp.c6
-rw-r--r--doc/lang.txt2
-rw-r--r--parse/gram.y5
-rw-r--r--parse/infer.c2
-rw-r--r--parse/parse.h2
-rw-r--r--parse/pickle.c8
-rw-r--r--parse/tok.c1
-rw-r--r--parse/type.c12
-rw-r--r--parse/types.def2
9 files changed, 22 insertions, 18 deletions
diff --git a/6/simp.c b/6/simp.c
index 1d06243..a1af977 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -257,7 +257,7 @@ size_t tysize(Type *t)
case Tyslice:
return 2*Ptrsz; /* len; ptr */
- case Tyalias:
+ case Tyname:
return tysize(t->sub[0]);
case Tyarray:
assert(exprop(t->asize) == Olit);
@@ -279,7 +279,7 @@ size_t tysize(Type *t)
sz = max(sz, tysize(t->udecls[i]->etype) + Ptrsz);
return align(sz, Ptrsz);
break;
- case Tybad: case Tyvar: case Typaram: case Tyname: case Ntypes:
+ case Tybad: case Tyvar: case Typaram: case Tyunres: case Ntypes:
die("Type %s does not have size; why did it get down to here?", tystr(t));
break;
}
@@ -456,7 +456,7 @@ static Node *ucompare(Simp *s, Node *a, Node *b, Type *t, size_t off)
r = NULL;
switch (t->type) {
case Tyvoid: case Tybad: case Tyvalist: case Tyvar:
- case Typaram: case Tyname: case Tyalias: case Ntypes:
+ case Typaram: case Tyunres: case Tyname: case Ntypes:
case Tyint64: case Tyuint64: case Tylong: case Tyulong:
case Tyfloat32: case Tyfloat64:
case Tyslice: case Tyarray: case Tytuple: case Tystruct:
diff --git a/doc/lang.txt b/doc/lang.txt
index 876a89b..9b4ab86 100644
--- a/doc/lang.txt
+++ b/doc/lang.txt
@@ -104,6 +104,8 @@ Declarations:
generic id = {a:@a; -> a}
+Control Structures:
+
Types:
Myrddin comes with a large number of built in types. These are
diff --git a/parse/gram.y b/parse/gram.y
index 98d955a..2efc0ed 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -88,6 +88,7 @@ static void constrainwith(Type *t, char *str);
%token<tok> Tchrlit
%token<tok> Tboollit
+%token<tok> Ttrait /* trait */
%token<tok> Tstruct /* struct */
%token<tok> Tunion /* union */
%token<tok> Ttyparam /* @typename */
@@ -105,7 +106,7 @@ static void constrainwith(Type *t, char *str);
%token<tok> Tendln /* ; or \n */
%token<tok> Tendblk /* ;; */
%token<tok> Tcolon /* : */
-%token<tok> Ttrait /* :: */
+%token<tok> Twith /* :: */
%token<tok> Tdot /* . */
%token<tok> Tcomma /* , */
%token<tok> Tret /* -> */
@@ -285,7 +286,7 @@ generictype
typaramlist
: /* empty */ {$$ = NULL;}
- | Ttrait name {$$ = $2;}
+ | Twith name {$$ = $2;}
;
compoundtype
diff --git a/parse/infer.c b/parse/infer.c
index cdcc895..ad7bdda 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -183,7 +183,7 @@ static Type *tf(Inferstate *st, Type *t)
assert(t != NULL);
lu = NULL;
while (1) {
- if (!tytab[t->tid] && t->type == Tyname) {
+ if (!tytab[t->tid] && t->type == Tyunres) {
if (!(lu = gettype(curstab(), t->name)))
fatal(t->name->line, "Could not fixed type %s", namestr(t->name));
tytab[t->tid] = lu;
diff --git a/parse/parse.h b/parse/parse.h
index 2b9f2bb..029159c 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -220,7 +220,7 @@ struct Node {
struct {
size_t did;
char isglobl;
- char isexport;
+ char isexport;
char isconst;
char isgeneric;
char isextern;
diff --git a/parse/pickle.c b/parse/pickle.c
index 8cf64ba..9834317 100644
--- a/parse/pickle.c
+++ b/parse/pickle.c
@@ -170,7 +170,7 @@ static void wrtype(FILE *fd, Type *ty)
/* cstrs are left out for now: FIXME */
wrint(fd, ty->nsub);
switch (ty->type) {
- case Tyname:
+ case Tyunres:
pickle(ty->name, fd);
break;
case Typaram:
@@ -196,7 +196,7 @@ static void wrtype(FILE *fd, Type *ty)
case Tyvar:
die("Attempting to pickle %s. This will not work.\n", tystr(ty));
break;
- case Tyalias:
+ case Tyname:
pickle(ty->name, fd);
wrtype(fd, ty->sub[0]);
break;
@@ -221,7 +221,7 @@ static Type *rdtype(FILE *fd)
if (ty->nsub > 0)
ty->sub = xalloc(ty->nsub * sizeof(Type*));
switch (ty->type) {
- case Tyname:
+ case Tyunres:
ty->name = unpickle(fd);
break;
case Typaram:
@@ -246,7 +246,7 @@ static Type *rdtype(FILE *fd)
case Tyslice:
ty->sub[0] = rdtype(fd);
break;
- case Tyalias:
+ case Tyname:
ty->name = unpickle(fd);
ty->sub[0] = rdtype(fd);
break;
diff --git a/parse/tok.c b/parse/tok.c
index a87e5d3..2b32374 100644
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -148,6 +148,7 @@ static int kwd(char *s)
{"protect", Tprotect},
{"sizeof", Tsizeof},
{"struct", Tstruct},
+ {"trait", Ttrait},
{"true", Tboollit},
{"type", Ttype},
{"union", Tunion},
diff --git a/parse/type.c b/parse/type.c
index d258075..64bdc08 100644
--- a/parse/type.c
+++ b/parse/type.c
@@ -53,7 +53,7 @@ Type *tydup(Type *t)
r->nmemb = t->nmemb;
r->sub = memdup(t->sub, t->nsub * sizeof(Type*));
switch (t->type) {
- case Tyname: r->name = t->name; break;
+ case Tyunres: r->name = t->name; break;
case Tyarray: r->asize = t->asize; break;
case Typaram: r->pname = strdup(t->pname); break;
case Tystruct: r->sdecls = memdup(t->sdecls, t->nmemb*sizeof(Node*)); break;
@@ -112,7 +112,7 @@ Type *mktynamed(int line, Node *name)
Type *t;
/* resolve it in the type inference stage */
- t = mkty(line, Tyname);
+ t = mkty(line, Tyunres);
t->name = name;
return t;
}
@@ -121,7 +121,7 @@ Type *mktyalias(int line, Node *name, Type *base)
{
Type *t;
- t = mkty(line, Tyalias);
+ t = mkty(line, Tyname);
t->name = name;
t->nsub = 1;
t->cstrs = bsdup(base->cstrs);
@@ -238,7 +238,7 @@ int istysigned(Type *t)
Type *tybase(Type *t)
{
- while (t->type == Tyalias)
+ while (t->type == Tyname)
t = t->sub[0];
return t;
}
@@ -414,11 +414,11 @@ static int tybfmt(char *buf, size_t len, Type *t)
case Typaram:
p += snprintf(p, end - p, "@%s", t->pname);
break;
- case Tyname:
+ case Tyunres:
p += snprintf(p, end - p, "?"); /* indicate unresolved name. should not be seen by user. */
p += namefmt(p, end - p, t->name);
break;
- case Tyalias:
+ case Tyname:
p += snprintf(p, end - p, "%s", namestr(t->name));
break;
case Tystruct: p += fmtstruct(p, end - p, t); break;
diff --git a/parse/types.def b/parse/types.def
index b702a33..591c1fe 100644
--- a/parse/types.def
+++ b/parse/types.def
@@ -41,6 +41,6 @@ Ty(Tyunion, NULL)
/* these have no memory repr */
Ty(Tyvar, NULL)
Ty(Typaram, NULL)
+Ty(Tyunres, NULL) /* unresolved */
Ty(Tyname, NULL)
-Ty(Tyalias, NULL)
Ty(Ntypes, NULL)