MCPcopy Index your code
hub / github.com/go-python/gopy / newVar

Function newVar

bind/types.go:561–587  ·  view source on GitHub ↗
(p *Package, typ types.Type, objname, name, doc string)

Source from the content-addressed store, hash-verified

559}
560
561func newVar(p *Package, typ types.Type, objname, name, doc string) (*Var, error) {
562 sym := p.syms.symtype(typ)
563 if sym == nil {
564 typname, _, _ := p.syms.typeNamePkg(typ)
565 typobj := p.syms.pkg.Scope().Lookup(typname)
566 if typobj != nil {
567 p.syms.addSymbol(typobj)
568 } else {
569 if ntyp, ok := typ.(*types.Named); ok {
570 p.syms.addType(ntyp.Obj(), typ)
571 } else {
572 p.syms.addType(nil, typ)
573 }
574 }
575 sym = p.syms.symtype(typ)
576 if sym == nil {
577 return nil, fmt.Errorf("could not find symbol for type: %s!", typ.String())
578 }
579 }
580 return &Var{
581 pkg: p,
582 sym: sym,
583 id: p.Name() + "_" + objname,
584 doc: doc,
585 name: name,
586 }, nil
587}
588
589func newVarsFrom(p *Package, tuple *types.Tuple) ([]*Var, error) {
590 vars := make([]*Var, 0, tuple.Len())

Callers 1

newVarFromFunction · 0.85

Calls 8

symtypeMethod · 0.80
typeNamePkgMethod · 0.80
LookupMethod · 0.80
addSymbolMethod · 0.80
addTypeMethod · 0.80
ObjMethod · 0.45
StringMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected