tacil

package
v0.0.0-...-a1c1f5a Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 6 Imported by: 0

README

Three Address Code Intermediate Language (TACIL)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VoidType *Void

	Int1Type  *Int1
	Int16Type *Int16
	Int8Type  *Int8
	Int32Type *Int32
	Int64Type *Int64
)
View Source
var PredeclaredRegisters = map[string]bool{
	"$sp": true,
	"$gp": true,
	"$fp": true,
}

Functions

func NextTemp

func NextTemp() string

Types

type Argument

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

Argument ... ---------------------

func CreateArgument

func CreateArgument(ty *FunctionType, parent *Function, name string) *Argument

func (Argument) HasName

func (a Argument) HasName() bool

func (Argument) Name

func (a Argument) Name() string

func (Argument) Parent

func (a Argument) Parent() *Function

func (Argument) SetName

func (a Argument) SetName(name string)

func (Argument) String

func (a Argument) String() string

func (Argument) Type

func (a Argument) Type() Type

type ArrayType

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

ArrayType -----------------------------------------

func CreateArrayType

func CreateArrayType(numEl Expr, elTy Type) *ArrayType

func (ArrayType) IsArrayTy

func (a ArrayType) IsArrayTy() bool

func (ArrayType) IsFuncTy

func (a ArrayType) IsFuncTy() bool

func (ArrayType) IsIntegerTy

func (a ArrayType) IsIntegerTy() bool

func (ArrayType) IsPtrTy

func (a ArrayType) IsPtrTy() bool

func (ArrayType) IsVoidTy

func (a ArrayType) IsVoidTy() bool

func (ArrayType) String

func (a ArrayType) String() string

type Assign

type Assign struct {
	Dst   Expr
	Value Expr
	// contains filtered or unexported fields
}

Assign --------------------------------

func CreateAssign

func CreateAssign(val, dst Expr) *Assign

func (*Assign) Parent

func (a *Assign) Parent() *BasicBlock

func (*Assign) SetParent

func (a *Assign) SetParent(parent *BasicBlock)

func (*Assign) String

func (a *Assign) String() string

type BasicBlock

type BasicBlock struct {
	Phi map[string]*Assign
	// contains filtered or unexported fields
}

BasicBlock ... -------------------------

func CreateBasicBlock

func CreateBasicBlock(name string, parent *Function) *BasicBlock

func NewBasicBlock

func NewBasicBlock(name string) *BasicBlock

func (*BasicBlock) AddInstr

func (b *BasicBlock) AddInstr(i Stmt)

func (*BasicBlock) Empty

func (b *BasicBlock) Empty() bool

func (*BasicBlock) HasName

func (b *BasicBlock) HasName() bool

func (*BasicBlock) InsertInstrBegin

func (b *BasicBlock) InsertInstrBegin(inst Stmt)

func (*BasicBlock) Instr

func (b *BasicBlock) Instr() *list.List

func (*BasicBlock) LastInst

func (b *BasicBlock) LastInst() Stmt

func (*BasicBlock) LastInstIsCondBr

func (b *BasicBlock) LastInstIsCondBr() bool

func (*BasicBlock) Name

func (b *BasicBlock) Name() string

func (*BasicBlock) Parent

func (b *BasicBlock) Parent() *Function

func (*BasicBlock) RemoveInstr

func (b *BasicBlock) RemoveInstr(rem *list.Element)

func (*BasicBlock) SetName

func (b *BasicBlock) SetName(name string)

func (*BasicBlock) String

func (b *BasicBlock) String() string

func (*BasicBlock) Type

func (b *BasicBlock) Type() Type

type BinaryOp

type BinaryOp struct {
	Op   Opcode
	X, Y Expr
	// contains filtered or unexported fields
}

BinaryOp ----------------------------------------

func NewBinaryOp

func NewBinaryOp(ty Type, op Opcode, x, y Expr) *BinaryOp

func (*BinaryOp) BaseName

func (b *BinaryOp) BaseName() string

func (*BinaryOp) HasName

func (b *BinaryOp) HasName() bool

func (*BinaryOp) Name

func (b *BinaryOp) Name() string

func (*BinaryOp) NumOperands

func (b *BinaryOp) NumOperands() int

func (*BinaryOp) Operand

func (b *BinaryOp) Operand(i int) Expr

func (*BinaryOp) SetName

func (b *BinaryOp) SetName(string)

func (*BinaryOp) String

func (b *BinaryOp) String() string

func (*BinaryOp) Type

func (b *BinaryOp) Type() Type

type BitVector

type BitVector byte

BitVector -----------------------------

type Builder

type Builder struct {
	BB  *BasicBlock       // the current BasicBlock where instructions are inserted
	CFG *ControlFlowGraph // A graph modelling control-flow for the current function
}

func NewBuilder

func NewBuilder() *Builder

func (*Builder) CreateAdd

func (b *Builder) CreateAdd(lhs, rhs Expr) *BinaryOp

func (*Builder) CreateAssign

func (b *Builder) CreateAssign(Val, Dst Expr) *Assign

func (*Builder) CreateCmp

func (b *Builder) CreateCmp(pred Opcode, lhs, rhs Expr) Expr

func (*Builder) CreateCondBr

func (b *Builder) CreateCondBr(cond Expr, ifTrue, ifFalse *BasicBlock) *CondBr

func (*Builder) CreateFuncCall

func (b *Builder) CreateFuncCall(callee Expr, args []Expr) *FuncCall

func (*Builder) CreateJmp

func (b *Builder) CreateJmp(dst *BasicBlock) *Jump

func (*Builder) CreateLoad

func (b *Builder) CreateLoad(addr Expr) *Load

func (*Builder) CreateNeg

func (b *Builder) CreateNeg(v Expr) Expr

func (*Builder) CreateNot

func (b *Builder) CreateNot(v Expr) Expr

func (*Builder) CreateProcCall

func (b *Builder) CreateProcCall(callee Expr, args []Expr) *ProcCallInstr

func (*Builder) CreateRet

func (b *Builder) CreateRet(v Expr) *Return

func (*Builder) CreateSub

func (b *Builder) CreateSub(lhs, rhs Expr) Expr

func (*Builder) CreateXOR

func (b *Builder) CreateXOR(lhs, rhs Expr) Expr

func (*Builder) GetInsertBlock

func (b *Builder) GetInsertBlock() *BasicBlock

GetInsertBlock returns the current BasicBlock where instructions are inserted

func (*Builder) SetInsertPoint

func (b *Builder) SetInsertPoint(BB *BasicBlock)

SetInsertPoint updates the current BasicBlock to BB

type Cmp

type Cmp struct {
	Pred Opcode
	X, Y Expr
	// contains filtered or unexported fields
}

Cmp -------------------------

func CreateCmp

func CreateCmp(pred Opcode, x, y Expr) *Cmp

func (*Cmp) BaseName

func (c *Cmp) BaseName() string

func (*Cmp) HasName

func (c *Cmp) HasName() bool

func (*Cmp) Name

func (c *Cmp) Name() string

func (*Cmp) NumOperands

func (c *Cmp) NumOperands() int

func (*Cmp) Operand

func (c *Cmp) Operand(i int) Expr

func (*Cmp) SetName

func (c *Cmp) SetName(string)

func (*Cmp) String

func (c *Cmp) String() string

func (*Cmp) Type

func (c *Cmp) Type() Type

type CondBr

type CondBr struct {
	Op      Opcode
	Cond    Expr
	IfTrue  *BasicBlock
	IfFalse *BasicBlock
	// contains filtered or unexported fields
}

CondBr ----------

func CreateCondBr

func CreateCondBr(cond Expr, ifThen, ifElse *BasicBlock) *CondBr

func (*CondBr) Parent

func (c *CondBr) Parent() *BasicBlock

func (*CondBr) SetParent

func (c *CondBr) SetParent(parent *BasicBlock)

func (*CondBr) String

func (c *CondBr) String() string

type ConstantBool

type ConstantBool struct {
	Value int
	Ty    *Int1
}

ConstantBool ... --------------------

func NewConstBool

func NewConstBool(value int) *ConstantBool

func (ConstantBool) BaseName

func (c ConstantBool) BaseName() string

func (ConstantBool) HasName

func (c ConstantBool) HasName() bool

func (ConstantBool) Name

func (c ConstantBool) Name() string

func (ConstantBool) NumOperands

func (c ConstantBool) NumOperands() int

func (ConstantBool) Operand

func (c ConstantBool) Operand(i int) Expr

func (ConstantBool) SetName

func (c ConstantBool) SetName(string)

func (ConstantBool) String

func (c ConstantBool) String() string

func (ConstantBool) Type

func (c ConstantBool) Type() Type

type ConstantInt

type ConstantInt struct {
	Value  uint64
	Signed bool
	Ty     Type
}

ConstantInt ... --------------------

func NewConstantInt

func NewConstantInt(ty Type, value uint64, signed bool) *ConstantInt

func (ConstantInt) BaseName

func (c ConstantInt) BaseName() string

func (ConstantInt) HasName

func (c ConstantInt) HasName() bool

func (ConstantInt) Name

func (c ConstantInt) Name() string

func (ConstantInt) NumOperands

func (c ConstantInt) NumOperands() int

func (ConstantInt) Operand

func (c ConstantInt) Operand(i int) Expr

func (ConstantInt) SetName

func (c ConstantInt) SetName(string)

func (ConstantInt) String

func (c ConstantInt) String() string

func (ConstantInt) Type

func (c ConstantInt) Type() Type

type ControlFlowGraph

type ControlFlowGraph struct {
	Entry, Exit *BasicBlock
	Nodes       adt.Set[*BasicBlock]
	Succ        map[string]*adt.HashSet[*BasicBlock]
	Pred        map[string]*adt.HashSet[*BasicBlock]

	Defs map[string]Stmt
	Uses map[string]adt.Set[Stmt]
}

ControlFlowGraph ----------------------------------------------------------------

func NewCFG

func NewCFG() *ControlFlowGraph

func (*ControlFlowGraph) AddPred

func (cfg *ControlFlowGraph) AddPred(BlkName string, Predecessors ...*BasicBlock)

func (*ControlFlowGraph) AddSucc

func (cfg *ControlFlowGraph) AddSucc(BlkName string, Successors ...*BasicBlock)

func (*ControlFlowGraph) DeleteBlocks

func (cfg *ControlFlowGraph) DeleteBlocks(blocks ...*BasicBlock)

func (*ControlFlowGraph) IsBrNode

func (cfg *ControlFlowGraph) IsBrNode(blk string) bool

func (*ControlFlowGraph) IsJoinNode

func (cfg *ControlFlowGraph) IsJoinNode(blk string) bool

func (*ControlFlowGraph) PostOrder

func (cfg *ControlFlowGraph) PostOrder() []*BasicBlock

func (*ControlFlowGraph) Reverse

func (cfg *ControlFlowGraph) Reverse() *ControlFlowGraph

func (*ControlFlowGraph) ReversePostOrder

func (cfg *ControlFlowGraph) ReversePostOrder() []*BasicBlock

func (*ControlFlowGraph) String

func (cfg *ControlFlowGraph) String() string

type Expr

type Expr interface {
	Name() string
	BaseName() string
	SetName(string)
	HasName() bool
	Operand(int) Expr
	NumOperands() int
	Type() Type
	fmt.Stringer
	// contains filtered or unexported methods
}

func GetAllOnesValue

func GetAllOnesValue(ty Type) Expr

func GetNullValue

func GetNullValue(ty Type) Expr

type FuncCall

type FuncCall struct {
	Op     Opcode
	Callee Expr
	Args   []Expr
	// contains filtered or unexported fields
}

FuncCall ... --------------------

func CreateFuncCall

func CreateFuncCall(callee Expr, args []Expr) *FuncCall

func (FuncCall) BaseName

func (c FuncCall) BaseName() string

func (FuncCall) HasName

func (c FuncCall) HasName() bool

func (FuncCall) Name

func (c FuncCall) Name() string

func (FuncCall) NumOperands

func (c FuncCall) NumOperands() int

func (FuncCall) Operand

func (c FuncCall) Operand(idx int) Expr

func (FuncCall) SetName

func (c FuncCall) SetName(string)

func (FuncCall) String

func (c FuncCall) String() string

func (FuncCall) Type

func (c FuncCall) Type() Type

type Function

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

Function ... -----------------------------

func CreateFunction

func CreateFunction(ty *FunctionType, link LinkageKind, name string, module *Module) *Function

func CreatePreDeclaredFunction

func CreatePreDeclaredFunction(ty *FunctionType, link LinkageKind, name string, module *Module) *Function

func (*Function) CFG

func (f *Function) CFG() *ControlFlowGraph

func (*Function) HasExternalLinkage

func (f *Function) HasExternalLinkage() bool

func (*Function) HasInternalLinkage

func (f *Function) HasInternalLinkage() bool

func (*Function) HasName

func (f *Function) HasName() bool

func (*Function) Name

func (f *Function) Name() string

func (*Function) NumUses

func (f *Function) NumUses() int

func (*Function) OrigName

func (f *Function) OrigName() string

func (*Function) Parent

func (f *Function) Parent() *Module

func (*Function) SetName

func (f *Function) SetName(name string)

func (*Function) String

func (f *Function) String() string

func (*Function) SymbolTable

func (f *Function) SymbolTable()

func (*Function) Type

func (f *Function) Type() Type

type FunctionType

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

FunctionType ... ---------------------

func CreateFunctionType

func CreateFunctionType(args []Type, retTy Type, varArgs bool) *FunctionType

func (FunctionType) ArgType

func (f FunctionType) ArgType(i uint) Type

func (FunctionType) IsArrayTy

func (FunctionType) IsArrayTy() bool

func (FunctionType) IsFuncTy

func (FunctionType) IsFuncTy() bool

func (FunctionType) IsIntegerTy

func (FunctionType) IsIntegerTy() bool

func (FunctionType) IsPtrTy

func (FunctionType) IsPtrTy() bool

func (FunctionType) IsVarArg

func (f FunctionType) IsVarArg() bool

func (FunctionType) IsVoidTy

func (FunctionType) IsVoidTy() bool

func (FunctionType) NumArgs

func (f FunctionType) NumArgs() int

func (FunctionType) ReturnType

func (f FunctionType) ReturnType() Type

func (FunctionType) String

func (f FunctionType) String() string

type Int1

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

Int1 ... ----------------------

func (Int1) BitWidth

func (i Int1) BitWidth() uint

func (Int1) IsArrayTy

func (Int1) IsArrayTy() bool

func (Int1) IsFuncTy

func (Int1) IsFuncTy() bool

func (Int1) IsIntegerTy

func (Int1) IsIntegerTy() bool

func (Int1) IsPtrTy

func (Int1) IsPtrTy() bool

func (Int1) IsVoidTy

func (Int1) IsVoidTy() bool

func (Int1) String

func (Int1) String() string

type Int16

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

Int16 ... ----------------------

func (Int16) BitWidth

func (i Int16) BitWidth() uint

func (Int16) IsArrayTy

func (Int16) IsArrayTy() bool

func (Int16) IsFuncTy

func (Int16) IsFuncTy() bool

func (Int16) IsIntegerTy

func (Int16) IsIntegerTy() bool

func (Int16) IsPtrTy

func (Int16) IsPtrTy() bool

func (Int16) IsVoidTy

func (Int16) IsVoidTy() bool

func (Int16) String

func (Int16) String() string

type Int32

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

Int32 ... ----------------------

func (Int32) BitWidth

func (i Int32) BitWidth() uint

func (Int32) IsArrayTy

func (Int32) IsArrayTy() bool

func (Int32) IsFuncTy

func (Int32) IsFuncTy() bool

func (Int32) IsIntegerTy

func (Int32) IsIntegerTy() bool

func (Int32) IsPtrTy

func (Int32) IsPtrTy() bool

func (Int32) IsVoidTy

func (Int32) IsVoidTy() bool

func (Int32) String

func (Int32) String() string

type Int64

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

Int64 ... ----------------------

func (Int64) BitWidth

func (i Int64) BitWidth() uint

func (Int64) IsArrayTy

func (Int64) IsArrayTy() bool

func (Int64) IsFuncTy

func (Int64) IsFuncTy() bool

func (Int64) IsIntegerTy

func (Int64) IsIntegerTy() bool

func (Int64) IsPtrTy

func (Int64) IsPtrTy() bool

func (Int64) IsVoidTy

func (Int64) IsVoidTy() bool

func (Int64) String

func (Int64) String() string

type Int8

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

Int8 ... ----------------------

func (Int8) BitWidth

func (i Int8) BitWidth() uint

func (Int8) IsArrayTy

func (Int8) IsArrayTy() bool

func (Int8) IsFuncTy

func (Int8) IsFuncTy() bool

func (Int8) IsIntegerTy

func (Int8) IsIntegerTy() bool

func (Int8) IsPtrTy

func (Int8) IsPtrTy() bool

func (Int8) IsVoidTy

func (Int8) IsVoidTy() bool

func (Int8) String

func (Int8) String() string

type IntegerType

type IntegerType interface {
	Type
	BitWidth() uint
}

IntegerType ... ----------------------

func GetIntegerType

func GetIntegerType(numBits uint) IntegerType

type Jump

type Jump struct {
	Op  Opcode
	Dst *BasicBlock
	// contains filtered or unexported fields
}

Jump --------------------------------

func CreateJmp

func CreateJmp(dst *BasicBlock) *Jump

func (*Jump) Parent

func (j *Jump) Parent() *BasicBlock

func (*Jump) SetParent

func (j *Jump) SetParent(parent *BasicBlock)

func (*Jump) String

func (j *Jump) String() string

type LabelType

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

LabelType ... ---------------------

func (LabelType) IsArrayTy

func (LabelType) IsArrayTy() bool

func (LabelType) IsFuncTy

func (LabelType) IsFuncTy() bool

func (LabelType) IsIntegerTy

func (LabelType) IsIntegerTy() bool

func (LabelType) IsPtrTy

func (LabelType) IsPtrTy() bool

func (LabelType) IsVoidTy

func (LabelType) IsVoidTy() bool

func (LabelType) String

func (l LabelType) String() string

type LinkageKind

type LinkageKind int
const (
	Internal LinkageKind = iota
	External
)

type Load

type Load struct {
	Op   Opcode
	Addr Expr
}

Load --------------------------

func CreateLoad

func CreateLoad(addr Expr) *Load

func (Load) BaseName

func (l Load) BaseName() string

func (Load) HasName

func (l Load) HasName() bool

func (Load) Name

func (l Load) Name() string

func (Load) NumOperands

func (l Load) NumOperands() int

func (Load) Operand

func (l Load) Operand(i int) Expr

func (Load) SetName

func (l Load) SetName(string)

func (Load) String

func (l Load) String() string

func (Load) Type

func (l Load) Type() Type

type Module

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

func NewModule

func NewModule(name string) *Module

func (*Module) GetFunction

func (m *Module) GetFunction(name string) (F *Function)

func (*Module) GetFunctionList

func (m *Module) GetFunctionList() []*Function

func (*Module) GetOrInsertFunction

func (m *Module) GetOrInsertFunction(name string, ty *FunctionType, link LinkageKind) *Function

type ObjKind

type ObjKind int
const (
	Var ObjKind = iota
	Const
	Func
)

type Object

type Object interface {
	Name() string
	Type() Type
	Kind() ObjKind
	Offset() int
	Parent() Scope
	SetParent(Scope)
}

type Opcode

type Opcode int
const (
	Invalid Opcode = iota

	Add
	Sub
	Mul
	Div

	Ld
	Str

	Xor
	Or
	And
	Shl
	LShr
	AShr

	Call
	Phi

	Eq
	Ne
	Gt
	Ge
	Lt
	Le

	Br
	Ret
	Jmp
)

func (Opcode) String

func (op Opcode) String() string

type PHINode

type PHINode struct {
	Op       Opcode
	Incoming []PHINodeIncoming
	// contains filtered or unexported fields
}

PHINode --------------------------

func CreateEmptyPHINode

func CreateEmptyPHINode() *PHINode

func CreatePHINode

func CreatePHINode(numIncomingPaths uint) *PHINode

func (*PHINode) AddIncoming

func (phi *PHINode) AddIncoming(v Expr, blk *BasicBlock)

func (*PHINode) BaseName

func (phi *PHINode) BaseName() string

func (*PHINode) HasName

func (phi *PHINode) HasName() bool

func (*PHINode) Name

func (phi *PHINode) Name() string

func (*PHINode) NumOperands

func (phi *PHINode) NumOperands() int

func (*PHINode) Operand

func (phi *PHINode) Operand(int) Expr

func (*PHINode) SetName

func (phi *PHINode) SetName(string)

func (*PHINode) String

func (phi *PHINode) String() string

func (*PHINode) Type

func (phi *PHINode) Type() Type

type PHINodeIncoming

type PHINodeIncoming struct {
	V   Expr
	Blk *BasicBlock
}

func (PHINodeIncoming) String

func (p PHINodeIncoming) String() string

type PointerType

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

PointerType ... --------------------

func CreatePointerType

func CreatePointerType(ty Type) *PointerType

func (PointerType) ElemType

func (p PointerType) ElemType() Type

func (PointerType) IsArrayTy

func (PointerType) IsArrayTy() bool

func (PointerType) IsFuncTy

func (PointerType) IsFuncTy() bool

func (PointerType) IsIntegerTy

func (PointerType) IsIntegerTy() bool

func (PointerType) IsPtrTy

func (PointerType) IsPtrTy() bool

func (PointerType) IsVoidTy

func (PointerType) IsVoidTy() bool

func (PointerType) String

func (PointerType) String() string

type ProcCallInstr

type ProcCallInstr struct {
	Op     Opcode
	Callee Expr
	Args   []Expr
	// contains filtered or unexported fields
}

ProcCallInstr ... --------------------

func CreateProcCall

func CreateProcCall(callee Expr, args []Expr) *ProcCallInstr

func (*ProcCallInstr) Parent

func (c *ProcCallInstr) Parent() *BasicBlock

func (*ProcCallInstr) SetParent

func (c *ProcCallInstr) SetParent(parent *BasicBlock)

func (*ProcCallInstr) String

func (c *ProcCallInstr) String() string

type Program

type Program struct {
	Modules []*Module
}

func (*Program) AddModule

func (p *Program) AddModule(mod *Module)

type PtrTy

type PtrTy struct {
	To Type
}

PtrTy -------------------------------------------

func (PtrTy) IsArrayTy

func (p PtrTy) IsArrayTy() bool

func (PtrTy) IsFuncTy

func (p PtrTy) IsFuncTy() bool

func (PtrTy) IsIntegerTy

func (p PtrTy) IsIntegerTy() bool

func (PtrTy) IsPtrTy

func (p PtrTy) IsPtrTy() bool

func (PtrTy) IsVoidTy

func (p PtrTy) IsVoidTy() bool

func (PtrTy) String

func (p PtrTy) String() string

type Return

type Return struct {
	Op    Opcode
	Value Expr
	// contains filtered or unexported fields
}

Return -----------------------------

func CreateRet

func CreateRet(v Expr) *Return

func (*Return) Parent

func (r *Return) Parent() *BasicBlock

func (*Return) SetParent

func (r *Return) SetParent(parent *BasicBlock)

func (*Return) String

func (r *Return) String() string

type Scope

type Scope interface {
	Parent() Scope
	Size() int
	Lookup(string) Object
	Insert(Object) Object
}

type Stmt

type Stmt interface {
	Parent() *BasicBlock
	SetParent(*BasicBlock)
	fmt.Stringer
	// contains filtered or unexported methods
}

type Store

type Store struct {
	Op    Opcode
	Value Expr
	Addr  Expr
	// contains filtered or unexported fields
}

Store -----------------------

func CreateStore

func CreateStore(addr, value Expr) *Store

func (*Store) Parent

func (s *Store) Parent() *BasicBlock

func (*Store) SetParent

func (s *Store) SetParent(parent *BasicBlock)

func (*Store) String

func (s *Store) String() string

type SymbolTable

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

func NewScope

func NewScope(parent Scope, name string) *SymbolTable

func (*SymbolTable) Elems

func (s *SymbolTable) Elems() map[string]Object

func (*SymbolTable) Insert

func (s *SymbolTable) Insert(obj Object) Object

func (*SymbolTable) Lookup

func (s *SymbolTable) Lookup(name string) Object

Lookup checks the current and (possibly) parent (and ancestor) scopes for the object with the given name if no such object exists, return nil.

func (*SymbolTable) Parent

func (s *SymbolTable) Parent() Scope

Parent returns the scope's containing (parent) scope.

func (*SymbolTable) Size

func (s *SymbolTable) Size() int

Size returns the number of symbols in the scope.

type Temp

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

Temp --------------------------------------

func NewTemp

func NewTemp(name string, ty Type) *Temp

func (*Temp) BaseName

func (t *Temp) BaseName() string

func (*Temp) HasName

func (t *Temp) HasName() bool

func (*Temp) Name

func (t *Temp) Name() string

func (*Temp) NumOperands

func (t *Temp) NumOperands() int

func (*Temp) Operand

func (t *Temp) Operand(i int) Expr

func (*Temp) SetName

func (t *Temp) SetName(s string)

func (*Temp) String

func (t *Temp) String() string

func (*Temp) Type

func (t *Temp) Type() Type

type Type

type Type interface {
	String() string

	IsIntegerTy() bool
	IsPtrTy() bool
	IsFuncTy() bool
	IsVoidTy() bool
	IsArrayTy() bool
	// contains filtered or unexported methods
}

type ValueSymbolTable

type ValueSymbolTable map[string]*Function

type Variable

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

Variable ----------------

func CreateVariableObject

func CreateVariableObject(name string, ty Type, offset int, kind ObjKind) *Variable

func (*Variable) Kind

func (v *Variable) Kind() ObjKind

func (*Variable) Name

func (v *Variable) Name() string

func (*Variable) Offset

func (v *Variable) Offset() int

func (*Variable) Parent

func (v *Variable) Parent() Scope

func (*Variable) SetParent

func (v *Variable) SetParent(s Scope)

func (*Variable) Type

func (v *Variable) Type() Type

type Void

type Void struct{}

Void ... ---------------

func (Void) IsArrayTy

func (Void) IsArrayTy() bool

func (Void) IsFuncTy

func (Void) IsFuncTy() bool

func (Void) IsIntegerTy

func (Void) IsIntegerTy() bool

func (Void) IsPtrTy

func (Void) IsPtrTy() bool

func (Void) IsVoidTy

func (Void) IsVoidTy() bool

func (Void) String

func (Void) String() string

Jump to

Keyboard shortcuts

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