Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(296)

Unified Diff: src/cmd/gc/reflect.c

Issue 4442071: code review 4442071: gc: correct handling of unexported method names in embe... (Closed)
Patch Set: diff -r bc9e9e3e43e2 https://go.googlecode.com/hg/ Created 13 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cmd/gc/go.y ('k') | src/cmd/gc/subr.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cmd/gc/reflect.c
===================================================================
--- a/src/cmd/gc/reflect.c
+++ b/src/cmd/gc/reflect.c
@@ -182,6 +182,11 @@
a = b;
a->name = method->name;
+ if(!exportname(method->name)) {
+ if(method->pkg == nil)
+ fatal("methods: missing package");
+ a->pkg = method->pkg;
+ }
a->isym = methodsym(method, it, 1);
a->tsym = methodsym(method, t, 0);
a->type = methodfunc(f->type, t);
@@ -253,8 +258,11 @@
method = f->sym;
a = mal(sizeof(*a));
a->name = method->name;
- if(!exportname(method->name))
+ if(!exportname(method->name)) {
+ if(method->pkg == nil)
+ fatal("imethods: missing package");
a->pkg = method->pkg;
+ }
a->mtype = f->type;
a->offset = 0;
a->type = methodfunc(f->type, nil);
@@ -297,6 +305,33 @@
return all;
}
+static void
+dimportpath(Pkg *p)
+{
+ static Pkg *gopkg;
+ char *nam;
+ Node *n;
+
+ if(p->pathsym != S)
+ return;
+
+ if(gopkg == nil) {
+ gopkg = mkpkg(strlit("go"));
+ gopkg->name = "go";
+ }
+ nam = smprint("importpath.%s.", p->prefix);
+
+ n = nod(ONAME, N, N);
+ n->sym = pkglookup(nam, gopkg);
+ free(nam);
+ n->class = PEXTERN;
+ n->xoffset = 0;
+ p->pathsym = n->sym;
+
+ gdatastring(n, p->path);
+ ggloblsym(n->sym, types[TSTRING]->width, 1);
+}
+
static int
dgopkgpath(Sym *s, int ot, Pkg *pkg)
{
@@ -314,30 +349,8 @@
return dsymptr(s, ot, ns, 0);
}
- return dgostringptr(s, ot, pkg->name);
-}
-
-static void
-dimportpath(Pkg *p)
-{
- static Pkg *gopkg;
- char *nam;
- Node *n;
-
- if(gopkg == nil) {
- gopkg = mkpkg(strlit("go"));
- gopkg->name = "go";
- }
- nam = smprint("importpath.%s.", p->prefix);
-
- n = nod(ONAME, N, N);
- n->sym = pkglookup(nam, gopkg);
- free(nam);
- n->class = PEXTERN;
- n->xoffset = 0;
-
- gdatastring(n, p->path);
- ggloblsym(n->sym, types[TSTRING]->width, 1);
+ dimportpath(pkg);
+ return dsymptr(s, ot, pkg->pathsym, 0);
}
/*
« no previous file with comments | « src/cmd/gc/go.y ('k') | src/cmd/gc/subr.c » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b