package main import "go/constant" type Node interface { Pos() Pos SetPos(Pos) aNode() } type node struct { pos Pos } func (n *node) Pos() Pos { return n.pos } func (n *node) SetPos(pos Pos) { n.pos = pos } func (*node) aNode() {} type File struct { Pragma Pragma PkgName *Name DeclList []Decl EOF Pos GoVersion string node } type ( Decl interface { Node aDecl() } ImportDecl struct { Group *Group Pragma Pragma LocalPkgName *Name Path *BasicLit decl } ConstDecl struct { Group *Group Pragma Pragma NameList []*Name Type Expr Values Expr decl } TypeDecl struct { Group *Group Pragma Pragma Name *Name TParamList []*Field Alias bool Type Expr decl } VarDecl struct { Group *Group Pragma Pragma NameList []*Name Type Expr Values Expr decl } FuncDecl struct { Pragma Pragma Recv *Field Name *Name TParamList []*Field Type *FuncType Body *BlockStmt decl } ) type decl struct{ node } func (*decl) aDecl() {} type Group struct { _ int } func NewName(pos Pos, value string) *Name { n := &Name{} n.pos = pos n.Value = value return n } type ( Expr interface { Node typeInfo aExpr() } BadExpr struct { expr } Name struct { Value string expr } BasicLit struct { Value string Kind LitKind Bad bool expr } CompositeLit struct { Type Expr ElemList []Expr NKeys int Rbrace Pos expr } KeyValueExpr struct { Key, Value Expr expr } FuncLit struct { Type *FuncType Body *BlockStmt expr } ParenExpr struct { X Expr expr } SelectorExpr struct { X Expr Sel *Name expr } IndexExpr struct { X Expr Index Expr expr } SliceExpr struct { X Expr Index [3]Expr Full bool expr } AssertExpr struct { X Expr Type Expr expr } TypeSwitchGuard struct { Lhs *Name X Expr expr } Operation struct { Op Operator X, Y Expr expr } CallExpr struct { Fun Expr ArgList []Expr HasDots bool expr } ListExpr struct { ElemList []Expr expr } ArrayType struct { Len Expr Elem Expr expr } SliceType struct { Elem Expr expr } DotsType struct { Elem Expr expr } StructType struct { FieldList []*Field TagList []*BasicLit expr } Field struct { Name *Name Type Expr node } InterfaceType struct { MethodList []*Field expr } FuncType struct { ParamList []*Field ResultList []*Field expr } MapType struct { Key, Value Expr expr } ChanType struct { Dir ChanDir Elem Expr expr } ) type Type interface { Underlying() Type String() string } type typeInfo interface { SetTypeInfo(TypeAndValue) GetTypeInfo() TypeAndValue } type TypeAndValue struct { Type Type Value constant.Value exprFlags } type exprFlags uint16 func (f exprFlags) IsVoid() bool { return f&1 != 0 } func (f exprFlags) IsType() bool { return f&2 != 0 } func (f exprFlags) IsBuiltin() bool { return f&4 != 0 } func (f exprFlags) IsValue() bool { return f&8 != 0 } func (f exprFlags) IsNil() bool { return f&16 != 0 } func (f exprFlags) Addressable() bool { return f&32 != 0 } func (f exprFlags) Assignable() bool { return f&64 != 0 } func (f exprFlags) HasOk() bool { return f&128 != 0 } func (f exprFlags) IsRuntimeHelper() bool { return f&256 != 0 } func (f *exprFlags) SetIsVoid() { *f |= 1 } func (f *exprFlags) SetIsType() { *f |= 2 } func (f *exprFlags) SetIsBuiltin() { *f |= 4 } func (f *exprFlags) SetIsValue() { *f |= 8 } func (f *exprFlags) SetIsNil() { *f |= 16 } func (f *exprFlags) SetAddressable() { *f |= 32 } func (f *exprFlags) SetAssignable() { *f |= 64 } func (f *exprFlags) SetHasOk() { *f |= 128 } func (f *exprFlags) SetIsRuntimeHelper() { *f |= 256 } type typeAndValue struct { tv TypeAndValue } func (x *typeAndValue) SetTypeInfo(tv TypeAndValue) { x.tv = tv } func (x *typeAndValue) GetTypeInfo() TypeAndValue { return x.tv } type expr struct { node typeAndValue } func (*expr) aExpr() {} type ChanDir uint const ( _ ChanDir = iota SendOnly RecvOnly ) type ( Stmt interface { Node aStmt() } SimpleStmt interface { Stmt aSimpleStmt() } EmptyStmt struct { simpleStmt } LabeledStmt struct { Label *Name Stmt Stmt stmt } BlockStmt struct { List []Stmt Rbrace Pos stmt } ExprStmt struct { X Expr simpleStmt } SendStmt struct { Chan, Value Expr simpleStmt } DeclStmt struct { DeclList []Decl stmt } AssignStmt struct { Op Operator Lhs, Rhs Expr simpleStmt } BranchStmt struct { Tok Token Label *Name Target Stmt stmt } CallStmt struct { Tok Token Call Expr DeferAt Expr stmt } ReturnStmt struct { Results Expr stmt } IfStmt struct { Init SimpleStmt Cond Expr Then *BlockStmt Else Stmt stmt } ForStmt struct { Init SimpleStmt Cond Expr Post SimpleStmt Body *BlockStmt stmt } SwitchStmt struct { Init SimpleStmt Tag Expr Body []*CaseClause Rbrace Pos stmt } SelectStmt struct { Body []*CommClause Rbrace Pos stmt } ) type ( RangeClause struct { Lhs Expr Def bool X Expr simpleStmt } CaseClause struct { Cases Expr Body []Stmt Colon Pos node } CommClause struct { Comm SimpleStmt Body []Stmt Colon Pos node } ) type stmt struct{ node } func (stmt) aStmt() {} type simpleStmt struct { stmt } func (simpleStmt) aSimpleStmt() {} type CommentKind uint const ( Above CommentKind = iota Below Left Right ) type Comment struct { Kind CommentKind Text string Next *Comment }