ref: 730217466af331194862aef9a100b76e44520b5c
parent: e374016cbdd281d23802c25aed35febe247560a6
author: Ori Bernstein <[email protected]>
date: Wed Sep 4 12:58:53 EDT 2013
Rename 'param' to 'arg'
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -401,8 +401,8 @@
return;
htput(bt, t->pname, t);
- for (i = 0; i < t->nparam; i++)
- putbindings(st, bt, t->param[i]);
+ for (i = 0; i < t->narg; i++)
+ putbindings(st, bt, t->arg[i]);
}
static void tybind(Inferstate *st, Type *t)
@@ -542,7 +542,7 @@
static int hasparam(Type *t)
{
- return t->type == Tyname && t->nparam > 0;
+ return t->type == Tyname && t->narg > 0;
}
/* Unifies two types, or errors if the types are not unifiable. */
@@ -600,11 +600,11 @@
if (!nameeq(a->name, b->name))
fatal(ctx->line, "%s incompatible with %s near %s",
tystr(a), tystr(b), ctxstr(st, ctx));
- if (a->nparam != b->nparam)
+ if (a->narg != b->narg)
fatal(ctx->line, "%s has wrong parameter list for %s near %s",
tystr(a), tystr(b), ctxstr(st, ctx));
- for (i = 0; i < a->nparam; i++)
- unify(st, ctx, a->param[i], b->param[i]);
+ for (i = 0; i < a->narg; i++)
+ unify(st, ctx, a->arg[i], b->arg[i]);
} else if (a->type != Tyvar) {
fatal(ctx->line, "%s incompatible with %s near %s",
tystr(a), tystr(b), ctxstr(st, ctx));
@@ -657,10 +657,10 @@
if (b->type != Tyunres && b->type != Tyname)
return;
- if (a->nparam != b->nparam)
+ if (a->narg != b->narg)
fatal(ctx->line, "Mismatched parameter list sizes: %s with %s near %s", tystr(a), tystr(b), ctxstr(st, ctx));
- for (i = 0; i < a->nparam; i++)
- unify(st, ctx, a->param[i], b->param[i]);
+ for (i = 0; i < a->narg; i++)
+ unify(st, ctx, a->arg[i], b->arg[i]);
}
static void loaduses(Node *n)
@@ -1260,8 +1260,8 @@
t->udecls[i]->etype = tyfix(st, ctx, t->udecls[i]->etype);
}
} else if (t->type == Tyname) {
- for (i = 0; i < t->nparam; i++)
- t->param[i] = tyfix(st, ctx, t->param[i]);
+ for (i = 0; i < t->narg; i++)
+ t->arg[i] = tyfix(st, ctx, t->arg[i]);
}
for (i = 0; i < t->nsub; i++)
t->sub[i] = tyfix(st, ctx, t->sub[i]);
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -114,8 +114,8 @@
size_t ncstrlist; /* The length of the constraint list above */
int isgeneric; /* Tyname: whether this is generic or not */
- Type **param; /* Tyname: the type parameters captured */
- size_t nparam; /* Tyname: count of type parameters */
+ Type **arg; /* Tyname: the type parameters captured */
+ size_t narg; /* Tyname: count of type parameters */
Type **inst; /* Tyname: instances created */
size_t ninst; /* Tyname: count of instances created */
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -56,13 +56,13 @@
if (!t->isgeneric) {
ret = t;
} else {
- for (i = 0; i < t->nparam; i++)
- if (!hthas(tsmap, t->param[i]))
- htput(tsmap, t->param[i], mktyvar(t->param[i]->line));
+ for (i = 0; i < t->narg; i++)
+ if (!hthas(tsmap, t->arg[i]))
+ htput(tsmap, t->arg[i], mktyvar(t->arg[i]->line));
ret = mktyname(t->line, t->name, NULL, 0, tyspecialize(t->sub[0], tsmap));
htput(tsmap, t, ret);
- for (i = 0; i < t->nparam; i++)
- lappend(&ret->param, &ret->nparam, tyspecialize(t->param[i], tsmap));
+ for (i = 0; i < t->narg; i++)
+ lappend(&ret->arg, &ret->narg, tyspecialize(t->arg[i], tsmap));
}
break;
case Tystruct:
--- a/parse/type.c
+++ b/parse/type.c
@@ -64,9 +64,9 @@
r->cstrlist = memdup(t->cstrlist, t->ncstrlist * sizeof(Node*));
r->ncstrlist = t->ncstrlist;
- r->param = memdup(t->param, t->nparam * sizeof(Type*));
- r->nparam = t->nparam;
- r->inst = memdup(t->param, t->nparam * sizeof(Type*));
+ r->arg = memdup(t->arg, t->narg * sizeof(Type*));
+ r->narg = t->narg;
+ r->inst = memdup(t->arg, t->narg * sizeof(Type*));
r->ninst = t->ninst;
r->sub = memdup(t->sub, t->nsub * sizeof(Type*));
@@ -134,7 +134,7 @@
return t;
}
-Type *mktyunres(int line, Node *name, Type **param, size_t nparam)
+Type *mktyunres(int line, Node *name, Type **arg, size_t narg)
{
Type *t;
@@ -141,12 +141,12 @@
/* resolve it in the type inference stage */
t = mktype(line, Tyunres);
t->name = name;
- t->param = param;
- t->nparam = nparam;
+ t->arg = arg;
+ t->narg = narg;
return t;
}
-Type *mktyname(int line, Node *name, Type **param, size_t nparam, Type *base)
+Type *mktyname(int line, Node *name, Type **arg, size_t narg, Type *base)
{
Type *t;
@@ -156,8 +156,8 @@
t->cstrs = bsdup(base->cstrs);
t->sub = xalloc(sizeof(Type*));
t->sub[0] = base;
- t->param = param;
- t->nparam = nparam;
+ t->arg = arg;
+ t->narg = narg;
return t;
}
@@ -449,11 +449,11 @@
case Tyunres:
p += snprintf(p, end - p, "?"); /* indicate unresolved name. should not be seen by user. */
p += namefmt(p, end - p, t->name);
- if (t->nparam) {
+ if (t->narg) {
p += snprintf(p, end - p, "(");
- for (i = 0; i < t->nparam; i++) {
+ for (i = 0; i < t->narg; i++) {
p += snprintf(p, end - p, "%s", sep);
- p += tybfmt(p, end - p, t->param[i]);
+ p += tybfmt(p, end - p, t->arg[i]);
sep = ", ";
}
p += snprintf(p, end - p, ")");
@@ -461,11 +461,11 @@
break;
case Tyname:
p += snprintf(p, end - p, "%s", namestr(t->name));
- if (t->nparam) {
+ if (t->narg) {
p += snprintf(p, end - p, "(");
- for (i = 0; i < t->nparam; i++) {
+ for (i = 0; i < t->narg; i++) {
p += snprintf(p, end - p, "%s", sep);
- p += tybfmt(p, end - p, t->param[i]);
+ p += tybfmt(p, end - p, t->arg[i]);
sep = ", ";
}
p += snprintf(p, end - p, ")");
@@ -517,8 +517,8 @@
else
hash = inthash(t->tid);
- for (i = 0; i < t->nparam; i++)
- hash ^= tyhash(t->param[i]);
+ for (i = 0; i < t->narg; i++)
+ hash ^= tyhash(t->arg[i]);
return hash;
}
@@ -533,10 +533,10 @@
return streq(a->pname, b->pname);
if (a->tid == b->tid)
return 1;
- if (a->nparam != b->nparam)
+ if (a->narg != b->narg)
return 0;
- for (i = 0; i < a->nparam; i++)
- if (!tyeq(a->param[i], b->param[i]))
+ for (i = 0; i < a->narg; i++)
+ if (!tyeq(a->arg[i], b->arg[i]))
return 0;
return 1;
}
--- a/parse/use.c
+++ b/parse/use.c
@@ -209,9 +209,9 @@
break;
case Tyname:
pickle(ty->name, fd);
- wrint(fd, ty->nparam);
- for (i = 0; i < ty->nparam; i++)
- wrtype(fd, ty->param[i]);
+ wrint(fd, ty->narg);
+ for (i = 0; i < ty->narg; i++)
+ wrtype(fd, ty->arg[i]);
wrtype(fd, ty->sub[0]);
break;
default:
@@ -288,10 +288,10 @@
break;
case Tyname:
ty->name = unpickle(fd);
- ty->nparam = rdint(fd);
- ty->param = zalloc(ty->nparam * sizeof(Type *));
- for (i = 0; i < ty->nparam; i++)
- rdtype(fd, &ty->param[i]);
+ ty->narg = rdint(fd);
+ ty->arg = zalloc(ty->narg * sizeof(Type *));
+ for (i = 0; i < ty->narg; i++)
+ rdtype(fd, &ty->arg[i]);
rdtype(fd, &ty->sub[0]);
break;
default:
@@ -686,8 +686,8 @@
t->vis = Vishidden;
for (i = 0; i < t->nsub; i++)
taghidden(t->sub[i]);
- for (i = 0; i < t->nparam; i++)
- taghidden(t->param[i]);
+ for (i = 0; i < t->narg; i++)
+ taghidden(t->arg[i]);
if (t->type == Tystruct) {
for (i = 0; i < t->nmemb; i++)
taghidden(decltype(t->sdecls[i]));
@@ -776,8 +776,8 @@
t->vis = Visexport;
for (j = 0; j < t->nsub; j++)
taghidden(t->sub[j]);
- for (j = 0; j < t->nparam; j++)
- taghidden(t->param[j]);
+ for (j = 0; j < t->narg; j++)
+ taghidden(t->arg[j]);
}
free(k);