Пример #1
0
// NewStruct constructs a new struct type.
func NewStruct(name string) *Struct {
	ret := new(Struct)
	ret.name = name
	ret.Syms = sym8.NewTable()

	return ret
}
Пример #2
0
func buildSymTable(p *lib) *sym8.Table {
	t := sym8.NewTable()
	for _, sym := range p.symbols {
		if sym.Type == SymFunc || sym.Type == SymVar {
			t.Declare(sym)
		}
	}
	return t
}
Пример #3
0
func buildPkg(
	b *builder, files map[string]*ast.File, pinfo *build8.PkgInfo,
) (
	syms *sym8.Table, deps *dagvis.Graph,
	testNames []string, errs []*lex8.Error,
) {
	imports := make(map[string]*build8.Package)
	for as, imp := range pinfo.Import {
		imports[as] = imp.Package
	}

	sp := &sempass.Pkg{
		Path:    b.path,
		Files:   files,
		Imports: imports,
	}

	tops := sym8.NewTable()
	b.scope.PushTable(tops)
	defer b.scope.Pop()

	res, depGraph, errs := sp.Build(b.scope)
	if errs != nil {
		return nil, nil, nil, errs
	}

	fillConsts(res.Consts)
	fillVars(b, res.Vars)
	fillFuncAlias(res.FuncAliases)
	fillFuncs(b, res.Funcs)
	fillMethods(b, res.Methods)
	buildFuncs(b, res.Funcs)
	buildFuncs(b, res.Methods)
	addInit(b)
	addStart(b)
	testList, testNames := buildTests(b, tops)
	if testList != nil {
		addTestStart(b, testList, len(testNames))
	}

	return tops, depGraph, testNames, nil
}