compiler

package
v0.0.0-...-2cdba53 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IdealIntType   vm.Type = &types.IdealIntType{}
	IdealFloatType vm.Type = &types.IdealFloatType{}
	IdealBoolType  vm.Type = &types.BoolType{}
)

TODO: move to builtins

Functions

This section is empty.

Types

type BlockCompiler

type BlockCompiler struct {
	*FuncCompiler                // The FuncCompiler for the function enclosing this block.
	Parent        *BlockCompiler // The BlockCompiler for the block enclosing this one, or nil for a function-level block.
	Block         *context.Block // The block definition
	Label         *Label         // The label of this block, used for finding break and continue labels.
}

BlockCompiler captures information used throughout the compilation of a single block within a function.

func (*BlockCompiler) CompileStmt

func (bc *BlockCompiler) CompileStmt(stmt ast.Stmt)

CompileStmt compiles the specified statement within the block.

type CodeBuf

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

func NewCodeBuf

func NewCodeBuf() *CodeBuf

func (*CodeBuf) Get

func (b *CodeBuf) Get() vm.Code

func (*CodeBuf) NextPC

func (b *CodeBuf) NextPC() uint

func (*CodeBuf) Push

func (b *CodeBuf) Push(instr func(*vm.Thread))

type Compiler

type Compiler struct {
	FSet         *token.FileSet
	Errors       *scanner.ErrorList
	NumErrors    int
	SilentErrors int
}

Compiler captures information used throughout a package compilation.

func (*Compiler) CompileExpr

func (cc *Compiler) CompileExpr(b *context.Block, constant bool, expr ast.Expr) *Expr

func (*Compiler) NumError

func (cc *Compiler) NumError() int

NumError returns the total number of errors detected yet

type EvalMap

type EvalMap map[interface{}]vm.Value

func (EvalMap) Elem

func (m EvalMap) Elem(t *vm.Thread, key interface{}) vm.Value

func (EvalMap) Iter

func (m EvalMap) Iter(cb func(key interface{}, val vm.Value) bool)

func (EvalMap) Len

func (m EvalMap) Len(t *vm.Thread) int64

func (EvalMap) SetElem

func (m EvalMap) SetElem(t *vm.Thread, key interface{}, val vm.Value)

type Expr

type Expr struct {
	*ExprInfo

	// The type of the expression
	ExprType vm.Type

	// Execute this expression as a statement.
	// Only expressions that are valid expression statements should set this.
	Exec vm.CodeInstruction
	// contains filtered or unexported fields
}

Expr is the result of compiling an expression. It stores the type of the expression and its evaluator function.

type ExprCompiler

type ExprCompiler struct {
	*Compiler
	// contains filtered or unexported fields
}

ExprCompiler stores information used throughout the compilation of a single expression. It does not embed funcCompiler because expressions can appear at top level.

type ExprInfo

type ExprInfo struct {
	*Compiler
	// contains filtered or unexported fields
}

ExprInfo stores information needed to compile any expression node. Each expr also stores its exprInfo so further expressions can be compiled from it.

type FlowBlock

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

type FlowBuf

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

func NewFlowBuf

func NewFlowBuf(cb *CodeBuf) *FlowBuf

NewFlowBuf creates a new FlowBuf using the specified CodeBuf

type FlowEnt

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

type FuncCompiler

type FuncCompiler struct {
	*Compiler                      // The Compiler for the package enclosing this function.
	*CodeBuf                       //
	FnType       *types.FuncType   //
	OutVarsNamed bool              // Whether the out variables are named. This affects what kinds of return statements are legal.
	Flow         *FlowBuf          //
	Labels       map[string]*Label //
}

FuncCompiler captures information used throughout the compilation of a single function body.

func (*FuncCompiler) CheckLabels

func (fc *FuncCompiler) CheckLabels()

CheckLabels checks that labels were resolved and that all jumps obey scoping rules. Reports an error and set fc.err if any check fails.

type Label

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

Jump to

Keyboard shortcuts

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