symbolmgr

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2018 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeArg = iota
	TypeImport
	TypeVar
	TypeFor
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DummySymbolMgrBuilder

type DummySymbolMgrBuilder struct {
	// contains filtered or unexported fields
}

func NewSymbolMgrBuilder

func NewSymbolMgrBuilder() *DummySymbolMgrBuilder

func (*DummySymbolMgrBuilder) AddArg

func (b *DummySymbolMgrBuilder) AddArg(name string, isPb bool)

func (*DummySymbolMgrBuilder) AddImport

func (b *DummySymbolMgrBuilder) AddImport(name string, isPb bool, path, pbPkg string)

func (*DummySymbolMgrBuilder) Build

func (b *DummySymbolMgrBuilder) Build() *SymbolMgr

type Symbol

type Symbol struct {
	Name    string
	Type    int
	IsPb    bool
	PkgImpt *pkgmgr.PkgImport
}

Symbol represents a symbol defined and used in a tag scope.

func (*Symbol) String

func (s *Symbol) String() string

type SymbolMgr

type SymbolMgr struct {
	// contains filtered or unexported fields
}

SymbolMgr manages all symbols of a template.

func New

func New() *SymbolMgr

func (*SymbolMgr) AllSymbols

func (sm *SymbolMgr) AllSymbols() map[string]*Symbol

func (*SymbolMgr) ExpandType

func (sm *SymbolMgr) ExpandType(varType string) string

ExpandType expands the given PB type with full qualified name, or the input unchanged if it's not a PB type.

func (*SymbolMgr) GetSymbol

func (sm *SymbolMgr) GetSymbol(name string) (*Symbol, error)

GetSymbol returns a symbol for the given name. It searches the name in each map of stack from top to bottom, so that if a name was defined twice, the higher one in stack shadows the lower one.

func (*SymbolMgr) Peek

func (sm *SymbolMgr) Peek() map[string]*Symbol

Peek returns the top symbol map in the stack and the map is updatable.

func (*SymbolMgr) Pop

func (sm *SymbolMgr) Pop()

Pop pops and drop the top symbol map in the stack.

func (*SymbolMgr) Push

func (sm *SymbolMgr) Push(symbols map[string]*Symbol)

Push pushes a symbol map into its inner stack.

func (*SymbolMgr) Size

func (sm *SymbolMgr) Size() int

Size returns the size of the symbol stack.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL