mirror of
https://github.com/golang/go
synced 2024-11-24 21:00:09 -07:00
gc: move typedcl2 into export.c
R=rsc CC=golang-dev https://golang.org/cl/5447043
This commit is contained in:
parent
4aab04178d
commit
882368939c
@ -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?
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user