ref: ec7cfc6f9f4927a0dfd85af0145adcf20b66c2b1
parent: c1288ac0fa910456e6e008fd48e995a71045726d
author: Ori Bernstein <[email protected]>
date: Thu Dec 18 18:31:31 EST 2014
Delete dead code. This goes away now that we don't need to merge stabs.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -847,187 +847,6 @@
readuse(n->file.uses[i], n->file.globls, Visintern);
}
-#if 0
-static void fiximpls(Inferstate *st, Stab *s)
-{
- Node *n;
- void **k;
- size_t nk, i;
-
- k = htkeys(s->impl, &nk);
- for (i = 0; i < nk; i++) {
- n = getimpl(s, k[i]);
- htdel(s->impl, k[i]);
- n->impl.type = tf(st, n->impl.type);
- putimpl(s, n);
- }
- free(k);
-}
-
-static void mergeattrs(Node *a, Node *b)
-{
- if (!a || !b)
- return;
-
- a->decl.isglobl = a->decl.isglobl || b->decl.isglobl;
- a->decl.isconst = a->decl.isconst || b->decl.isconst;
- a->decl.isextern = a->decl.isextern || b->decl.isextern;
- a->decl.ispkglocal = a->decl.ispkglocal || b->decl.ispkglocal;
- a->decl.ishidden = a->decl.ishidden || b->decl.ishidden;
- a->decl.isimport = a->decl.isimport || b->decl.isimport;
- a->decl.isnoret = a->decl.isnoret || b->decl.isnoret;
- a->decl.isexportinit = a->decl.isexportinit || b->decl.isexportinit;
-}
-#endif
-
-/* The exports in package declarations
- * need to be merged with the declarations
- * at the global scope. Declarations in
- * one may set the type of the other,
- * so this should be done early in the
- * process */
-#if 0
-static void mergeexports(Inferstate *st, Node *file)
-{
- Stab *exports, *globls;
- size_t i, nk;
- void **k;
- /* export, global version */
- Node *nx, *ng;
- Type *tx, *tg;
- Trait *trx, *trg;
- Ucon *ux, *ug;
-
- globls = file->file.globls;
-
- /* export the types */
- pushstab(globls);
- k = htkeys(exports->ty, &nk);
- for (i = 0; i < nk; i++) {
- tx = gettype(exports, k[i]);
- tg = gettype(globls, k[i]);
- nx = k[i];
- if (tx) {
- if (!tg)
- puttype(globls, nx, tx);
- else
- fatal(nx, "Exported type %s already declared on line %d", namestr(nx), tg->loc);
- } else {
- if (tg)
- updatetype(exports, nx, tf(st, tg));
- else
- fatal(nx, "Exported type %s not declared", namestr(nx));
- }
- pushstab(exports);
- tyresolve(st, tx);
- popstab();
-
- if (tg)
- tyresolve(st, tg);
- }
- free(k);
-
- /* export the traits */
- k = htkeys(exports->tr, &nk);
- for (i = 0; i < nk; i++) {
- trx = gettrait(exports, k[i]);
- nx = k[i];
- if (!trx->isproto) {
- trg = gettrait(globls, nx);
- if (!trg)
- puttrait(globls, nx, trx);
- else
- fatal(nx, "Exported trait %s already declared on line %d", namestr(nx), trg->name->loc);
- } else {
- trg = gettrait(globls, nx);
- if (trg && !trg->isproto) {
- *trx = *trg;
- } else {
- fatal(nx, "Exported trait %s not declared", namestr(nx));
- }
- }
- trx->vis = Visexport;
- }
- free(k);
-
- /*
- * if we neglect to fix the types for impls before
- * lookups, getimpl() on the global with the key from
- * the export table will fail.
- */
- fiximpls(st, exports);
- fiximpls(st, globls);
-
- /* export the impls */
- k = htkeys(exports->impl, &nk);
- for (i = 0; i < nk; i++) {
- nx = getimpl(exports, k[i]);
- ng = getimpl(globls, k[i]);
-
- if (nx->impl.isproto) {
- if (!ng)
- fatal(nx, "Missing trait impl body for %s %s\n", namestr(nx->impl.traitname), tystr(nx->impl.type));
- htdel(exports->impl, k[i]);
- putimpl(exports, ng);
- ng->impl.vis = Visexport;
- } else {
- if (!ng) {
- putimpl(globls, nx);
- } else {
- fatal(nx, "Double trait impl body for %s %s on line %d\n",
- namestr(nx->impl.traitname), tystr(nx->impl.type), ng->loc);
- }
- }
- lappend(&exportimpls, &nexportimpls, ng);
- }
- free(k);
-
- /* export the declarations */
- k = htkeys(exports->dcl, &nk);
- for (i = 0; i < nk; i++) {
- nx = getdcl(exports, k[i]);
- ng = getdcl(globls, k[i]);
- /* if an export has an initializer, it shouldn't be declared in the
- * body */
- if (ng) {
- if (nx->decl.init)
- fatal(nx, "Export %s double-defined on line %d", ctxstr(st, nx), ng->loc);
- if (nx->decl.isgeneric != ng->decl.isgeneric)
- fatal(nx, "Export %s defined with different genericness on line %d", ctxstr(st, nx), ng->loc);
- mergeattrs(ng, nx);
- mergeattrs(nx, ng);
- unify(st, nx, type(st, ng), type(st, nx));
- } else {
- if (!nx->decl.isextern && !nx->decl.isimport && !nx->decl.trait)
- if (!nx->decl.init && (nx->decl.isconst || nx->decl.isgeneric))
- fatal(nx, "Export %s defined but not implemented", ctxstr(st, nx));
- putdcl(globls, nx);
- }
- }
- free(k);
-
-
-
- /* export the union constructors */
- k = htkeys(exports->uc, &nk);
- for (i = 0; i < nk; i++) {
- ux = getucon(exports, k[i]);
- ug = getucon(globls, k[i]);
- /* if an export has an initializer, it shouldn't be declared in the
- * body */
- if (ux && ug)
- lfatal(ux->loc, "Union constructor double defined on %d", ux->loc);
- else if (!ug)
- putucon(globls, ux);
- else
- putucon(exports, ug);
- }
- free(k);
-
- popstab();
-}
-#endif
-
static Type *initvar(Inferstate *st, Node *n, Node *s)
{
Type *t;