Documentation ¶
Overview ¶
Package tast saves data structures for typed AST. Compiling it should contain no semantic errors.
Index ¶
- Constants
- Variables
- func SymStr(s int) string
- type AssignStmt
- type Block
- type BreakStmt
- type CallExpr
- type Case
- type Cast
- type Const
- type ConstDecls
- type ContinueStmt
- type Define
- type Expr
- type ExprList
- type ExprStmt
- type ForStmt
- type Func
- type FuncAlias
- type Ident
- type IfStmt
- type Import
- type IncStmt
- type IndexExpr
- type MemberExpr
- type OpExpr
- type Pkg
- type Ref
- type ReturnStmt
- type StarExpr
- type Stmt
- type SwitchStmt
- type This
- type Type
- type VarDecls
Constants ¶
const ( SymNone = iota SymFunc SymVar SymStruct SymType SymConst SymImport SymField SymInterface )
Symbol types
Variables ¶
Void is a void ref.
Functions ¶
Types ¶
type AssignStmt ¶
AssignStmt is an assignment statement, like "a,b=x,y".
type Block ¶
type Block struct {
Stmts []Stmt
}
Block is a statement block; it is also a statement itself.
type CallExpr ¶
CallExpr is an expression like "f(x)"
type Cast ¶
Cast cast from one type of reference to another
func NewMultiCast ¶
NewMultiCast creates a new casting operation for a list of refs.
func NewMultiCastType ¶
NewMultiCastType creates a new casting operation from an expression to a list of refs with the same length of a type.
type ConstDecls ¶
type ConstDecls struct {
Decls []*Define
}
ConstDecls is a const declaration group.
type Define ¶
Define is a define statement, like "a,b:=x,y".
type Expr ¶
Expr is a generic interface for an expression.
type ExprList ¶
ExprList is a list of expressions.
func MakeExprList ¶
MakeExprList makes the expression an expression list if it not one yet.
func (*ExprList) Append ¶
Append appends an expression into the expression list.
type ForStmt ¶
ForStmt is a for loop statement.
type Func ¶
type Func struct { Sym *syms.Symbol // function symbol This *types.Pointer Receiver *syms.Symbol // explicit receiver Args []*syms.Symbol NamedRets []*syms.Symbol Body []Stmt }
Func is a function.
type FuncAlias ¶
FuncAlias is a function alias.
type Ident ¶
Ident is an identifier.
type IndexExpr ¶
IndexExpr is an expression like "a[b:c]" Both b and c are optional.
type MemberExpr ¶
MemberExpr is an expression of "a.b"
type OpExpr ¶
OpExpr is an expression likfe "a+b"
type Pkg ¶
type Pkg struct { Imports []*syms.Symbol Consts []*syms.Symbol Structs []*syms.Symbol Interfaces []*syms.Symbol Vars []*Define FuncAliases []*FuncAlias Funcs []*Func Methods []*Func }
Pkg is a package of imports, consts, structs, vars and funcs.
type Ref ¶
type Ref struct { // T is the type of the reference T types.T // ConstValue is not nil when the reference already has a value. ConstValue interface{} // Addressable tells if the reference is addressable Addressable bool // Recv save the receiver, if any. Recv *Ref // List saves the ref for an expression list. List []*Ref // Void is true when the reference is a void ref. // This is required for saving ref of an expression list // or a return value of a function call. Void bool }
Ref is a reference to a evaluatd node.
func NewAddressableRef ¶
NewAddressableRef creates a new addressable node.
func NewConstRef ¶
NewConstRef creates a new reference node with a constant value.
func NewListRef ¶
NewListRef creates a new reference with a list of types.
func NewTypeRef ¶
NewTypeRef creates a new reference node for a type expression.
type SwitchStmt ¶
SwitchStmt is a switch statement