Documentation ¶
Index ¶
- Variables
- type Block
- func (b *Block) DefineConst(name string, pos token.Pos, t vm.Type, v vm.Value) (*Constant, Def)
- func (b *Block) DefinePackage(id, path string, pos token.Pos) (*PkgIdent, Def)
- func (b *Block) DefineTemp(t vm.Type) *Variable
- func (b *Block) DefineType(name string, pos token.Pos, t vm.Type) vm.Type
- func (b *Block) DefineVar(name string, pos token.Pos, t vm.Type) (*Variable, Def)
- func (b *Block) EnterChild() *Block
- func (b *Block) EnterChildScope() *Scope
- func (b *Block) Exit()
- func (b *Block) Lookup(name string) (bl *Block, level int, def Def)
- func (b *Block) Undefine(name string)
- type Constant
- type Def
- type PkgIdent
- type Scope
- type UniverseScope
- type Variable
Constants ¶
This section is empty.
Variables ¶
var Universe = NewUniverse()
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { Outer *Block // The block enclosing this one Inner *Block // The nested block currently being compiled, or nil. Scope *Scope // The Scope containing this block. Defs map[string]Def // The Variables, Constants, and Types defined in this block. Global bool // If Global, do not allocate new vars and consts in the frame; NumVars int // The number of variables defined in this block. // contains filtered or unexported fields }
Block represents a definition context in which a name may not be defined more than once.
The variables offset must be greater than the index of any variable defined in any parent of this block within the same Scope at the time this block is entered.
Global blocks assume that the refs will be compiled in using defs[name].Init.
func (*Block) DefineConst ¶
DefineConst creates a new constant definition.
func (*Block) DefinePackage ¶
DefinePackage defines a package import in the block.
func (*Block) DefineTemp ¶
DefineTemp allocates a anonymous slot in the current scope.
func (*Block) DefineType ¶
DefineType creates a user defined type.
func (*Block) DefineVar ¶
DefineVar creates a new variable definition and allocate it in the current scope, or returns the existing definition if the symbol was already defined.
func (*Block) EnterChild ¶
EnterChild creates a new block with this one as parent, using the same scope.
func (*Block) EnterChildScope ¶
EnterChildScope creates a new block with this one as parent, using a new scope.
type Constant ¶
type Def ¶
type Def interface { // Pos returns the position of the definition in the source code Pos() token.Pos }
Def is a definition of a *Variable, *Constant, or Type.
type PkgIdent ¶
type Scope ¶
type Scope struct { // The root block of this scope. *Block // The maximum number of variables required at any point in this Scope. // This determines the number of slots needed in the Frame created from this Scope at run-time. MaxVars int }
Scope is the compile-time analogue of a Frame, which captures some subtree of blocks.
type UniverseScope ¶
type UniverseScope struct { *Scope Pkgs map[string]*Scope // a lookup-table for easy retrieval of packages by their "path" }
UniverseScope contains the global scope for the whole vm.
type Variable ¶
type Variable struct { VarPos token.Pos // Index of this variable in the Frame Index int // Static type of this variable Type vm.Type // Value of this variable. // This is only used by Scope.NewFrame; therefore, it is useful for Global scopes // but cannot be used in function scopes. Init vm.Value }