ast

package
v0.0.0-...-7b07caf Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assignment

type Assignment struct {
	VarName string
	Expr    Expression
}

func NewAssignment

func NewAssignment(varName string, expr Expression) *Assignment

func (*Assignment) GenIR

func (a *Assignment) GenIR(cc *CompilerContext) value.Value

func (*Assignment) String

func (a *Assignment) String() string

type BinOp

type BinOp struct {
	Left  Expression
	Op    string
	Right Expression
}

func NewBinOp

func NewBinOp(left Expression, op string, right Expression) *BinOp

func (*BinOp) GenIR

func (bo *BinOp) GenIR(cc *CompilerContext) value.Value

func (*BinOp) String

func (bo *BinOp) String() string

type Block

type Block struct {
	Name         string
	Instructions []Instruction
	Terminator   Instruction
}

func NewBlock

func NewBlock(name string) *Block

func (*Block) AddInstruction

func (b *Block) AddInstruction(i Instruction)

func (*Block) GenIR

func (b *Block) GenIR(cc *CompilerContext) value.Value

func (*Block) String

func (b *Block) String() string

type Branch

type Branch struct {
	Blk *Block
}

func NewBranch

func NewBranch(blk *Block) *Branch

func (*Branch) GenIR

func (b *Branch) GenIR(cc *CompilerContext) value.Value

func (*Branch) String

func (b *Branch) String() string

type CompilerContext

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

func NewCompilerContext

func NewCompilerContext(mod *ir.Module) *CompilerContext

func (*CompilerContext) GetIRModule

func (cc *CompilerContext) GetIRModule() *ir.Module

type ConditionalBranch

type ConditionalBranch struct {
	Condition   *BinOp
	TrueTarget  *Block
	FalseTarget *Block
}

func NewConditionalBranch

func NewConditionalBranch(condition *BinOp, trueTarget *Block, falseTarget *Block) *ConditionalBranch

func (*ConditionalBranch) GenIR

func (*ConditionalBranch) String

func (b *ConditionalBranch) String() string

type Constant

type Constant struct {
	Value string
	T     ConstantType
}

func NewConstant

func NewConstant(v string, t ConstantType) *Constant

func (*Constant) String

func (c *Constant) String() string

type ConstantType

type ConstantType int
const (
	StringType ConstantType = iota
	NumericType
)

type Expression

type Expression interface {
	GenIR(cc *CompilerContext) value.Value

	String() string
	// contains filtered or unexported methods
}

type Function

type Function struct {
	Proto  *FunctionProto
	Locals []*FunctionLocal
	Blocks []*Block
	// contains filtered or unexported fields
}

func NewFunction

func NewFunction(fn string, isProcedure bool) *Function

func (*Function) AddBlock

func (f *Function) AddBlock(b *Block)

func (*Function) AddLocal

func (f *Function) AddLocal(name string, typ string, value string)

func (*Function) AddParam

func (f *Function) AddParam(name string, ownership string, t string)

func (*Function) GenIR

func (f *Function) GenIR(cc *CompilerContext) value.Value

func (*Function) GenIRForProtos

func (f *Function) GenIRForProtos(cc *CompilerContext) value.Value

func (*Function) String

func (f *Function) String() string

type FunctionCall

type FunctionCall struct {
	ModuleName   string
	FunctionName string
	Args         []Expression
}

func NewFunctionCall

func NewFunctionCall(moduleName string, functionName string) *FunctionCall

func (*FunctionCall) AddArg

func (fc *FunctionCall) AddArg(expr Expression)

func (*FunctionCall) GenIR

func (fc *FunctionCall) GenIR(cc *CompilerContext) value.Value

func (*FunctionCall) String

func (fc *FunctionCall) String() string

type FunctionLocal

type FunctionLocal struct {
	Name  string
	Typ   string
	Value string
}

func (*FunctionLocal) GenIR

func (fl *FunctionLocal) GenIR(cc *CompilerContext) value.Value

func (*FunctionLocal) String

func (fl *FunctionLocal) String() string

type FunctionParam

type FunctionParam struct {
	Name      string
	Ownership string // IN, OUT, INOUT
	Type      string
}

func (*FunctionParam) GenIR

func (fp *FunctionParam) GenIR(cc *CompilerContext) *ir.Param

func (*FunctionParam) String

func (fp *FunctionParam) String() string

type FunctionProto

type FunctionProto struct {
	Name   string
	Params []*FunctionParam
}

func NewFunctionProto

func NewFunctionProto(name string) *FunctionProto

func (*FunctionProto) AddParam

func (fp *FunctionProto) AddParam(name string, ownership string, t string)

func (*FunctionProto) GenIR

func (fp *FunctionProto) GenIR(cc *CompilerContext) *ir.Func

func (*FunctionProto) String

func (fp *FunctionProto) String() string

type Instruction

type Instruction interface {
	GenIR(cc *CompilerContext) value.Value
	String() string
}

type Node

type Node interface {
	String() string
}

type NumericLiteral

type NumericLiteral struct {
	Value int64
}

func NewNumericLiteral

func NewNumericLiteral(value string) *NumericLiteral

func (*NumericLiteral) GenIR

func (nl *NumericLiteral) GenIR(cc *CompilerContext) value.Value

func (*NumericLiteral) String

func (nl *NumericLiteral) String() string

type Package

type Package struct {
	Name string
	// contains filtered or unexported fields
}

func NewPackage

func NewPackage(name string) *Package

func (*Package) AddFunction

func (p *Package) AddFunction(f *Function)

func (*Package) GenIR

func (p *Package) GenIR(cc *CompilerContext) error

func (*Package) HasMainFunction

func (p *Package) HasMainFunction() bool

func (*Package) String

func (p *Package) String() string

type Retrn

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

func NewRetrn

func NewRetrn() *Retrn

type StringLiteral

type StringLiteral struct {
	Value string
}

func NewStringLiteral

func NewStringLiteral(value string) *StringLiteral

func (*StringLiteral) GenIR

func (sl *StringLiteral) GenIR(cc *CompilerContext) value.Value

func (*StringLiteral) String

func (sl *StringLiteral) String() string

type Variable

type Variable struct {
	Name string
}

func NewVariable

func NewVariable(name string) *Variable

func (*Variable) GenIR

func (v *Variable) GenIR(cc *CompilerContext) value.Value

func (*Variable) String

func (v *Variable) String() string

Jump to

Keyboard shortcuts

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