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