}
}
-// import
-
-// return the sym for ss, which should match lexical
-func importsym(s *Sym, op Op) *Sym {
+// importsym declares symbol s as an imported object representable by op.
+func importsym(s *Sym, op Op) {
if s.Def != nil && s.Def.Op != op {
pkgstr := fmt.Sprintf("during import %q", importpkg.Path)
redeclare(s, pkgstr)
s.Flags |= SymPackage // package scope
}
}
-
- return s
}
-// return the type pkg.name, forward declaring if needed
+// pkgtype returns the named type declared by symbol s.
+// If no such type has been declared yet, a forward declaration is returned.
func pkgtype(s *Sym) *Type {
importsym(s, OTYPE)
if s.Def == nil || s.Def.Op != OTYPE {
}
}
+// importconst declares symbol s as an imported constant with type t and value n.
func importconst(s *Sym, t *Type, n *Node) {
importsym(s, OLITERAL)
n = convlit(n, t)
}
}
+// importvar declares symbol s as an imported variable with type t.
func importvar(s *Sym, t *Type) {
importsym(s, ONAME)
if s.Def != nil && s.Def.Op == ONAME {
defer p.trace("hidden_pkgtype")()
}
- s1 := p.hidden_pkg_importsym()
-
- ss := pkgtype(s1)
- importsym(s1, OTYPE)
-
- return ss
+ return pkgtype(p.hidden_pkg_importsym())
}
// ----------------------------------------------------------------------------