Exemplo n.º 1
0
func writeBlock(f *link8.Func, b *Block) {
	for _, inst := range b.insts {
		f.AddInst(inst.inst)
		if inst.sym != nil {
			s := inst.sym
			f.AddLink(s.fill, &link8.PkgSym{s.pkg, s.sym})
		}
	}
}
Exemplo n.º 2
0
func linkSymbol(b *builder, s *funcStmt, f *link8.Func) {
	t := s.symTok
	if b.curPkg == nil {
		b.Errorf(t.Pos, "no context for resolving %q", t.Lit)
		return // this may happen for bare function
	}

	typ, pkg, name := resolveSymbol(b, s)
	if typ == SymNone {
		return
	}

	if s.fill == fillLink && typ != SymFunc {
		b.Errorf(t.Pos, "%s %q is not a function", SymStr(typ), t.Lit)
		return
	} else if pkg != b.curPkg.Path() && !sym8.IsPublic(s.sym) {
		// for imported package, check if it is public
		b.Errorf(t.Pos, "%q is not public", t.Lit)
		return
	}

	// save the link
	f.AddLink(s.fill, &link8.PkgSym{pkg, name})
}