1
0
mirror of https://github.com/golang/go synced 2024-09-25 01:20:13 -06:00

gc: move typedcl2 into export.c

R=rsc
CC=golang-dev
https://golang.org/cl/5447043
This commit is contained in:
Luuk van Dijk 2011-11-29 13:34:08 +01:00
parent 4aab04178d
commit 882368939c
3 changed files with 25 additions and 38 deletions

View File

@ -673,41 +673,6 @@ typedcl1(Node *n, Node *t, int local)
return nod(ODCLTYPE, n, N);
}
/*
* typedcl1 but during imports
*/
void
typedcl2(Type *pt, Type *t)
{
Node *n;
// override declaration in unsafe.go for Pointer.
// there is no way in Go code to define unsafe.Pointer
// so we have to supply it.
if(incannedimport &&
strcmp(importpkg->name, "unsafe") == 0 &&
strcmp(pt->nod->sym->name, "Pointer") == 0) {
t = types[TUNSAFEPTR];
}
if(pt->etype == TFORW)
goto ok;
if(!eqtype(pt->orig, t))
yyerror("inconsistent definition for type %S during import\n\t%lT\n\t%lT", pt->sym, pt->orig, t);
return;
ok:
n = pt->nod;
copytype(pt->nod, t);
// unzero nod
pt->nod = n;
pt->sym->lastlineno = parserline();
declare(n, PEXTERN);
checkwidth(pt);
}
/*
* structs, functions, and methods.
* they don't belong here, but where do they belong?

View File

@ -349,8 +349,31 @@ importvar(Sym *s, Type *t, int ctxt)
void
importtype(Type *pt, Type *t)
{
if(pt != T && t != T)
typedcl2(pt, t);
Node *n;
if(pt != T && t != T) {
// override declaration in unsafe.go for Pointer.
// there is no way in Go code to define unsafe.Pointer
// so we have to supply it.
if(incannedimport &&
strcmp(importpkg->name, "unsafe") == 0 &&
strcmp(pt->nod->sym->name, "Pointer") == 0) {
t = types[TUNSAFEPTR];
}
if(pt->etype == TFORW) {
n = pt->nod;
copytype(pt->nod, t);
// unzero nod
pt->nod = n;
pt->sym->lastlineno = parserline();
declare(n, PEXTERN);
checkwidth(pt);
} else if(!eqtype(pt->orig, t))
yyerror("inconsistent definition for type %S during import\n\t%lT\n\t%lT", pt->sym, pt->orig, t);
}
if(debug['E'])
print("import type %T %lT\n", pt, t);

View File

@ -964,7 +964,6 @@ Type* tointerface(NodeList *l);
Type* tostruct(NodeList *l);
Node* typedcl0(Sym *s);
Node* typedcl1(Node *n, Node *t, int local);
void typedcl2(Type *pt, Type *t);
Node* typenod(Type *t);
NodeList* variter(NodeList *vl, Node *t, NodeList *el);