Commit d5a80d0b authored by Russ Cox's avatar Russ Cox

gc: no more ...

various cleanup, deleting unused code

R=ken2
CC=golang-dev
https://golang.org/cl/1663041
parent 6672b40c
......@@ -30,6 +30,7 @@
#include "go.h"
/*
Bits
bor(Bits a, Bits b)
{
......@@ -52,7 +53,6 @@ band(Bits a, Bits b)
return c;
}
/*
Bits
bnot(Bits a)
{
......@@ -76,6 +76,7 @@ bany(Bits *a)
return 0;
}
/*
int
beq(Bits a, Bits b)
{
......@@ -86,6 +87,7 @@ beq(Bits a, Bits b)
return 0;
return 1;
}
*/
int
bnum(Bits a)
......@@ -110,6 +112,7 @@ blsh(uint n)
return c;
}
/*
int
bset(Bits a, uint n)
{
......@@ -117,6 +120,7 @@ bset(Bits a, uint n)
return 1;
return 0;
}
*/
int
bitno(int32 b)
......
......@@ -1117,7 +1117,7 @@ nonnegconst(Node *n)
* convert x to type et and back to int64
* for sign extension and truncation.
*/
int64
static int64
iconv(int64 x, int et)
{
switch(et) {
......
......@@ -7,7 +7,7 @@
static void funcargs(Node*);
int
static int
dflag(void)
{
if(!debug['d'])
......@@ -24,7 +24,7 @@ dflag(void)
*/
static Sym* dclstack;
void
static void
dcopy(Sym *a, Sym *b)
{
a->pkg = b->pkg;
......@@ -34,7 +34,7 @@ dcopy(Sym *a, Sym *b)
a->lastlineno = b->lastlineno;
}
Sym*
static Sym*
push(void)
{
Sym *d;
......@@ -45,7 +45,7 @@ push(void)
return d;
}
Sym*
static Sym*
pushdcl(Sym *s)
{
Sym *d;
......@@ -217,90 +217,6 @@ addvar(Node *n, Type *t, int ctxt)
n->type = t;
}
// TODO: cut use of below in sigtype and then delete
void
addtyp(Type *n, int ctxt)
{
Node *def;
if(n==T || n->sym == S)
fatal("addtyp: n=%T t=%T nil", n);
def = typenod(n);
declare(def, ctxt);
n->vargen = def->vargen;
typelist = list(typelist, def);
}
/*
* introduce a type named n
* but it is an unknown type for now
*/
// TODO(rsc): cut use of this in sigtype and then delete
Type*
dodcltype(Type *n)
{
addtyp(n, dclcontext);
n->local = 1;
autoexport(typenod(n), dclcontext);
return n;
}
/*
* now we know what n is: it's t
*/
// TODO(rsc): cut use of this in sigtype and then delete
void
updatetype(Type *n, Type *t)
{
Sym *s;
int local, vargen;
int maplineno, lno, etype;
if(t == T)
return;
s = n->sym;
if(s == S || s->def == N || s->def->op != OTYPE || s->def->type != n)
fatal("updatetype %T = %T", n, t);
etype = n->etype;
switch(n->etype) {
case TFORW:
break;
default:
fatal("updatetype %T / %T", n, t);
}
// decl was
// type n t;
// copy t, but then zero out state associated with t
// that is no longer associated with n.
maplineno = n->maplineno;
local = n->local;
vargen = n->vargen;
*n = *t;
n->orig = t->orig;
n->sym = s;
n->local = local;
n->siggen = 0;
n->printed = 0;
n->method = nil;
n->vargen = vargen;
n->nod = N;
checkwidth(n);
// double-check use of type as map key
if(maplineno) {
lno = lineno;
lineno = maplineno;
maptype(n, types[TBOOL]);
lineno = lno;
}
}
/*
* declare variables from grammar
* new_name_list (type | [type] = expr_list)
......@@ -544,8 +460,6 @@ dclchecks(void)
static int
colasname(Node *n)
{
// TODO(rsc): can probably simplify
// once late-binding of names goes in
switch(n->op) {
case ONAME:
case ONONAME:
......@@ -769,7 +683,7 @@ ok:
/*
* turn a parsed struct into a type
*/
Type**
static Type**
stotype(NodeList *l, int et, Type **t)
{
Type *f, *t1, *t2, **t0;
......@@ -1028,15 +942,9 @@ checkarglist(NodeList *all, int input)
yyerror("cannot use ... in output argument list");
else if(l->next != nil)
yyerror("can only use ... as final argument in list");
if(n->right->left == N) {
// TODO(rsc): Delete with DDD cleanup.
n->right->op = OTYPE;
n->right->type = typ(TINTER);
} else {
n->right->op = OTARRAY;
n->right->right = n->right->left;
n->right->left = N;
}
n->right->op = OTARRAY;
n->right->right = n->right->left;
n->right->left = N;
n->isddd = 1;
if(n->left != N)
n->left->isddd = 1;
......@@ -1108,33 +1016,6 @@ functype(Node *this, NodeList *in, NodeList *out)
return t;
}
int
methcmp(Type *t1, Type *t2)
{
if(t1->etype != TFUNC)
return 0;
if(t2->etype != TFUNC)
return 0;
t1 = t1->type->down; // skip this arg
t2 = t2->type->down; // skip this arg
for(;;) {
if(t1 == t2)
break;
if(t1 == T || t2 == T)
return 0;
if(t1->etype != TSTRUCT || t2->etype != TSTRUCT)
return 0;
if(!eqtype(t1->type, t2->type))
return 0;
t1 = t1->down;
t2 = t2->down;
}
return 1;
}
Sym*
methodsym(Sym *nsym, Type *t0)
{
......
......@@ -5,13 +5,10 @@
#include "go.h"
#include "y.tab.h"
void dumpsym(Sym*);
void
addexportsym(Node *n)
{
exportlist = list(exportlist, n);
}
static void dumpsym(Sym*);
static void dumpexporttype(Sym*);
static void dumpexportvar(Sym*);
static void dumpexportconst(Sym*);
void
exportsym(Node *n)
......@@ -25,10 +22,10 @@ exportsym(Node *n)
}
n->sym->flags |= SymExport;
addexportsym(n);
exportlist = list(exportlist, n);
}
void
static void
packagesym(Node *n)
{
if(n == N || n->sym == S)
......@@ -40,7 +37,7 @@ packagesym(Node *n)
}
n->sym->flags |= SymPackage;
addexportsym(n);
exportlist = list(exportlist, n);
}
int
......@@ -69,7 +66,7 @@ autoexport(Node *n, int ctxt)
packagesym(n);
}
void
static void
dumppkg(Pkg *p)
{
if(p == nil || p == localpkg || p->exported)
......@@ -78,7 +75,7 @@ dumppkg(Pkg *p)
Bprint(bout, "\timport %s \"%Z\"\n", p->name, p->path);
}
void
static void
dumpprereq(Type *t)
{
if(t == T)
......@@ -97,7 +94,7 @@ dumpprereq(Type *t)
dumpprereq(t->down);
}
void
static void
dumpexportconst(Sym *s)
{
Node *n;
......@@ -142,7 +139,7 @@ dumpexportconst(Sym *s)
}
}
void
static void
dumpexportvar(Sym *s)
{
Node *n;
......@@ -166,7 +163,7 @@ dumpexportvar(Sym *s)
Bprint(bout, "\n");
}
void
static void
dumpexporttype(Sym *s)
{
Type *t;
......@@ -192,7 +189,7 @@ methcmp(const void *va, const void *vb)
return strcmp(a->sym->name, b->sym->name);
}
void
static void
dumpsym(Sym *s)
{
Type *f, *t;
......@@ -243,7 +240,7 @@ dumpsym(Sym *s)
}
}
void
static void
dumptype(Type *t)
{
// no need to re-dump type if already exported
......
......@@ -9,6 +9,9 @@
#include "go.h"
static void cgen_dcl(Node *n);
static void cgen_proc(Node *n, int proc);
Node*
sysfunc(char *name)
{
......@@ -61,7 +64,7 @@ allocparams(void)
lineno = lno;
}
void
static void
newlab(int op, Sym *s, Node *stmt)
{
Label *lab;
......@@ -400,7 +403,7 @@ cgen_proc(Node *n, int proc)
* but might have to allocate heap copy
* for escaped variables.
*/
void
static void
cgen_dcl(Node *n)
{
if(debug['g'])
......@@ -419,7 +422,7 @@ cgen_dcl(Node *n)
/*
* generate discard of value
*/
void
static void
cgen_discard(Node *nr)
{
Node tmp;
......
This diff is collapsed.
......@@ -923,7 +923,8 @@ labelname:
dotdotdot:
LDDD
{
$$ = nod(ODDD, N, N);
yyerror("final argument in variadic function missing type");
$$ = nod(ODDD, typenod(typ(TINTER)), N);
}
| LDDD ntype
{
......@@ -1709,9 +1710,17 @@ hidden_dcl:
}
| hidden_opt_sym LDDD
{
$$ = nod(ODCLFIELD, $1, typenod(typ(TINTER)));
Type *t;
yyerror("invalid variadic function type in import - recompile import");
t = typ(TARRAY);
t->bound = -1;
t->type = typ(TINTER);
$$ = nod(ODCLFIELD, $1, typenod(t));
$$->isddd = 1;
}
| hidden_opt_sym LDDD hidden_type
{
Type *t;
......
......@@ -46,7 +46,7 @@ renameinit(Node *n)
* return (11)
* }
*/
int
static int
anyinit(NodeList *n)
{
uint32 h;
......
......@@ -7,11 +7,22 @@
#include "y.tab.h"
#include <ar.h>
#undef getc
#undef ungetc
#define getc ccgetc
#define ungetc ccungetc
extern int yychar;
int windows;
void lexfini(void);
void yytinit(void);
static void lexinit(void);
static void lexfini(void);
static void yytinit(void);
static int getc(void);
static void ungetc(int);
static int32 getr(void);
static int escchar(int, int*, vlong*);
static void addidir(char*);
static char *goos, *goarch, *goroot;
......@@ -215,7 +226,7 @@ main(int argc, char *argv[])
return 0;
}
int
static int
arsize(Biobuf *b, char *name)
{
struct ar_hdr *a;
......@@ -229,7 +240,7 @@ arsize(Biobuf *b, char *name)
return atoi(a->size);
}
int
static int
skiptopkgdef(Biobuf *b)
{
char *p;
......@@ -254,7 +265,7 @@ skiptopkgdef(Biobuf *b)
return 1;
}
void
static void
addidir(char* dir)
{
Idir** pp;
......@@ -270,7 +281,7 @@ addidir(char* dir)
}
// is this path a local name? begins with ./ or ../ or /
int
static int
islocalname(Strlit *name)
{
if(!windows && name->len >= 1 && name->s[0] == '/')
......@@ -285,7 +296,7 @@ islocalname(Strlit *name)
return 0;
}
int
static int
findpkg(Strlit *name)
{
Idir *p;
......@@ -448,7 +459,7 @@ cannedimports(char *file, char *cp)
incannedimport = 1;
}
int
static int
isfrog(int c)
{
// complain about possibly invisible control characters
......@@ -1132,7 +1143,7 @@ yylex(void)
return lx;
}
int
static int
getc(void)
{
int c;
......@@ -1170,7 +1181,7 @@ getc(void)
return c;
}
void
static void
ungetc(int c)
{
curio.peekc1 = curio.peekc;
......@@ -1179,7 +1190,7 @@ ungetc(int c)
lexlineno--;
}
int32
static int32
getr(void)
{
int c, i;
......@@ -1210,8 +1221,7 @@ loop:
return rune;
}
int
static int
escchar(int e, int *escflg, vlong *val)
{
int i, u, c;
......@@ -1407,7 +1417,7 @@ static struct
"insofaras", LIGNORE, Txxx, OXXX,
};
void
static void
lexinit(void)
{
int i, lex;
......@@ -1471,7 +1481,7 @@ lexinit(void)
nblank = s->def;
}
void
static void
lexfini(void)
{
Sym *s;
......@@ -1657,7 +1667,7 @@ struct
"','", "comma",
};
void
static void
yytinit(void)
{
int i, j;
......
......@@ -618,7 +618,7 @@ mpdivmodfixfix(Mpint *q, Mpint *r, Mpint *n, Mpint *d)
q->neg = ns^ds;
}
int
static int
iszero(Mpint *a)
{
long *a1;
......
......@@ -8,6 +8,9 @@
* architecture-independent object file output
*/
static void outhist(Biobuf *b);
static void dumpglobls(void);
void
dumpobj(void)
{
......@@ -38,7 +41,7 @@ dumpobj(void)
Bterm(bout);
}
void
static void
dumpglobls(void)
{
Node *n;
......@@ -58,8 +61,7 @@ dumpglobls(void)
continue;
dowidth(n->type);
// TODO(rsc): why is this not s/n->sym->def/n/ ?
ggloblnod(n->sym->def, n->type->width);
ggloblnod(n, n->type->width);
}
}
......@@ -71,7 +73,7 @@ Bputname(Biobuf *b, Sym *s)
Bwrite(b, s->name, strlen(s->name)+1);
}
void
static void
outhist(Biobuf *b)
{
Hist *h;
......
......@@ -235,7 +235,7 @@ methods(Type *t)
/*
* return methods of interface type t, sorted by name.
*/
Sig*
static Sig*
imethods(Type *t)
{
Sig *a, *all, *last;
......
......@@ -718,7 +718,7 @@ initctxt:
return 1;
}
int
static int
getlit(Node *lit)
{
if(smallintconst(lit))
......
......@@ -8,6 +8,8 @@
#include "opnames.h"
#include "yerr.h"
static void dodump(Node*, int);
typedef struct Error Error;
struct Error
{
......@@ -509,12 +511,6 @@ maptype(Type *key, Type *val)
return t;
}
int
iskeytype(Type *t)
{
return algtype(t) != ANOEQ;
}
Type*
typ(int et)
{
......@@ -657,7 +653,7 @@ aindex(Node *b, Type *t)
return r;
}
void
static void
indent(int dep)
{
int i;
......@@ -666,14 +662,14 @@ indent(int dep)
print(". ");
}
void
static void
dodumplist(NodeList *l, int dep)
{
for(; l; l=l->next)
dodump(l->n, dep);
}
void
static void
dodump(Node *n, int dep)
{
if(n == N)
......@@ -1035,34 +1031,6 @@ Jconv(Fmt *fp)
return 0;
}
int
Gconv(Fmt *fp)
{
char buf[100];
Type *t;
t = va_arg(fp->args, Type*);
if(t->etype == TFUNC) {
if(t->vargen != 0) {
snprint(buf, sizeof(buf), "-%d%d%d g(%ld)",
t->thistuple, t->outtuple, t->intuple, t->vargen);
goto out;
}
snprint(buf, sizeof(buf), "-%d%d%d",
t->thistuple, t->outtuple, t->intuple);
goto out;
}
if(t->vargen != 0) {
snprint(buf, sizeof(buf), " g(%ld)", t->vargen);
goto out;
}
strcpy(buf, "");
out:
return fmtstrcpy(fp, buf);
}
int
Sconv(Fmt *fp)
{
......@@ -1203,13 +1171,9 @@ Tpretty(Fmt *fp, Type *t)
fmtprint(fp, "(");
for(t1=getinargx(t)->type; t1; t1=t1->down) {
if(noargnames && t1->etype == TFIELD) {
if(t1->isddd) {
// TODO(rsc): Delete with DDD cleanup.
if(t1->type->etype == TINTER)
fmtprint(fp, "...");
else
fmtprint(fp, "... %T", t1->type->type);
} else
if(t1->isddd)
fmtprint(fp, "...%T", t1->type->type);
else
fmtprint(fp, "%T", t1->type);
} else
fmtprint(fp, "%T", t1);
......@@ -1287,13 +1251,9 @@ Tpretty(Fmt *fp, Type *t)
fmtprint(fp, "? ");
} else
fmtprint(fp, "%hS ", t->sym);
if(t->isddd) {
// TODO(rsc): delete with DDD cleanup.
if(t->type->etype == TINTER)
fmtprint(fp, "...");
else
fmtprint(fp, "... %T", t->type->type);
} else
if(t->isddd)
fmtprint(fp, "...%T", t->type->type);
else
fmtprint(fp, "%T", t->type);
if(t->note) {
fmtprint(fp, " ");
......@@ -1764,20 +1724,6 @@ cplxsubtype(int et)
return 0;
}
int
iscomposite(Type *t)
{
if(t == T)
return 0;
switch(t->etype) {
case TARRAY:
case TSTRUCT:
case TMAP:
return 1;
}
return 0;
}
// Return 1 if t1 and t2 are identical, following the spec rules.
//
// Any cyclic type must go through a named type, and if one is
......@@ -2209,7 +2155,7 @@ shallow(Type *t)
return nt;
}
Type*
static Type*
deep(Type *t)
{
Type *nt, *xt;
......@@ -2283,39 +2229,6 @@ syslook(char *name, int copy)
return n;
}
/*
* are the arg names of two
* functions the same. we know
* that eqtype has been called
* and has returned true.
*/
int
eqargs(Type *t1, Type *t2)
{
if(t1 == t2)
return 1;
if(t1 == T || t2 == T)
return 0;
if(t1->etype != t2->etype)
return 0;
if(t1->etype != TFUNC)
fatal("eqargs: oops %E", t1->etype);
t1 = t1->type;
t2 = t2->type;
for(;;) {
if(t1 == t2)
break;
if(!eqtype(t1, t2))
return 0;
t1 = t1->down;
t2 = t2->down;
}
return 1;
}
/*
* compute a hash value for type t.
* if t is a method type, ignore the receiver
......@@ -2750,7 +2663,7 @@ setmaxarg(Type *t)
// search depth 0 --
// return count of fields+methods
// found with a given name
int
static int
lookdot0(Sym *s, Type *t, Type **save)
{
Type *f, *u;
......@@ -3019,7 +2932,7 @@ expandmeth(Sym *s, Type *t)
/*
* Given funarg struct list, return list of ODCLFIELD Node fn args.
*/
NodeList*
static NodeList*
structargs(Type **tl, int mustname)
{
Iter savet;
......@@ -3121,7 +3034,7 @@ genwrapper(Type *rcvr, Type *method, Sym *newnam)
funccompile(fn, 0);
}
Type*
static Type*
ifacelookdot(Sym *s, Type *t, int *followptr)
{
int i, c, d;
......
......@@ -33,14 +33,6 @@ struct Case
};
#define C ((Case*)nil)
Type*
notideal(Type *t)
{
if(t != T && t->etype == TIDEAL)
return T;
return t;
}
void
dumpcase(Case *c0)
{
......@@ -240,7 +232,7 @@ csort(Case *l, int(*f)(Case*, Case*))
return l;
}
Node*
static Node*
newlabel(void)
{
static int label;
......@@ -255,7 +247,7 @@ newlabel(void)
* make labels between cases and statements
* deal with fallthrough, break, unreachable statements
*/
void
static void
casebody(Node *sw, Node *typeswvar)
{
Node *os, *oc, *n, *c, *last;
......@@ -339,7 +331,7 @@ casebody(Node *sw, Node *typeswvar)
lineno = lno;
}
Case*
static Case*
mkcaselist(Node *sw, int arg)
{
Node *n;
......@@ -434,7 +426,7 @@ mkcaselist(Node *sw, int arg)
static Node* exprname;
Node*
static Node*
exprbsw(Case *c0, int ncase, int arg)
{
NodeList *cas;
......@@ -494,7 +486,7 @@ exprbsw(Case *c0, int ncase, int arg)
* normal (expression) switch.
* rebulid case statements into if .. goto
*/
void
static void
exprswitch(Node *sw)
{
Node *def;
......@@ -580,7 +572,7 @@ static Node* hashname;
static Node* facename;
static Node* boolname;
Node*
static Node*
typeone(Node *t)
{
NodeList *init;
......@@ -609,7 +601,7 @@ typeone(Node *t)
return a;
}
Node*
static Node*
typebsw(Case *c0, int ncase)
{
NodeList *cas;
......@@ -652,7 +644,7 @@ typebsw(Case *c0, int ncase)
* switch v := i.(type) { case t1: ..; case t2: ..; }
* into if statements
*/
void
static void
typeswitch(Node *sw)
{
Node *def;
......
......@@ -9,9 +9,6 @@
* marks variables that escape the local frame.
* rewrites n->op to be more specific in some cases.
* sets n->walk to walking function.
*
* TODO:
* trailing ... section of function calls
*/
#include "go.h"
......@@ -32,6 +29,7 @@ static void checklvalue(Node*, char*);
static void checkassign(Node*);
static void checkassignlist(NodeList*);
static void stringtoarraylit(Node**);
static Node* resolve(Node*);
/*
* resolve ONONAME to definition, if any.
......@@ -1432,8 +1430,6 @@ typecheckaste(int op, Type *tstruct, NodeList *nl, char *desc)
tn = n->type->type;
for(tl=tstruct->type; tl; tl=tl->down) {
if(tl->isddd) {
// TODO(rsc): delete if (but not body) in DDD cleanup.
if(tl->type->etype != TINTER)
for(; tn; tn=tn->down)
if(assignop(tn->type, tl->type->type, &why) == 0)
yyerror("cannot use %T as type %T in %s%s", tn->type, tl->type->type, desc, why);
......@@ -1465,8 +1461,6 @@ typecheckaste(int op, Type *tstruct, NodeList *nl, char *desc)
for(; nl; nl=nl->next) {
setlineno(nl->n);
defaultlit(&nl->n, t->type);
// TODO(rsc): drop first if in DDD cleanup
if(t->etype != TINTER)
if(assignop(nl->n->type, t->type, &why) == 0)
yyerror("cannot use %+N as type %T in %s%s", nl->n, t->type, desc, why);
}
......
......@@ -8,13 +8,22 @@ static Node* walkprint(Node*, NodeList**, int);
static Node* conv(Node*, Type*);
static Node* mapfn(char*, Type*);
static Node* makenewvar(Type*, NodeList**, Node**);
static Node* ascompatee1(int, Node*, Node*, NodeList**);
static NodeList* ascompatee(int, NodeList*, NodeList*, NodeList**);
static NodeList* ascompatet(int, NodeList*, Type**, int, NodeList**);
static NodeList* ascompatte(int, Type**, NodeList*, int, NodeList**);
static Node* convas(Node*, NodeList**);
static void heapmoves(void);
static NodeList* paramstoheap(Type **argin, int out);
static NodeList* reorder1(NodeList*);
static NodeList* reorder3(NodeList*);
static NodeList* walkdefstack;
// can this code branch reach the end
// without an undcontitional RETURN
// this is hard, so it is conservative
int
static int
walkret(NodeList *l)
{
Node *n;
......@@ -87,16 +96,6 @@ walk(Node *fn)
}
}
void
gettype(Node **np, NodeList **init)
{
if(debug['W'])
dump("\nbefore gettype", *np);
typecheck(np, Erv);
if(debug['W'])
dump("after gettype", *np);
}
static int nwalkdeftype;
static NodeList *methodqueue;
......@@ -1307,13 +1306,13 @@ makenewvar(Type *t, NodeList **init, Node **nstar)
return nvar;
}
Node*
static Node*
ascompatee1(int op, Node *l, Node *r, NodeList **init)
{
return convas(nod(OAS, l, r), init);
}
NodeList*
static NodeList*
ascompatee(int op, NodeList *nl, NodeList *nr, NodeList **init)
{
NodeList *ll, *lr, *nn;
......@@ -1346,7 +1345,7 @@ ascompatee(int op, NodeList *nl, NodeList *nr, NodeList **init)
* evaluating the lv or a function call
* in the conversion of the types
*/
int
static int
fncall(Node *l, Type *rt)
{
if(l->ullman >= UINF)
......@@ -1356,7 +1355,7 @@ fncall(Node *l, Type *rt)
return 1;
}
NodeList*
static NodeList*
ascompatet(int op, NodeList *nl, Type **nr, int fp, NodeList **init)
{
Node *l, *tmp, *a;
......@@ -1414,113 +1413,10 @@ ascompatet(int op, NodeList *nl, Type **nr, int fp, NodeList **init)
return concat(nn, mm);
}
/*
* make a tsig for the structure
* carrying the ... arguments
*/
Type*
sigtype(Type *st)
{
Sym *s;
Type *t;
static int sigdddgen;
dowidth(st);
sigdddgen++;
snprint(namebuf, sizeof(namebuf), "dsigddd_%d", sigdddgen);
s = lookup(namebuf);
t = newtype(s);
t = dodcltype(t);
updatetype(t, st);
t->local = 1;
return t;
}
/*
* package all the arguments that
* match a ... parameter into an
* automatic structure.
* then call the ... arg (interface)
* with a pointer to the structure.
*/
NodeList*
mkdotargs(NodeList *lr0, NodeList *nn, Type *l, int fp, NodeList **init)
{
Node *r;
Type *t, *st, *ft;
Node *a, *var;
NodeList *lr, *n;
n = nil; // list of assignments
st = typ(TSTRUCT); // generated structure
ft = T; // last field
for(lr=lr0; lr; lr=lr->next) {
r = lr->n;
if(r->op == OLITERAL && r->val.ctype == CTNIL) {
if(r->type == T || r->type->etype == TNIL) {
yyerror("inappropriate use of nil in ... argument");
return nil;
}
}
defaultlit(&r, T);
lr->n = r;
if(r->type == T) // type check failed
return nil;
// generate the next structure field
t = typ(TFIELD);
t->type = r->type;
if(ft == T)
st->type = t;
else
ft->down = t;
ft = t;
a = nod(OAS, N, r);
n = list(n, a);
}
// make a named type for the struct
st = sigtype(st);
dowidth(st);
// now we have the size, make the struct
var = nod(OXXX, N, N);
tempname(var, st);
var->sym = lookup(".ddd");
typecheck(&var, Erv);
// assign the fields to the struct.
// use the init list so that reorder1 doesn't reorder
// these assignments after the interface conversion
// below.
t = st->type;
for(lr=n; lr; lr=lr->next) {
r = lr->n;
r->left = nod(OXXX, N, N);
*r->left = *var;
r->left->type = r->right->type;
r->left->xoffset += t->width;
typecheck(&r, Etop);
walkexpr(&r, init);
lr->n = r;
t = t->down;
}
*init = concat(*init, n);
// last thing is to put assignment
// of the structure to the DDD parameter
a = nod(OAS, nodarg(l, fp), var);
nn = list(nn, convas(a, init));
return nn;
}
/*
* package all the arguments that match a ... T parameter into a []T.
*/
NodeList*
static NodeList*
mkdotargslice(NodeList *lr0, NodeList *nn, Type *l, int fp, NodeList **init)
{
Node *a, *n;
......@@ -1594,7 +1490,7 @@ dumpnodetypes(NodeList *l, char *what)
* return expr-list
* func(expr-list)
*/
NodeList*
static NodeList*
ascompatte(int op, Type **nl, NodeList *lr, int fp, NodeList **init)
{
Type *l, *ll;
......@@ -1656,14 +1552,10 @@ loop:
goto ret;
}
// normal case -- make a structure of all
// remaining arguments and pass a pointer to
// it to the ddd parameter (empty interface)
// TODO(rsc): delete in DDD cleanup.
if(l->type->etype == TINTER)
nn = mkdotargs(lr, nn, l, fp, init);
else
nn = mkdotargslice(lr, nn, l, fp, init);
// normal case -- make a slice of all
// remaining arguments and pass it to
// the ddd parameter.
nn = mkdotargslice(lr, nn, l, fp, init);
goto ret;
}
......@@ -1882,26 +1774,7 @@ callnew(Type *t)
return mkcall1(fn, ptrto(t), nil, nodintconst(t->width));
}
Type*
fixchan(Type *t)
{
if(t == T)
goto bad;
if(t->etype != TCHAN)
goto bad;
if(t->type == T)
goto bad;
dowidth(t->type);
return t;
bad:
yyerror("not a channel: %lT", t);
return T;
}
Node*
static Node*
convas(Node *n, NodeList **init)
{
Node *l, *r;
......@@ -2014,7 +1887,7 @@ reorder1(NodeList *all)
* be later use of an earlier lvalue.
*/
int
static int
vmatch2(Node *l, Node *r)
{
NodeList *ll;
......@@ -2113,7 +1986,7 @@ reorder3(NodeList *all)
* generate and return code to allocate
* copies of escaped parameters to the heap.
*/
NodeList*
static NodeList*
paramstoheap(Type **argin, int out)
{
Type *t;
......@@ -2146,7 +2019,7 @@ paramstoheap(Type **argin, int out)
/*
* walk through argout parameters copying back to stack
*/
NodeList*
static NodeList*
returnsfromheap(Type **argin)
{
Type *t;
......@@ -2169,7 +2042,7 @@ returnsfromheap(Type **argin)
* between the stack and the heap. adds code to
* curfn's before and after lists.
*/
void
static void
heapmoves(void)
{
NodeList *nn;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment