Beispiel #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, s.pkg, s.sym)
		}
	}
}
Beispiel #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, index := 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 > 0 && !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, pkg, index)
}