gc

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2018 License: BSD-3-Clause Imports: 16 Imported by: 1

README

gc

Package GC is a Go compiler front end. (Work in progress)

Installation

$ go get modernc.org/gc

Documentation: godoc.org/modernc.org/gc

Documentation

Overview

Package gc is a Go compiler front end. Work in progess. API not stable.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayType

type ArrayType struct {
	Expr    Expr
	Element Type
	// contains filtered or unexported fields
}

ArrayType represents '[Expr]Element'.

Example
example(&ArrayType{}, "type T [42]int")
Output:

&gc.ArrayType{
· Expr: &gc.PrimaryExprIntLiteral{
· · Literal: 2:9: "42",
· },
· Element: &gc.NamedType{
· · Name: "int",
· },
}

func (*ArrayType) AssignableTo

func (n *ArrayType) AssignableTo(t Type) bool

func (*ArrayType) ComparableWith

func (n *ArrayType) ComparableWith(t Type) (r bool, _ string)

func (*ArrayType) Identical

func (n *ArrayType) Identical(t Type) bool

func (*ArrayType) Implements

func (n *ArrayType) Implements(t Type) (r bool)

func (*ArrayType) IsDefined

func (n *ArrayType) IsDefined() bool

func (*ArrayType) Kind

func (n *ArrayType) Kind() TypeKind

func (*ArrayType) String

func (n *ArrayType) String() string

func (*ArrayType) UnderlyingType

func (n *ArrayType) UnderlyingType() Type

type Bindings

type Bindings map[string]Declaration

Bindings map names to Declarations.

type CaseBlock

type CaseBlock struct {
	ExprOrTypeList []ExprOrType
	Expr           Expr
	Body           []Stmt //TODO StmtBlock

	Default bool // "default" clause
	Define  bool // true: case x := y; false: case y or case x = y.
	// contains filtered or unexported fields
}

CaseBlock represents data reduced by productions

caseBlockList:
|	caseBlockList "case" exprOrTypeList ":=" expr ':' stmtList
|	caseBlockList "case" exprOrTypeList ':' stmtList
|	caseBlockList "case" exprOrTypeList '=' expr ':' stmtList
|	caseBlockList "default" ':' stmtList
Example (Default)
example(CaseBlock{}, `
func foo() {
	switch  x {
	case 42:
		bar()
	default:
		baz()
	}
}
`)
Output:

List: []gc.CaseBlock{ // len 2
· 0: gc.CaseBlock{
· · ExprOrTypeList: []*gc.ExprOrTypeExpr{ // len 1
· · · 0: &gc.ExprOrTypeExpr{
· · · · Expr: &gc.PrimaryExprIntLiteral{
· · · · · Literal: 5:7: "42",
· · · · },
· · · },
· · },
· · Body: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 6:3: "bar",
· · · · · },
· · · · },
· · · },
· · },
· },
· 1: gc.CaseBlock{
· · Body: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 8:3: "baz",
· · · · · },
· · · · },
· · · },
· · },
· · Default: true,
· },
},
Example (SelectAssign)
example(CaseBlock{}, `
func foo() {
	select {
	case x, ok = <-c:
		bar()
	}
}
`)
Output:

List: []gc.CaseBlock{ // len 1
· 0: gc.CaseBlock{
· · ExprOrTypeList: []*gc.ExprOrTypeExpr{ // len 2
· · · 0: &gc.ExprOrTypeExpr{
· · · · Expr: &gc.PrimaryExprIdent{
· · · · · Ident: 5:7: "x",
· · · · },
· · · },
· · · 1: &gc.ExprOrTypeExpr{
· · · · Expr: &gc.PrimaryExprIdent{
· · · · · Ident: 5:10: "ok",
· · · · },
· · · },
· · },
· · Expr: &gc.UnaryExprReceive{
· · · Expr: &gc.PrimaryExprIdent{
· · · · Ident: 5:17: "c",
· · · },
· · },
· · Body: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 6:3: "bar",
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (SelectDefine)
example(CaseBlock{}, `
func foo() {
	select {
	case x, ok := <-c:
		bar()
	}
}
`)
Output:

List: []gc.CaseBlock{ // len 1
· 0: gc.CaseBlock{
· · ExprOrTypeList: []*gc.ExprOrTypeExpr{ // len 2
· · · 0: &gc.ExprOrTypeExpr{
· · · · Expr: &gc.PrimaryExprIdent{
· · · · · Ident: 5:7: "x",
· · · · },
· · · },
· · · 1: &gc.ExprOrTypeExpr{
· · · · Expr: &gc.PrimaryExprIdent{
· · · · · Ident: 5:10: "ok",
· · · · },
· · · },
· · },
· · Expr: &gc.UnaryExprReceive{
· · · Expr: &gc.PrimaryExprIdent{
· · · · Ident: 5:18: "c",
· · · },
· · },
· · Body: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 6:3: "bar",
· · · · · },
· · · · },
· · · },
· · },
· · Define: true,
· },
},
Example (SwitchExpr)
example(CaseBlock{}, `
func foo() {
	switch x {
	case 42:
		bar()
	}
}
`)
Output:

List: []gc.CaseBlock{ // len 1
· 0: gc.CaseBlock{
· · ExprOrTypeList: []*gc.ExprOrTypeExpr{ // len 1
· · · 0: &gc.ExprOrTypeExpr{
· · · · Expr: &gc.PrimaryExprIntLiteral{
· · · · · Literal: 5:7: "42",
· · · · },
· · · },
· · },
· · Body: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 6:3: "bar",
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (SwitchType)
example(CaseBlock{}, `
func foo() {
	switch x.(type) {
	case []int:
		bar()
	}
}
`)
Output:

List: []gc.CaseBlock{ // len 1
· 0: gc.CaseBlock{
· · ExprOrTypeList: []*gc.ExprOrTypeType{ // len 1
· · · 0: &gc.ExprOrTypeType{
· · · },
· · },
· · Body: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 6:3: "bar",
· · · · · },
· · · · },
· · · },
· · },
· },
},

func (CaseBlock) String

func (i CaseBlock) String() string

type ChanDir

type ChanDir int

ChanDir represents channel direction.

const (
	TxChan ChanDir = 1 << iota
	RxChan
)

Values of type ChanDir

func (ChanDir) String

func (i ChanDir) String() string

type ChannelType

type ChannelType struct {
	Element Type

	Dir ChanDir
	// contains filtered or unexported fields
}

ChannelType represents 'chan Element'.

Example
example(&ChannelType{}, "type T <-chan int")
Output:

&gc.ChannelType{
· Element: &gc.NamedType{
· · Name: "int",
· },
· Dir: RxChan,
}

func (*ChannelType) AssignableTo

func (n *ChannelType) AssignableTo(t Type) bool

func (*ChannelType) ComparableWith

func (n *ChannelType) ComparableWith(t Type) (r bool, _ string)

func (*ChannelType) Identical

func (n *ChannelType) Identical(t Type) bool

func (*ChannelType) Implements

func (n *ChannelType) Implements(t Type) (r bool)

func (*ChannelType) IsDefined

func (n *ChannelType) IsDefined() bool

func (*ChannelType) Kind

func (n *ChannelType) Kind() TypeKind

func (*ChannelType) String

func (n *ChannelType) String() string

func (*ChannelType) UnderlyingType

func (n *ChannelType) UnderlyingType() Type

type CompLitExpr

type CompLitExpr interface {
	// contains filtered or unexported methods
}

CompLitExpr represents data reduced by productions

compLitExpr:
	'{' bracedKeyValList '}'
|	expr
Example (Expr)
example(&CompLitExprExpr{}, "var v = []int{42}")
Output:

Expr: &gc.CompLitExprExpr{
· Expr: &gc.PrimaryExprIntLiteral{
· · Literal: 2:15: "42",
· },
},
Example (KeyValList)
example(&CompLitExprKeyValList{}, "var v = [][]int{{1: 42, 3: 314}}")
Output:

Expr: &gc.CompLitExprKeyValList{
· List: []*gc.KeyValKeyedExpr{ // len 2
· · 0: &gc.KeyValKeyedExpr{
· · · Key: &gc.CompLitExprExpr{
· · · · Expr: &gc.PrimaryExprIntLiteral{
· · · · · Literal: 2:18: "1",
· · · · },
· · · },
· · · Expr: &gc.CompLitExprExpr{
· · · · Expr: &gc.PrimaryExprIntLiteral{
· · · · · Literal: 2:21: "42",
· · · · },
· · · },
· · },
· · 1: &gc.KeyValKeyedExpr{
· · · Key: &gc.CompLitExprExpr{
· · · · Expr: &gc.PrimaryExprIntLiteral{
· · · · · Literal: 2:25: "3",
· · · · },
· · · },
· · · Expr: &gc.CompLitExprExpr{
· · · · Expr: &gc.PrimaryExprIntLiteral{
· · · · · Literal: 2:28: "314",
· · · · },
· · · },
· · },
· },
},

type CompLitExprExpr

type CompLitExprExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

CompLitExprExpr is a CompLitExpr.

type CompLitExprKeyValList

type CompLitExprKeyValList struct {
	List []KeyVal
	// contains filtered or unexported fields
}

CompLitExprKeyValList is a CompLitExpr.

type ConstDecl

type ConstDecl struct {
	Value Operand
	// contains filtered or unexported fields
}

ConstDecl describes a constant declaration.

func (*ConstDecl) Kind

func (d *ConstDecl) Kind() DeclarationKind

Kind implements Declaration.

func (*ConstDecl) Name

func (d *ConstDecl) Name() string

Name implements Declaration.

func (*ConstDecl) String

func (d *ConstDecl) String() string

String implements Declaration.

func (*ConstDecl) Type

func (d *ConstDecl) Type() Type

Type implements Declaration.

func (*ConstDecl) Visibility

func (d *ConstDecl) Visibility() token.Pos

Visibility implements Declaration.

type Context

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

Context describes the context of loaded packages.

func NewContext

func NewContext(goos, goarch string, tags, searchPaths []string, options ...Option) (*Context, error)

NewContext returns a newly created Context. tags are the build tags considered when loading packages having build directives (see https://golang.ir/pkg/go/build/#hdr-Build_Constraints for details). searchPaths are examined when looking for a package to load.

func (*Context) Build

func (c *Context) Build(files []string) (*Package, error)

Build constructs a package from files and returns the resulting Package or an error if any. Build panics if len(files) == 0.

The method is safe for concurrent use by multiple goroutines.

func (*Context) FilesForImportPath

func (c *Context) FilesForImportPath(position token.Position, importPath string) (dir string, sourceFiles []string, testFiles []string, err error)

FilesForImportPath the package directory and a list of source and test files.

func (*Context) Load

func (c *Context) Load(importPath string) (*Package, error)

Load finds the package in importPath and returns the resulting Package or an error if any.

The method is safe for concurrent use by multiple goroutines.

func (*Context) NumPackages

func (c *Context) NumPackages() int

NumPackages returns the number of loaded packages.

The method is safe for concurrent use by multiple goroutines.

func (*Context) SourceFileForPath

func (c *Context) SourceFileForPath(path string) *SourceFile

SourceFileForPath searches loaded packages for the one containing the file at path and returns the corresponding SourceFile. The result is nil if the file is not considered for build by any of the loaded packages.

The method is safe for concurrent use by multiple goroutines.

type Declaration

type Declaration interface {
	//TODO Node
	// Kind returns the Declarations's kind.
	Kind() DeclarationKind

	// Name returns the declared name.
	Name() string

	// Position returns the position of the declaration.
	Position() token.Position

	// Visibility returns the position at which the declaration is visible
	// in its declaration scope or token.NoPos for declarations in package
	// and file scope.
	Visibility() token.Pos

	// Type returns the declaration type. N/A for ImportDeclaration.
	Type() Type

	Package() *Package
	SourceFile() *SourceFile
	String() string
	// contains filtered or unexported methods
}

Declaration is one of *ConstDecl, *FuncDecl, *ImportSpec, *MethodDecl, *TypeDecl or *VarDecl.

type DeclarationKind

type DeclarationKind int

DeclarationKind describes a Declaration's Kind.

const (
	ConstDeclaration DeclarationKind = iota
	FuncDeclaration
	ImportDeclaration
	MethodDeclaration
	TypeDeclaration
	VarDeclaration
)

Values of DeclarationKind.

func (DeclarationKind) String

func (i DeclarationKind) String() string

type ElseIf

type ElseIf struct {
	IfHeader
	Body *StmtBlock
}

ElseIf represents data reduced by productions

elseIfList:
|	elseIfList "else" "if" ifHeader loopBody
Example
example(ElseIf{}, `
func foo() {
	if x {
		bar()
	} else if y {
		baz()
	} else if y {
		qux()
	}
}
`)
Output:

ElseIf: []gc.ElseIf{ // len 2
· 0: gc.ElseIf{
· · IfHeader: &gc.IfHeader1{
· · · Stmt: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprIdent{
· · · · · Ident: 6:12: "y",
· · · · },
· · · },
· · },
· · Body: &gc.StmtBlock{
· · · List: []*gc.SimpleStmtExpr{ // len 1
· · · · 0: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprCall{
· · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · Ident: 7:3: "baz",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· },
· 1: gc.ElseIf{
· · IfHeader: &gc.IfHeader1{
· · · Stmt: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprIdent{
· · · · · Ident: 8:12: "y",
· · · · },
· · · },
· · },
· · Body: &gc.StmtBlock{
· · · List: []*gc.SimpleStmtExpr{ // len 1
· · · · 0: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprCall{
· · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · Ident: 9:3: "qux",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· },
},

type Expr

type Expr interface {
	Operand
	Position() token.Position
	// contains filtered or unexported methods
}

Expr represents data reduced by productions

expr:
	expr "!=" expr
|	expr "&&" expr
|	expr "&^" expr
|	expr "<-" expr
|	expr "<<" expr
|	expr "<=" expr
|	expr "==" expr
|	expr ">=" expr
|	expr ">>" expr
|	expr "||" expr
|	expr '%' expr
|	expr '&' expr
|	expr '*' expr
|	expr '+' expr
|	expr '-' expr
|	expr '/' expr
|	expr '<' expr
|	expr '>' expr
|	expr '^' expr
|	expr '|' expr
|	unaryExpr
Example (ADD)
example(&ExprADD{}, "var v = a + b")
Output:

Initializer: &gc.ExprADD{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:13: "b",
· },
},
Example (AND)
example(&ExprAND{}, "var v = a & b")
Output:

Initializer: &gc.ExprAND{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:13: "b",
· },
},
Example (ANDNOT)
example(&ExprANDNOT{}, "var v = a &^ b")
Output:

Initializer: &gc.ExprANDNOT{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "b",
· },
},
Example (EQL)
example(&ExprEQL{}, "var v = a == b")
Output:

Initializer: &gc.ExprEQL{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "b",
· },
},
Example (GEQ)
example(&ExprGEQ{}, "var v = a >= b")
Output:

Initializer: &gc.ExprGEQ{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "b",
· },
},
Example (GTR)
example(&ExprGTR{}, "var v = > b")
Output:

Initializer: &gc.ExprGTR{
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:11: "b",
· },
},
Example (LAND)
example(&ExprLAND{}, "var v = a && b")
Output:

Initializer: &gc.ExprLAND{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "b",
· },
},
Example (LEQ)
example(&ExprLEQ{}, "var v = a <= b")
Output:

Initializer: &gc.ExprLEQ{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "b",
· },
},
Example (LOR)
example(&ExprLOR{}, "var v = a || b")
Output:

Initializer: &gc.ExprLOR{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "b",
· },
},
Example (LSS)
example(&ExprLSS{}, "var v = a < b")
Output:

Initializer: &gc.ExprLSS{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:13: "b",
· },
},
Example (MUL)
example(&ExprMUL{}, "var v = a * b")
Output:

Initializer: &gc.ExprMUL{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:13: "b",
· },
},
Example (NEQ)
example(&ExprNEQ{}, "var v = a != b")
Output:

Initializer: &gc.ExprNEQ{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "b",
· },
},
Example (OR)
example(&ExprOR{}, "var v = a | b")
Output:

Initializer: &gc.ExprOR{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:13: "b",
· },
},
Example (QUO)
example(&ExprQUO{}, "var v = a / b")
Output:

Initializer: &gc.ExprQUO{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:13: "b",
· },
},
Example (REM)
example(&ExprREM{}, "var v = a % b")
Output:

Initializer: &gc.ExprREM{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:13: "b",
· },
},
Example (SHL)
example(&ExprSHL{}, "var v = a << b")
Output:

Initializer: &gc.ExprSHL{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "b",
· },
},
Example (SHR)
example(&ExprSHR{}, "var v = a >> b")
Output:

Initializer: &gc.ExprSHR{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "b",
· },
},
Example (SUB)
example(&ExprSUB{}, "var v = a - b")
Output:

Initializer: &gc.ExprSUB{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:13: "b",
· },
},
Example (XOR)
example(&ExprXOR{}, "var v = a ^ b")
Output:

Initializer: &gc.ExprXOR{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:9: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:13: "b",
· },
},

type ExprADD

type ExprADD struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprADD represents LHS + RHS.

func (*ExprADD) Package

func (n *ExprADD) Package() *Package

func (*ExprADD) Pos

func (n *ExprADD) Pos() token.Pos

func (*ExprADD) Position

func (n *ExprADD) Position() (r token.Position)

func (*ExprADD) SourceFile

func (n *ExprADD) SourceFile() *SourceFile

func (*ExprADD) Type

func (e *ExprADD) Type() Type

func (*ExprADD) Value

func (e *ExprADD) Value() Value

type ExprAND

type ExprAND struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprAND represents LHS & RHS.

func (*ExprAND) Package

func (n *ExprAND) Package() *Package

func (*ExprAND) Pos

func (n *ExprAND) Pos() token.Pos

func (*ExprAND) Position

func (n *ExprAND) Position() (r token.Position)

func (*ExprAND) SourceFile

func (n *ExprAND) SourceFile() *SourceFile

func (*ExprAND) Type

func (e *ExprAND) Type() Type

func (*ExprAND) Value

func (e *ExprAND) Value() Value

type ExprANDNOT

type ExprANDNOT struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprANDNOT represents LHS &^ RHS.

func (*ExprANDNOT) Package

func (n *ExprANDNOT) Package() *Package

func (*ExprANDNOT) Pos

func (n *ExprANDNOT) Pos() token.Pos

func (*ExprANDNOT) Position

func (n *ExprANDNOT) Position() (r token.Position)

func (*ExprANDNOT) SourceFile

func (n *ExprANDNOT) SourceFile() *SourceFile

func (*ExprANDNOT) Type

func (e *ExprANDNOT) Type() Type

func (*ExprANDNOT) Value

func (e *ExprANDNOT) Value() Value

type ExprARROW

type ExprARROW struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprARROW represents LHS <- RHS.

func (*ExprARROW) Package

func (n *ExprARROW) Package() *Package

func (*ExprARROW) Pos

func (n *ExprARROW) Pos() token.Pos

func (*ExprARROW) Position

func (n *ExprARROW) Position() (r token.Position)

func (*ExprARROW) SourceFile

func (n *ExprARROW) SourceFile() *SourceFile

func (*ExprARROW) Type

func (e *ExprARROW) Type() Type

func (*ExprARROW) Value

func (e *ExprARROW) Value() Value

type ExprEQL

type ExprEQL struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprEQL represents LHS == RHS.

func (*ExprEQL) Package

func (n *ExprEQL) Package() *Package

func (*ExprEQL) Pos

func (n *ExprEQL) Pos() token.Pos

func (*ExprEQL) Position

func (n *ExprEQL) Position() (r token.Position)

func (*ExprEQL) SourceFile

func (n *ExprEQL) SourceFile() *SourceFile

func (*ExprEQL) Type

func (e *ExprEQL) Type() Type

func (*ExprEQL) Value

func (e *ExprEQL) Value() Value

type ExprGEQ

type ExprGEQ struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprGEQ represents LHS >= RHS.

func (*ExprGEQ) Package

func (n *ExprGEQ) Package() *Package

func (*ExprGEQ) Pos

func (n *ExprGEQ) Pos() token.Pos

func (*ExprGEQ) Position

func (n *ExprGEQ) Position() (r token.Position)

func (*ExprGEQ) SourceFile

func (n *ExprGEQ) SourceFile() *SourceFile

func (*ExprGEQ) Type

func (e *ExprGEQ) Type() Type

func (*ExprGEQ) Value

func (e *ExprGEQ) Value() Value

type ExprGTR

type ExprGTR struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprGTR represents LHS > RHS.

func (*ExprGTR) Package

func (n *ExprGTR) Package() *Package

func (*ExprGTR) Pos

func (n *ExprGTR) Pos() token.Pos

func (*ExprGTR) Position

func (n *ExprGTR) Position() (r token.Position)

func (*ExprGTR) SourceFile

func (n *ExprGTR) SourceFile() *SourceFile

func (*ExprGTR) Type

func (e *ExprGTR) Type() Type

func (*ExprGTR) Value

func (e *ExprGTR) Value() Value

type ExprLAND

type ExprLAND struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprLAND represents LHS && RHS.

func (*ExprLAND) Package

func (n *ExprLAND) Package() *Package

func (*ExprLAND) Pos

func (n *ExprLAND) Pos() token.Pos

func (*ExprLAND) Position

func (n *ExprLAND) Position() (r token.Position)

func (*ExprLAND) SourceFile

func (n *ExprLAND) SourceFile() *SourceFile

func (*ExprLAND) Type

func (e *ExprLAND) Type() Type

func (*ExprLAND) Value

func (e *ExprLAND) Value() Value

type ExprLEQ

type ExprLEQ struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprLEQ represents LHS <= RHS.

func (*ExprLEQ) Package

func (n *ExprLEQ) Package() *Package

func (*ExprLEQ) Pos

func (n *ExprLEQ) Pos() token.Pos

func (*ExprLEQ) Position

func (n *ExprLEQ) Position() (r token.Position)

func (*ExprLEQ) SourceFile

func (n *ExprLEQ) SourceFile() *SourceFile

func (*ExprLEQ) Type

func (e *ExprLEQ) Type() Type

func (*ExprLEQ) Value

func (e *ExprLEQ) Value() Value

type ExprLOR

type ExprLOR struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprLOR represents LHS || RHS.

func (*ExprLOR) Package

func (n *ExprLOR) Package() *Package

func (*ExprLOR) Pos

func (n *ExprLOR) Pos() token.Pos

func (*ExprLOR) Position

func (n *ExprLOR) Position() (r token.Position)

func (*ExprLOR) SourceFile

func (n *ExprLOR) SourceFile() *SourceFile

func (*ExprLOR) Type

func (e *ExprLOR) Type() Type

func (*ExprLOR) Value

func (e *ExprLOR) Value() Value

type ExprLSS

type ExprLSS struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprLSS represents LHS < RHS.

func (*ExprLSS) Package

func (n *ExprLSS) Package() *Package

func (*ExprLSS) Pos

func (n *ExprLSS) Pos() token.Pos

func (*ExprLSS) Position

func (n *ExprLSS) Position() (r token.Position)

func (*ExprLSS) SourceFile

func (n *ExprLSS) SourceFile() *SourceFile

func (*ExprLSS) Type

func (e *ExprLSS) Type() Type

func (*ExprLSS) Value

func (e *ExprLSS) Value() Value

type ExprMUL

type ExprMUL struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprMUL represents LHS * RHS.

func (*ExprMUL) Package

func (n *ExprMUL) Package() *Package

func (*ExprMUL) Pos

func (n *ExprMUL) Pos() token.Pos

func (*ExprMUL) Position

func (n *ExprMUL) Position() (r token.Position)

func (*ExprMUL) SourceFile

func (n *ExprMUL) SourceFile() *SourceFile

func (*ExprMUL) Type

func (e *ExprMUL) Type() Type

func (*ExprMUL) Value

func (e *ExprMUL) Value() Value

type ExprNEQ

type ExprNEQ struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprNEQ represents LHS != RHS.

func (*ExprNEQ) Package

func (n *ExprNEQ) Package() *Package

func (*ExprNEQ) Pos

func (n *ExprNEQ) Pos() token.Pos

func (*ExprNEQ) Position

func (n *ExprNEQ) Position() (r token.Position)

func (*ExprNEQ) SourceFile

func (n *ExprNEQ) SourceFile() *SourceFile

func (*ExprNEQ) Type

func (e *ExprNEQ) Type() Type

func (*ExprNEQ) Value

func (e *ExprNEQ) Value() Value

type ExprOR

type ExprOR struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprOR represents LHS | RHS.

func (*ExprOR) Package

func (n *ExprOR) Package() *Package

func (*ExprOR) Pos

func (n *ExprOR) Pos() token.Pos

func (*ExprOR) Position

func (n *ExprOR) Position() (r token.Position)

func (*ExprOR) SourceFile

func (n *ExprOR) SourceFile() *SourceFile

func (*ExprOR) Type

func (e *ExprOR) Type() Type

func (*ExprOR) Value

func (e *ExprOR) Value() Value

type ExprOrType

type ExprOrType interface {
	Position() token.Position
	Type() Type
	// contains filtered or unexported methods
}

ExprOrType represents data reduced by productions

exprOrType:
	expr
|	nonExprType %prec _PreferToRightParen
Example (Expr)
example(&ExprOrTypeExpr{}, "var v = foo(42)")
Output:

0: &gc.ExprOrTypeExpr{
· Expr: &gc.PrimaryExprIntLiteral{
· · Literal: 2:13: "42",
· },
},
Example (Type)
example(&ExprOrTypeType{}, "var v = make([]int, 42)")
Output:

0: &gc.ExprOrTypeType{
},

type ExprOrTypeExpr

type ExprOrTypeExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

ExprOrTypeExpr is an ExprOrType.

func (*ExprOrTypeExpr) Position

func (n *ExprOrTypeExpr) Position() token.Position

Position implemenst Expr.

func (*ExprOrTypeExpr) Type

func (n *ExprOrTypeExpr) Type() Type

Type implements Expr.

type ExprOrTypeType

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

ExprOrTypeType is an ExprOrType.

func (*ExprOrTypeType) Position

func (e *ExprOrTypeType) Position() (r token.Position)

func (*ExprOrTypeType) Type

func (n *ExprOrTypeType) Type() Type

Type implements Expr.

type ExprQUO

type ExprQUO struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprQUO represents LHS / RHS.

func (*ExprQUO) Package

func (n *ExprQUO) Package() *Package

func (*ExprQUO) Pos

func (n *ExprQUO) Pos() token.Pos

func (*ExprQUO) Position

func (n *ExprQUO) Position() (r token.Position)

func (*ExprQUO) SourceFile

func (n *ExprQUO) SourceFile() *SourceFile

func (*ExprQUO) Type

func (e *ExprQUO) Type() Type

func (*ExprQUO) Value

func (e *ExprQUO) Value() Value

type ExprREM

type ExprREM struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprREM represents LHS % RHS.

func (*ExprREM) Package

func (n *ExprREM) Package() *Package

func (*ExprREM) Pos

func (n *ExprREM) Pos() token.Pos

func (*ExprREM) Position

func (n *ExprREM) Position() (r token.Position)

func (*ExprREM) SourceFile

func (n *ExprREM) SourceFile() *SourceFile

func (*ExprREM) Type

func (e *ExprREM) Type() Type

func (*ExprREM) Value

func (e *ExprREM) Value() Value

type ExprSHL

type ExprSHL struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprSHL represents LHS << RHS.

func (*ExprSHL) Package

func (n *ExprSHL) Package() *Package

func (*ExprSHL) Pos

func (n *ExprSHL) Pos() token.Pos

func (*ExprSHL) Position

func (n *ExprSHL) Position() (r token.Position)

func (*ExprSHL) SourceFile

func (n *ExprSHL) SourceFile() *SourceFile

func (*ExprSHL) Type

func (e *ExprSHL) Type() Type

func (*ExprSHL) Value

func (e *ExprSHL) Value() Value

type ExprSHR

type ExprSHR struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprSHR represents LHS >> RHS.

func (*ExprSHR) Package

func (n *ExprSHR) Package() *Package

func (*ExprSHR) Pos

func (n *ExprSHR) Pos() token.Pos

func (*ExprSHR) Position

func (n *ExprSHR) Position() (r token.Position)

func (*ExprSHR) SourceFile

func (n *ExprSHR) SourceFile() *SourceFile

func (*ExprSHR) Type

func (e *ExprSHR) Type() Type

func (*ExprSHR) Value

func (e *ExprSHR) Value() Value

type ExprSUB

type ExprSUB struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprSUB represents LHS - RHS.

func (*ExprSUB) Package

func (n *ExprSUB) Package() *Package

func (*ExprSUB) Pos

func (n *ExprSUB) Pos() token.Pos

func (*ExprSUB) Position

func (n *ExprSUB) Position() (r token.Position)

func (*ExprSUB) SourceFile

func (n *ExprSUB) SourceFile() *SourceFile

func (*ExprSUB) Type

func (e *ExprSUB) Type() Type

func (*ExprSUB) Value

func (e *ExprSUB) Value() Value

type ExprXOR

type ExprXOR struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

ExprXOR represents LHS 6 RHS.

func (*ExprXOR) Package

func (n *ExprXOR) Package() *Package

func (*ExprXOR) Pos

func (n *ExprXOR) Pos() token.Pos

func (*ExprXOR) Position

func (n *ExprXOR) Position() (r token.Position)

func (*ExprXOR) SourceFile

func (n *ExprXOR) SourceFile() *SourceFile

func (*ExprXOR) Type

func (e *ExprXOR) Type() Type

func (*ExprXOR) Value

func (e *ExprXOR) Value() Value

type FieldDeclaration

type FieldDeclaration interface {
	// contains filtered or unexported methods
}

FieldDeclaration represents data reduced by productions

fieldDecl:
	'*' embeddedName literalOpt
|	identList typ literalOpt
|	embeddedName literalOpt
Example (Embedded)
example(&FieldDeclarationEmbedded{}, "type T struct { io.Reader }")
Output:

0: &gc.FieldDeclarationEmbedded{
· Type: &gc.QualifiedNamedType{
· · Qualifier: "io",
· · Name: "Reader",
· },
},
Example (EmbeddedPtr)
example(&FieldDeclarationEmbedded{}, "type T struct { *int }")
Output:

0: &gc.FieldDeclarationEmbedded{
· Type: &gc.PointerType{
· · Element: &gc.NamedType{
· · · Name: "int",
· · },
· },
· Ptr: true,
},
Example (Named)
example(&FieldDeclarationNamed{}, "type T struct { i int }")
Output:

0: &gc.FieldDeclarationNamed{
· Name: 2:17: "i",
· Type: &gc.NamedType{
· · Name: "int",
· },
},

type FieldDeclarationEmbedded

type FieldDeclarationEmbedded struct {
	Type Type
	Tag  string

	Ptr bool
	// contains filtered or unexported fields
}

FieldDeclarationEmbedded is a FieldDeclaration.

type FieldDeclarationNamed

type FieldDeclarationNamed struct {
	Name Token
	Type Type
	Tag  string
	// contains filtered or unexported fields
}

FieldDeclarationNamed is a FieldDeclaration.

type FuncDecl

type FuncDecl struct {
	Body *StmtBlock
	// contains filtered or unexported fields
}

FuncDecl describes a function declaration.

func (*FuncDecl) Kind

func (d *FuncDecl) Kind() DeclarationKind

Kind implements Declaration.

func (*FuncDecl) Name

func (d *FuncDecl) Name() string

Name implements Declaration.

func (*FuncDecl) String

func (d *FuncDecl) String() string

String implements Declaration.

func (*FuncDecl) Type

func (d *FuncDecl) Type() Type

Type implements Declaration.

func (*FuncDecl) Visibility

func (d *FuncDecl) Visibility() token.Pos

Visibility implements Declaration.

type FunctionType

type FunctionType struct {
	ParameterList ParamTypeList
	ResultList    ParamTypeList

	Variadic bool
	// contains filtered or unexported fields
}

FunctionType represents 'func(Params) Result'.

Example
example(&FunctionType{}, "type T func(int, string) float64")
Output:

&gc.FunctionType{
· ParameterList: &gc.ParamTypeListType{
· · List: []*gc.ParamTypeType{ // len 2
· · · 0: &gc.ParamTypeType{
· · · · Type: &gc.NamedType{
· · · · · Name: "int",
· · · · },
· · · },
· · · 1: &gc.ParamTypeType{
· · · · Type: &gc.NamedType{
· · · · · Name: "string",
· · · · },
· · · },
· · },
· },
· ResultList: &gc.ParamTypeListType{
· · List: []*gc.ParamTypeType{ // len 1
· · · 0: &gc.ParamTypeType{
· · · · Type: &gc.NamedType{
· · · · · Name: "float64",
· · · · },
· · · },
· · },
· },
}

func (*FunctionType) AssignableTo

func (n *FunctionType) AssignableTo(t Type) bool

func (*FunctionType) ComparableWith

func (n *FunctionType) ComparableWith(t Type) (r bool, _ string)

func (*FunctionType) Identical

func (n *FunctionType) Identical(t Type) bool

func (*FunctionType) Implements

func (n *FunctionType) Implements(t Type) (r bool)

func (*FunctionType) IsDefined

func (n *FunctionType) IsDefined() bool

func (*FunctionType) Kind

func (n *FunctionType) Kind() TypeKind

func (*FunctionType) Parameters

func (n *FunctionType) Parameters() Type

Parameters returns the TupleType corresponding to n.ParametersList

func (*FunctionType) Result

func (n *FunctionType) Result() Type

Result returns n's ResultList type as a TupleType or a non-tuple type if n has exactly one result.

func (*FunctionType) String

func (n *FunctionType) String() (r string)

func (*FunctionType) UnderlyingType

func (n *FunctionType) UnderlyingType() Type

type Ident

type Ident struct {
	Token
	// contains filtered or unexported fields
}

Ident represents an identifier and its resolution scope

func (*Ident) Package

func (n *Ident) Package() *Package

func (*Ident) Pos

func (n *Ident) Pos() token.Pos

func (*Ident) Position

func (n *Ident) Position() (r token.Position)

func (*Ident) Scope

func (n *Ident) Scope() *Scope

Scope returns n's resolution scope.

func (*Ident) SourceFile

func (n *Ident) SourceFile() *SourceFile

type IfHeader

type IfHeader interface {
	// contains filtered or unexported methods
}

IfHeader represents data reduced by productions

ifHeader:
	simpleStmtOpt
|	simpleStmtOpt ';' simpleStmtOpt
Example (Assign)
example(&IfHeader2{}, "func foo() { if x = y; z {} }")
Output:

IfHeader: &gc.IfHeader2{
· Stmt: &gc.SimpleStmtAssignment{
· · LHS: []*gc.PrimaryExprIdent{ // len 1
· · · 0: &gc.PrimaryExprIdent{
· · · · Ident: 2:17: "x",
· · · },
· · },
· · RHS: []*gc.PrimaryExprIdent{ // len 1
· · · 0: &gc.PrimaryExprIdent{
· · · · Ident: 2:21: "y",
· · · },
· · },
· },
· Stmt2: &gc.SimpleStmtExpr{
· · Expr: &gc.PrimaryExprIdent{
· · · Ident: 2:24: "z",
· · },
· },
},
Example (Define)
example(&IfHeader2{}, "func foo() { if x := y; z {} }")
Output:

IfHeader: &gc.IfHeader2{
· Stmt: &gc.SimpleStmtDefine{
· · LHS: []*gc.PrimaryExprIdent{ // len 1
· · · 0: &gc.PrimaryExprIdent{
· · · · Ident: 2:17: "x",
· · · },
· · },
· · RHS: []*gc.PrimaryExprIdent{ // len 1
· · · 0: &gc.PrimaryExprIdent{
· · · · Ident: 2:22: "y",
· · · },
· · },
· },
· Stmt2: &gc.SimpleStmtExpr{
· · Expr: &gc.PrimaryExprIdent{
· · · Ident: 2:25: "z",
· · },
· },
},
Example (Simple)
example(&IfHeader1{}, "func foo() { if x {} }")
Output:

IfHeader: &gc.IfHeader1{
· Stmt: &gc.SimpleStmtExpr{
· · Expr: &gc.PrimaryExprIdent{
· · · Ident: 2:17: "x",
· · },
· },
},

type IfHeader1

type IfHeader1 struct {
	Stmt SimpleStmt
	// contains filtered or unexported fields
}

IfHeader1 describes if foo() ...

type IfHeader2

type IfHeader2 struct {
	Stmt  SimpleStmt
	Stmt2 SimpleStmt
	// contains filtered or unexported fields
}

IfHeader2 describes if x := foo(); x > 3 ...

type ImportDecl

type ImportDecl struct {
	ImportPath string // `foo/bar` in `import "foo/bar"`
	Qualifier  string // `baz` in `import baz "foo/bar"`.

	Dot bool // The `import . "foo/bar"` variant is used.
	// contains filtered or unexported fields
}

ImportDecl is an import declaration.

func (*ImportDecl) ImportSpec

func (n *ImportDecl) ImportSpec() *ImportDecl

ImportSpec implements Declaration.

func (*ImportDecl) Kind

func (n *ImportDecl) Kind() DeclarationKind

Kind implements Declaration.

func (*ImportDecl) Name

func (n *ImportDecl) Name() string

Name implements Declaration.

func (*ImportDecl) Package

func (d *ImportDecl) Package() *Package

func (*ImportDecl) String

func (d *ImportDecl) String() string

String implements Declaration.

func (*ImportDecl) Type

func (d *ImportDecl) Type() Type

Type implements Declaration.

func (*ImportDecl) Visibility

func (d *ImportDecl) Visibility() token.Pos

Visibility implements Declaration.

type InterfaceType

type InterfaceType struct {
	Embedded []Type
	Methods  map[string]*FunctionType
	// contains filtered or unexported fields
}

InterfaceType represents 'interface{...}'.

Example
example(&InterfaceType{}, "type T interface{ m(int) string }")
Output:

&gc.InterfaceType{
· Methods: map[string]*gc.FunctionType{
· · "m": &gc.FunctionType{
· · · ParameterList: &gc.ParamTypeListType{
· · · · List: []*gc.ParamTypeType{ // len 1
· · · · · 0: &gc.ParamTypeType{
· · · · · · Type: &gc.NamedType{
· · · · · · · Name: "int",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · ResultList: &gc.ParamTypeListType{
· · · · List: []*gc.ParamTypeType{ // len 1
· · · · · 0: &gc.ParamTypeType{
· · · · · · Type: &gc.NamedType{
· · · · · · · Name: "string",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· },
}

func (*InterfaceType) AssignableTo

func (n *InterfaceType) AssignableTo(t Type) bool

func (*InterfaceType) ComparableWith

func (n *InterfaceType) ComparableWith(t Type) (r bool, _ string)

func (*InterfaceType) Identical

func (n *InterfaceType) Identical(t Type) bool

func (*InterfaceType) Implements

func (n *InterfaceType) Implements(t Type) (r bool)

func (*InterfaceType) IsDefined

func (n *InterfaceType) IsDefined() bool

func (*InterfaceType) Kind

func (n *InterfaceType) Kind() TypeKind

func (*InterfaceType) String

func (n *InterfaceType) String() string

func (*InterfaceType) UnderlyingType

func (n *InterfaceType) UnderlyingType() Type

type InvalidValue

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

InvalidValue represents an invalidValue.

type KeyVal

type KeyVal interface {
	// contains filtered or unexported methods
}

KeyVal represents data reduced by productions

keyVal:
	compLitExpr
|	compLitExpr ':' compLitExpr
Example (Expr)
example(&KeyValExpr{}, "var v = []int{42}")
Output:

0: &gc.KeyValExpr{
· Expr: &gc.CompLitExprExpr{
· · Expr: &gc.PrimaryExprIntLiteral{
· · · Literal: 2:15: "42",
· · },
· },
},
Example (KeyedExpr)
example(&KeyValKeyedExpr{}, "var v = []int{1: 42}")
Output:

0: &gc.KeyValKeyedExpr{
· Key: &gc.CompLitExprExpr{
· · Expr: &gc.PrimaryExprIntLiteral{
· · · Literal: 2:15: "1",
· · },
· },
· Expr: &gc.CompLitExprExpr{
· · Expr: &gc.PrimaryExprIntLiteral{
· · · Literal: 2:18: "42",
· · },
· },
},

type KeyValExpr

type KeyValExpr struct {
	Expr CompLitExpr
	// contains filtered or unexported fields
}

KeyValExpr is a KeyVal

type KeyValKeyedExpr

type KeyValKeyedExpr struct {
	Key  CompLitExpr
	Expr CompLitExpr
	// contains filtered or unexported fields
}

KeyValKeyedExpr is a KeyVal

type MapType

type MapType struct {
	Key   Type
	Value Type
	// contains filtered or unexported fields
}

MapType represents 'map[Key]Value'.

Example
example(&MapType{}, "type T map[int]string")
Output:

&gc.MapType{
· Key: &gc.NamedType{
· · Name: "int",
· },
· Value: &gc.NamedType{
· · Name: "string",
· },
}

func (*MapType) AssignableTo

func (n *MapType) AssignableTo(t Type) bool

func (*MapType) ComparableWith

func (n *MapType) ComparableWith(t Type) (r bool, _ string)

func (*MapType) Identical

func (n *MapType) Identical(t Type) bool

func (*MapType) Implements

func (n *MapType) Implements(t Type) (r bool)

func (*MapType) IsDefined

func (n *MapType) IsDefined() bool

func (*MapType) Kind

func (n *MapType) Kind() TypeKind

func (*MapType) String

func (n *MapType) String() string

func (*MapType) UnderlyingType

func (n *MapType) UnderlyingType() Type

type MethodDecl

type MethodDecl struct {
	Receiver Type
	Body     *StmtBlock
	// contains filtered or unexported fields
}

MethodDecl describes a method declaration.

func (*MethodDecl) IsPtrReceiver

func (d *MethodDecl) IsPtrReceiver() bool

IsPtrReceiver reports whether d's receiver is a pointer.

func (*MethodDecl) Kind

func (d *MethodDecl) Kind() DeclarationKind

Kind implements Declaration.

func (*MethodDecl) Name

func (d *MethodDecl) Name() string

Name implements Declaration.

func (*MethodDecl) String

func (d *MethodDecl) String() string

String implements Declaration.

func (*MethodDecl) Type

func (d *MethodDecl) Type() Type

Type implements Declaration.

func (*MethodDecl) Visibility

func (d *MethodDecl) Visibility() token.Pos

Visibility implements Declaration.

type NamedType

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

NamedType represents 'identifier type'.

Example
example(&NamedType{}, "type T int")
Output:

&gc.NamedType{
· Name: "int",
}

func (*NamedType) AssignableTo

func (n *NamedType) AssignableTo(t Type) bool

func (*NamedType) ComparableWith

func (n *NamedType) ComparableWith(t Type) (r bool, _ string)

func (*NamedType) Declaration

func (n *NamedType) Declaration() *TypeDecl

Declaration returns the declaration of n.

func (*NamedType) Identical

func (n *NamedType) Identical(t Type) bool

func (*NamedType) Implements

func (n *NamedType) Implements(t Type) (r bool)

func (*NamedType) IsDefined

func (n *NamedType) IsDefined() bool

IsDefined implements Type.

func (*NamedType) Kind

func (n *NamedType) Kind() TypeKind

func (*NamedType) Scope

func (n *NamedType) Scope() *Scope

func (*NamedType) String

func (n *NamedType) String() string

func (*NamedType) Type

func (n *NamedType) Type() Type

Type returns U in type T U.

func (*NamedType) UnderlyingType

func (n *NamedType) UnderlyingType() Type

UnderlyingType implements Type.

type Node

type Node interface {
	Package() *Package
	Position() token.Position
	SourceFile() *SourceFile
	String() string
	// contains filtered or unexported methods
}

type Operand

type Operand interface {
	Type() Type
	Value() Value
}

Operand describes operation's operand.

type Option

type Option func(c *Context) error

Option amends Context.

func IgnoreRedeclarations

func IgnoreRedeclarations() Option

IgnoreRedeclarations disables reporting redeclarations as errors.

func LocalImportsPath

func LocalImportsPath(s string) Option

LocalImportsPath sets the relative path for local imports.

func NoErrorColumns

func NoErrorColumns() Option

NoErrorColumns disable displaying of columns in error messages.

func NoErrorLimit

func NoErrorLimit() Option

NoErrorLimit disables limit on number of errors reported.

type Package

type Package struct {
	Dir         string
	ImportPath  string
	ImportedBy  map[string]struct{} // import path: struct{}.
	Imports     map[string]struct{} // import path: struct{}.
	Methods     map[string]Bindings // receiver name: *MethodDecl
	Name        string
	Scope       *Scope // Package scope.
	SourceFiles []*SourceFile
	// contains filtered or unexported fields
}

Package describes a package.

type ParamType

type ParamType interface {
	// contains filtered or unexported methods
}

ParamType represents data reduced by productions

paramType:
	IDENT dddType
|	IDENT typ
|	dddType
|	typ
Example (IdentType)
example(&ParamTypeIdentType{}, "func foo(a int)")
Output:

0: &gc.ParamTypeIdentType{
· Ident: 2:10: "a",
· Type: &gc.NamedType{
· · Name: "int",
· },
},
Example (Type)
example(&ParamTypeType{}, "func foo(int)")
Output:

0: &gc.ParamTypeType{
· Type: &gc.NamedType{
· · Name: "int",
· },
},

type ParamTypeIdentType

type ParamTypeIdentType struct {
	Ident Token
	Type  Type

	Variadic bool
	// contains filtered or unexported fields
}

ParamTypeIdentType is a ParamType that includes the name of the parameter.

type ParamTypeList

type ParamTypeList interface {
	// contains filtered or unexported methods
}

ParamTypeList represents data reduced by productions

paramTypeList:
	paramType
|	paramTypeList ',' paramType
Example (IdentType)
example(ParamTypeListIdentType{}, "func foo(i int, s string)")
Output:

ParameterList: &gc.ParamTypeListIdentType{
· List: []*gc.ParamTypeIdentType{ // len 2
· · 0: &gc.ParamTypeIdentType{
· · · Ident: 2:10: "i",
· · · Type: &gc.NamedType{
· · · · Name: "int",
· · · },
· · },
· · 1: &gc.ParamTypeIdentType{
· · · Ident: 2:17: "s",
· · · Type: &gc.NamedType{
· · · · Name: "string",
· · · },
· · },
· },
},
Example (Type)
example(ParamTypeListType{}, "func foo(int, string)")
Output:

ParameterList: &gc.ParamTypeListType{
· List: []*gc.ParamTypeType{ // len 2
· · 0: &gc.ParamTypeType{
· · · Type: &gc.NamedType{
· · · · Name: "int",
· · · },
· · },
· · 1: &gc.ParamTypeType{
· · · Type: &gc.NamedType{
· · · · Name: "string",
· · · },
· · },
· },
},

type ParamTypeListIdentType

type ParamTypeListIdentType struct {
	List []*ParamTypeIdentType
	// contains filtered or unexported fields
}

ParamTypeListIdentType is a ParamTypeList of ParamTypeIdentType

type ParamTypeListType

type ParamTypeListType struct {
	List []*ParamTypeType
	// contains filtered or unexported fields
}

ParamTypeListType is a ParamTypeList of ParamTypeType

type ParamTypeType

type ParamTypeType struct {
	Type Type

	Variadic bool
	// contains filtered or unexported fields
}

ParamTypeType is a ParamType without a name of the parameter.

type PointerType

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

PointerType represents '*Element'.

Example
example(&PointerType{}, "type T *int")
Output:

&gc.PointerType{
· Element: &gc.NamedType{
· · Name: "int",
· },
}

func (*PointerType) AssignableTo

func (n *PointerType) AssignableTo(t Type) bool

func (*PointerType) ComparableWith

func (n *PointerType) ComparableWith(t Type) (r bool, _ string)

func (*PointerType) Identical

func (n *PointerType) Identical(t Type) bool

func (*PointerType) Implements

func (n *PointerType) Implements(t Type) (r bool)

func (*PointerType) IsDefined

func (n *PointerType) IsDefined() bool

func (*PointerType) Kind

func (n *PointerType) Kind() TypeKind

func (*PointerType) String

func (n *PointerType) String() string

func (*PointerType) UnderlyingType

func (n *PointerType) UnderlyingType() Type

type PrimaryExpr

type PrimaryExpr Expr

PrimaryExpr represents data reduced by productions

primaryExpr:
	'(' exprOrType ')'
|	IDENT genericArgsOpt %prec _NotParen
|	convType '(' expr commaOpt ')'
|	fnType lbrace stmtList '}'
|	literal
|	otherType lbrace bracedKeyValList '}'
|	primaryExpr '(' ')'
|	primaryExpr '(' exprOrTypeList "..." commaOpt ')'
|	primaryExpr '(' exprOrTypeList commaOpt ')'
|	primaryExpr '.' '(' "type" ')'
|	primaryExpr '.' '(' exprOrType ')'
|	primaryExpr '.' IDENT
|	primaryExpr '[' expr ']'
|	primaryExpr '[' exprOpt ':' exprOpt ':' exprOpt ']'
|	primaryExpr '[' exprOpt ':' exprOpt ']'
|	primaryExpr '{' bracedKeyValList '}'
Example (Call)
example(&PrimaryExprCall{}, "var v = foo(42)")
Output:

Initializer: &gc.PrimaryExprCall{
· PrimaryExpr: &gc.PrimaryExprIdent{
· · Ident: 2:9: "foo",
· },
· Args: []*gc.ExprOrTypeExpr{ // len 1
· · 0: &gc.ExprOrTypeExpr{
· · · Expr: &gc.PrimaryExprIntLiteral{
· · · · Literal: 2:13: "42",
· · · },
· · },
· },
},
Example (CompositeLiteral)
example(&PrimaryExprCompositeLiteral{}, "var v = []int{42}")
Output:

Initializer: &gc.PrimaryExprCompositeLiteral{
· List: []*gc.KeyValExpr{ // len 1
· · 0: &gc.KeyValExpr{
· · · Expr: &gc.CompLitExprExpr{
· · · · Expr: &gc.PrimaryExprIntLiteral{
· · · · · Literal: 2:15: "42",
· · · · },
· · · },
· · },
· },
},
Example (Conversion)
example(&PrimaryExprConversion{}, "var v = ([]byte)(nil)")
Output:

Initializer: &gc.PrimaryExprConversion{
· Expr: &gc.PrimaryExprIdent{
· · Ident: 2:18: "nil",
· },
},
Example (FloatLiteral)
example(&PrimaryExprFloatLiteral{}, "var v = 42.314")
Output:

Initializer: &gc.PrimaryExprFloatLiteral{
· Literal: 2:9: "42.314",
},
Example (FullSlice)
example(&PrimaryExprFullSlice{}, "var v = foo[24:42:314]")
Output:

Initializer: &gc.PrimaryExprFullSlice{
· PrimaryExpr: &gc.PrimaryExprIdent{
· · Ident: 2:9: "foo",
· },
· Lo: &gc.PrimaryExprIntLiteral{
· · Literal: 2:13: "24",
· },
· Hi: &gc.PrimaryExprIntLiteral{
· · Literal: 2:16: "42",
· },
· Max: &gc.PrimaryExprIntLiteral{
· · Literal: 2:19: "314",
· },
},
Example (FuncLiteral)
example(&PrimaryExprFuncLiteral{}, "var v = func(){}")
Output:

Initializer: &gc.PrimaryExprFuncLiteral{
· Body: &gc.StmtBlock{
· },
},
Example (Ident)
example(&PrimaryExprIdent{}, "var v = foo")
Output:

Initializer: &gc.PrimaryExprIdent{
· Ident: 2:9: "foo",
},
Example (ImagLiteral)
example(&PrimaryExprImagLiteral{}, "var v = 42i")
Output:

Initializer: &gc.PrimaryExprImagLiteral{
· Literal: 2:9: "42i",
},
Example (Index)
example(&PrimaryExprIndex{}, "var v = foo[42]")
Output:

Initializer: &gc.PrimaryExprIndex{
· PrimaryExpr: &gc.PrimaryExprIdent{
· · Ident: 2:9: "foo",
· },
· Index: &gc.PrimaryExprIntLiteral{
· · Literal: 2:13: "42",
· },
},
Example (IntLiteral)
example(&PrimaryExprIntLiteral{}, "var v = 42")
Output:

Initializer: &gc.PrimaryExprIntLiteral{
· Literal: 2:9: "42",
},
Example (ParenExpr)
example(&PrimaryExprParenExpr{}, "var v = (42)")
Output:

Initializer: &gc.PrimaryExprParenExpr{
· Expr: &gc.PrimaryExprIntLiteral{
· · Literal: 2:10: "42",
· },
},
Example (RuneLiteral)
example(&PrimaryExprRuneLiteral{}, "var v = 'a'")
Output:

Initializer: &gc.PrimaryExprRuneLiteral{
· Literal: 2:9: "'a'",
},
Example (Selector)
example(&PrimaryExprSelector{}, "var v = foo().bar")
Output:

Initializer: &gc.PrimaryExprSelector{
· PrimaryExpr: &gc.PrimaryExprCall{
· · PrimaryExpr: &gc.PrimaryExprIdent{
· · · Ident: 2:9: "foo",
· · },
· },
· Selector: 2:15: "bar",
},
Example (SimpleSlice)
example(&PrimaryExprSimpleSlice{}, "var v = foo[24:42]")
Output:

Initializer: &gc.PrimaryExprSimpleSlice{
· PrimaryExpr: &gc.PrimaryExprIdent{
· · Ident: 2:9: "foo",
· },
· Lo: &gc.PrimaryExprIntLiteral{
· · Literal: 2:13: "24",
· },
· Hi: &gc.PrimaryExprIntLiteral{
· · Literal: 2:16: "42",
· },
},
Example (StringLiteral)
example(&PrimaryExprStringLiteral{}, `var v = "foo"`)
Output:

Initializer: &gc.PrimaryExprStringLiteral{
· Literal: 2:9: "\"foo\"",
},
Example (TypeAssertion)
example(&PrimaryExprTypeAssertion{}, "var v, ok = foo.(int)")
Output:

Initializer: &gc.PrimaryExprTypeAssertion{
· PrimaryExpr: &gc.PrimaryExprIdent{
· · Ident: 2:13: "foo",
· },
· Assert: &gc.ExprOrTypeExpr{
· · Expr: &gc.PrimaryExprIdent{
· · · Ident: 2:18: "int",
· · },
· },
},
Example (TypeSwitchGuard)
example(&PrimaryExprTypeSwitchGuard{}, `
func foo(x interface{}) {
	switch x.(type) {
	case []int:
		foo()
	case [42]string:
		bar()
	default:
		qux()
	}
}	
`)
Output:

Expr: &gc.PrimaryExprTypeSwitchGuard{
· PrimaryExpr: &gc.PrimaryExprIdent{
· · Ident: 4:9: "x",
· },
},

type PrimaryExprCall

type PrimaryExprCall struct {
	PrimaryExpr Expr
	Args        []ExprOrType

	DDD          bool
	IsConversion bool
	// contains filtered or unexported fields
}

PrimaryExprCall is an Expr.

func (*PrimaryExprCall) Package

func (n *PrimaryExprCall) Package() *Package

func (*PrimaryExprCall) Pos

func (n *PrimaryExprCall) Pos() token.Pos

func (*PrimaryExprCall) Position

func (n *PrimaryExprCall) Position() (r token.Position)

func (*PrimaryExprCall) SourceFile

func (n *PrimaryExprCall) SourceFile() *SourceFile

func (*PrimaryExprCall) Type

func (e *PrimaryExprCall) Type() Type

func (*PrimaryExprCall) Value

func (e *PrimaryExprCall) Value() Value

type PrimaryExprCompositeLiteral

type PrimaryExprCompositeLiteral struct {
	List []KeyVal
	// contains filtered or unexported fields
}

PrimaryExprCompositeLiteral is an Expr.

func (*PrimaryExprCompositeLiteral) Package

func (n *PrimaryExprCompositeLiteral) Package() *Package

func (*PrimaryExprCompositeLiteral) Pos

func (n *PrimaryExprCompositeLiteral) Pos() token.Pos

func (*PrimaryExprCompositeLiteral) Position

func (n *PrimaryExprCompositeLiteral) Position() (r token.Position)

func (*PrimaryExprCompositeLiteral) SourceFile

func (n *PrimaryExprCompositeLiteral) SourceFile() *SourceFile

func (*PrimaryExprCompositeLiteral) Type

func (e *PrimaryExprCompositeLiteral) Type() Type

func (*PrimaryExprCompositeLiteral) Value

func (e *PrimaryExprCompositeLiteral) Value() Value

type PrimaryExprConversion

type PrimaryExprConversion struct {
	Expr Expr
	// contains filtered or unexported fields
}

PrimaryExprConversion is an Expr.

func (*PrimaryExprConversion) Package

func (n *PrimaryExprConversion) Package() *Package

func (*PrimaryExprConversion) Pos

func (n *PrimaryExprConversion) Pos() token.Pos

func (*PrimaryExprConversion) Position

func (n *PrimaryExprConversion) Position() (r token.Position)

func (*PrimaryExprConversion) SourceFile

func (n *PrimaryExprConversion) SourceFile() *SourceFile

func (*PrimaryExprConversion) Type

func (e *PrimaryExprConversion) Type() Type

func (*PrimaryExprConversion) Value

func (e *PrimaryExprConversion) Value() Value

type PrimaryExprFloatLiteral

type PrimaryExprFloatLiteral struct {
	Literal Token
	// contains filtered or unexported fields
}

PrimaryExprFloatLiteral is an Expr.

func (*PrimaryExprFloatLiteral) Position

func (n *PrimaryExprFloatLiteral) Position() token.Position

Position implemenst Expr.

func (*PrimaryExprFloatLiteral) Type

func (e *PrimaryExprFloatLiteral) Type() Type

func (*PrimaryExprFloatLiteral) Value

func (e *PrimaryExprFloatLiteral) Value() Value

type PrimaryExprFullSlice

type PrimaryExprFullSlice struct {
	PrimaryExpr Expr
	Lo          Expr
	Hi          Expr
	Max         Expr
	// contains filtered or unexported fields
}

PrimaryExprFullSlice is an Expr.

func (*PrimaryExprFullSlice) Package

func (n *PrimaryExprFullSlice) Package() *Package

func (*PrimaryExprFullSlice) Pos

func (n *PrimaryExprFullSlice) Pos() token.Pos

func (*PrimaryExprFullSlice) Position

func (n *PrimaryExprFullSlice) Position() (r token.Position)

func (*PrimaryExprFullSlice) SourceFile

func (n *PrimaryExprFullSlice) SourceFile() *SourceFile

func (*PrimaryExprFullSlice) Type

func (e *PrimaryExprFullSlice) Type() Type

func (*PrimaryExprFullSlice) Value

func (e *PrimaryExprFullSlice) Value() Value

type PrimaryExprFuncLiteral

type PrimaryExprFuncLiteral struct {
	Body *StmtBlock
	// contains filtered or unexported fields
}

PrimaryExprFuncLiteral is an Expr.

func (*PrimaryExprFuncLiteral) Package

func (n *PrimaryExprFuncLiteral) Package() *Package

func (*PrimaryExprFuncLiteral) Pos

func (n *PrimaryExprFuncLiteral) Pos() token.Pos

func (*PrimaryExprFuncLiteral) Position

func (n *PrimaryExprFuncLiteral) Position() (r token.Position)

func (*PrimaryExprFuncLiteral) SourceFile

func (n *PrimaryExprFuncLiteral) SourceFile() *SourceFile

func (*PrimaryExprFuncLiteral) Type

func (e *PrimaryExprFuncLiteral) Type() Type

func (*PrimaryExprFuncLiteral) Value

func (e *PrimaryExprFuncLiteral) Value() Value

type PrimaryExprIdent

type PrimaryExprIdent struct {
	Ident Ident
	// contains filtered or unexported fields
}

PrimaryExprIdent is an Expr.

func (*PrimaryExprIdent) Position

func (n *PrimaryExprIdent) Position() token.Position

Position implemenst Expr.

func (*PrimaryExprIdent) Type

func (e *PrimaryExprIdent) Type() Type

func (*PrimaryExprIdent) Value

func (e *PrimaryExprIdent) Value() Value

type PrimaryExprImagLiteral

type PrimaryExprImagLiteral struct {
	Literal Token
	// contains filtered or unexported fields
}

PrimaryExprImagLiteral is an Expr.

func (*PrimaryExprImagLiteral) Position

func (n *PrimaryExprImagLiteral) Position() token.Position

Position implemenst Expr.

func (*PrimaryExprImagLiteral) Type

func (e *PrimaryExprImagLiteral) Type() Type

func (*PrimaryExprImagLiteral) Value

func (e *PrimaryExprImagLiteral) Value() Value

type PrimaryExprIndex

type PrimaryExprIndex struct {
	PrimaryExpr Expr
	Index       Expr
	// contains filtered or unexported fields
}

PrimaryExprIndex is an Expr.

func (*PrimaryExprIndex) Package

func (n *PrimaryExprIndex) Package() *Package

func (*PrimaryExprIndex) Pos

func (n *PrimaryExprIndex) Pos() token.Pos

func (*PrimaryExprIndex) Position

func (n *PrimaryExprIndex) Position() (r token.Position)

func (*PrimaryExprIndex) SourceFile

func (n *PrimaryExprIndex) SourceFile() *SourceFile

func (*PrimaryExprIndex) Type

func (e *PrimaryExprIndex) Type() Type

func (*PrimaryExprIndex) Value

func (e *PrimaryExprIndex) Value() Value

type PrimaryExprIntLiteral

type PrimaryExprIntLiteral struct {
	Literal Token
	// contains filtered or unexported fields
}

PrimaryExprIntLiteral is an Expr.

func (*PrimaryExprIntLiteral) Position

func (n *PrimaryExprIntLiteral) Position() token.Position

Position implemenst Expr.

func (*PrimaryExprIntLiteral) Type

func (e *PrimaryExprIntLiteral) Type() Type

func (*PrimaryExprIntLiteral) Value

func (e *PrimaryExprIntLiteral) Value() Value

type PrimaryExprParenExpr

type PrimaryExprParenExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

PrimaryExprParenExpr is an Expr.

func (*PrimaryExprParenExpr) Package

func (n *PrimaryExprParenExpr) Package() *Package

func (*PrimaryExprParenExpr) Pos

func (n *PrimaryExprParenExpr) Pos() token.Pos

func (*PrimaryExprParenExpr) Position

func (n *PrimaryExprParenExpr) Position() (r token.Position)

func (*PrimaryExprParenExpr) SourceFile

func (n *PrimaryExprParenExpr) SourceFile() *SourceFile

func (*PrimaryExprParenExpr) Type

func (e *PrimaryExprParenExpr) Type() Type

func (*PrimaryExprParenExpr) Value

func (e *PrimaryExprParenExpr) Value() Value

type PrimaryExprRuneLiteral

type PrimaryExprRuneLiteral struct {
	Literal Token
	// contains filtered or unexported fields
}

PrimaryExprRuneLiteral is an Expr.

func (*PrimaryExprRuneLiteral) Position

func (n *PrimaryExprRuneLiteral) Position() token.Position

Position implemenst Expr.

func (*PrimaryExprRuneLiteral) Type

func (e *PrimaryExprRuneLiteral) Type() Type

func (*PrimaryExprRuneLiteral) Value

func (e *PrimaryExprRuneLiteral) Value() Value

type PrimaryExprSelector

type PrimaryExprSelector struct {
	PrimaryExpr Expr
	Selector    Ident
	Declaration Declaration // Non-nil if the selector denotes a declaration.
	// contains filtered or unexported fields
}

PrimaryExprSelector is an Expr.

func (*PrimaryExprSelector) Package

func (n *PrimaryExprSelector) Package() *Package

func (*PrimaryExprSelector) Pos

func (n *PrimaryExprSelector) Pos() token.Pos

func (*PrimaryExprSelector) Position

func (n *PrimaryExprSelector) Position() (r token.Position)

func (*PrimaryExprSelector) SourceFile

func (n *PrimaryExprSelector) SourceFile() *SourceFile

func (*PrimaryExprSelector) Type

func (e *PrimaryExprSelector) Type() Type

func (*PrimaryExprSelector) Value

func (e *PrimaryExprSelector) Value() Value

type PrimaryExprSimpleSlice

type PrimaryExprSimpleSlice struct {
	PrimaryExpr Expr
	Lo          Expr
	Hi          Expr
	// contains filtered or unexported fields
}

PrimaryExprSimpleSlice is an Expr.

func (*PrimaryExprSimpleSlice) Package

func (n *PrimaryExprSimpleSlice) Package() *Package

func (*PrimaryExprSimpleSlice) Pos

func (n *PrimaryExprSimpleSlice) Pos() token.Pos

func (*PrimaryExprSimpleSlice) Position

func (n *PrimaryExprSimpleSlice) Position() (r token.Position)

func (*PrimaryExprSimpleSlice) SourceFile

func (n *PrimaryExprSimpleSlice) SourceFile() *SourceFile

func (*PrimaryExprSimpleSlice) Type

func (e *PrimaryExprSimpleSlice) Type() Type

func (*PrimaryExprSimpleSlice) Value

func (e *PrimaryExprSimpleSlice) Value() Value

type PrimaryExprStringLiteral

type PrimaryExprStringLiteral struct {
	Literal Token
	// contains filtered or unexported fields
}

PrimaryExprStringLiteral is an Expr.

func (*PrimaryExprStringLiteral) Position

func (n *PrimaryExprStringLiteral) Position() token.Position

Position implemenst Expr.

func (*PrimaryExprStringLiteral) Type

func (e *PrimaryExprStringLiteral) Type() Type

func (*PrimaryExprStringLiteral) Value

func (e *PrimaryExprStringLiteral) Value() Value

type PrimaryExprTypeAssertion

type PrimaryExprTypeAssertion struct {
	PrimaryExpr Expr
	Assert      ExprOrType
	// contains filtered or unexported fields
}

PrimaryExprTypeAssertion is an Expr.

func (*PrimaryExprTypeAssertion) Package

func (n *PrimaryExprTypeAssertion) Package() *Package

func (*PrimaryExprTypeAssertion) Pos

func (n *PrimaryExprTypeAssertion) Pos() token.Pos

func (*PrimaryExprTypeAssertion) Position

func (n *PrimaryExprTypeAssertion) Position() (r token.Position)

func (*PrimaryExprTypeAssertion) SourceFile

func (n *PrimaryExprTypeAssertion) SourceFile() *SourceFile

func (*PrimaryExprTypeAssertion) Type

func (e *PrimaryExprTypeAssertion) Type() Type

func (*PrimaryExprTypeAssertion) Value

func (e *PrimaryExprTypeAssertion) Value() Value

type PrimaryExprTypeSwitchGuard

type PrimaryExprTypeSwitchGuard struct {
	PrimaryExpr Expr
	// contains filtered or unexported fields
}

PrimaryExprTypeSwitchGuard is an Expr.

func (*PrimaryExprTypeSwitchGuard) Package

func (n *PrimaryExprTypeSwitchGuard) Package() *Package

func (*PrimaryExprTypeSwitchGuard) Pos

func (n *PrimaryExprTypeSwitchGuard) Pos() token.Pos

func (*PrimaryExprTypeSwitchGuard) Position

func (n *PrimaryExprTypeSwitchGuard) Position() (r token.Position)

func (*PrimaryExprTypeSwitchGuard) SourceFile

func (n *PrimaryExprTypeSwitchGuard) SourceFile() *SourceFile

func (*PrimaryExprTypeSwitchGuard) Type

func (e *PrimaryExprTypeSwitchGuard) Type() Type

func (*PrimaryExprTypeSwitchGuard) Value

func (e *PrimaryExprTypeSwitchGuard) Value() Value

type QualifiedNamedType

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

QualifiedNamedType represents 'qualifier.identifier'.

Example
example(&QualifiedNamedType{}, "type T foo.Bar")
Output:

&gc.QualifiedNamedType{
· Qualifier: "foo",
· Name: "Bar",
}

func (*QualifiedNamedType) AssignableTo

func (n *QualifiedNamedType) AssignableTo(t Type) bool

func (*QualifiedNamedType) ComparableWith

func (n *QualifiedNamedType) ComparableWith(t Type) (r bool, _ string)

func (*QualifiedNamedType) Declaration

func (n *QualifiedNamedType) Declaration() *TypeDecl

Declaration returns the declaration of n.

func (*QualifiedNamedType) Identical

func (n *QualifiedNamedType) Identical(t Type) bool

func (*QualifiedNamedType) Implements

func (n *QualifiedNamedType) Implements(t Type) (r bool)

func (*QualifiedNamedType) IsDefined

func (n *QualifiedNamedType) IsDefined() bool

IsDefined implements Type.

func (*QualifiedNamedType) Kind

func (n *QualifiedNamedType) Kind() TypeKind

func (*QualifiedNamedType) Scope

func (n *QualifiedNamedType) Scope() *Scope

func (*QualifiedNamedType) String

func (n *QualifiedNamedType) String() string

func (*QualifiedNamedType) Type

func (n *QualifiedNamedType) Type() Type

Type returns U in type T U.

func (*QualifiedNamedType) UnderlyingType

func (n *QualifiedNamedType) UnderlyingType() Type

UnderlyingType implements Type.

type Scope

type Scope struct {
	Bindings Bindings
	Kind     ScopeKind
	Labels   Bindings
	Parent   *Scope
	Unbound  []Declaration // Declarations named _. TODO needed?
	// contains filtered or unexported fields
}

Scope tracks declarations.

func (*Scope) Lookup

func (s *Scope) Lookup(pkg *Package, fileScope *Scope, nm Token) Declaration

Lookup searches for nm in s or any of its parents. fileScope, if not nil, is searched prior to searching the universe scope when lookup does not find nm in package scope and s belongs to pkg.

type ScopeKind

type ScopeKind int

ScopeKind describe a Scope's Kind.

const (
	UniverseScope ScopeKind = iota
	PackageScope
	FileScope
	BlockScope
)

Values of ScopeKind.

func (ScopeKind) String

func (i ScopeKind) String() string

type SimpleStmt

type SimpleStmt Stmt

SimpleStmt represents data reduced by productions

simpleStmt:
	expr
|	expr "%=" expr
|	expr "&=" expr
|	expr "&^=" expr
|	expr "*=" expr
|	expr "++"
|	expr "+=" expr
|	expr "--"
|	expr "-=" expr
|	expr "/=" expr
|	expr "<<=" expr
|	expr ">>=" expr
|	expr "^=" expr
|	expr "|=" expr
|	exprList ":=" exprList
|	exprList '=' exprList
Example (AddAssign)
example(&SimpleStmtAddAssign{}, "func foo() { a += b }")
Output:

0: &gc.SimpleStmtAddAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:19: "b",
· },
},
Example (AndAssign)
example(&SimpleStmtAndAssign{}, "func foo() { a &= b }")
Output:

0: &gc.SimpleStmtAndAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:19: "b",
· },
},
Example (AndNotAssign)
example(&SimpleStmtAndNotAssign{}, "func foo() { a &^= b }")
Output:

0: &gc.SimpleStmtAndNotAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:20: "b",
· },
},
Example (Assignment)
example(&SimpleStmtAssignment{}, "func foo() { a, b = c, d }")
Output:

0: &gc.SimpleStmtAssignment{
· LHS: []*gc.PrimaryExprIdent{ // len 2
· · 0: &gc.PrimaryExprIdent{
· · · Ident: 2:14: "a",
· · },
· · 1: &gc.PrimaryExprIdent{
· · · Ident: 2:17: "b",
· · },
· },
· RHS: []*gc.PrimaryExprIdent{ // len 2
· · 0: &gc.PrimaryExprIdent{
· · · Ident: 2:21: "c",
· · },
· · 1: &gc.PrimaryExprIdent{
· · · Ident: 2:24: "d",
· · },
· },
},
Example (Assingnment)
example(&SimpleStmtAssignment{}, "func foo() { a, b = c, d }")
Output:

0: &gc.SimpleStmtAssignment{
· LHS: []*gc.PrimaryExprIdent{ // len 2
· · 0: &gc.PrimaryExprIdent{
· · · Ident: 2:14: "a",
· · },
· · 1: &gc.PrimaryExprIdent{
· · · Ident: 2:17: "b",
· · },
· },
· RHS: []*gc.PrimaryExprIdent{ // len 2
· · 0: &gc.PrimaryExprIdent{
· · · Ident: 2:21: "c",
· · },
· · 1: &gc.PrimaryExprIdent{
· · · Ident: 2:24: "d",
· · },
· },
},
Example (Dec)
example(&SimpleStmtDec{}, "func foo() { a-- }")
Output:

0: &gc.SimpleStmtDec{
· Expr: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
},
Example (Decl)
example(&SimpleStmtDecl{}, "func foo() { var a, b int }")
Output:

0: &gc.SimpleStmtDecl{
· List: []*gc.VarDecl{ // len 2
· · 0: &gc.VarDecl{
· · },
· · 1: &gc.VarDecl{
· · },
· },
},
Example (Define)
example(&SimpleStmtDefine{}, "func foo() { a, b := c, d }")
Output:

0: &gc.SimpleStmtDefine{
· LHS: []*gc.PrimaryExprIdent{ // len 2
· · 0: &gc.PrimaryExprIdent{
· · · Ident: 2:14: "a",
· · },
· · 1: &gc.PrimaryExprIdent{
· · · Ident: 2:17: "b",
· · },
· },
· RHS: []*gc.PrimaryExprIdent{ // len 2
· · 0: &gc.PrimaryExprIdent{
· · · Ident: 2:22: "c",
· · },
· · 1: &gc.PrimaryExprIdent{
· · · Ident: 2:25: "d",
· · },
· },
},
Example (Expr)
example(&SimpleStmtExpr{}, "func foo() { bar() }")
Output:

0: &gc.SimpleStmtExpr{
· Expr: &gc.PrimaryExprCall{
· · PrimaryExpr: &gc.PrimaryExprIdent{
· · · Ident: 2:14: "bar",
· · },
· },
},
Example (Inc)
example(&SimpleStmtInc{}, "func foo() { a++ }")
Output:

0: &gc.SimpleStmtInc{
· Expr: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
},
Example (MulAssign)
example(&SimpleStmtMulAssign{}, "func foo() { a *= b }")
Output:

0: &gc.SimpleStmtMulAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:19: "b",
· },
},
Example (OrAssign)
example(&SimpleStmtOrAssign{}, "func foo() { a |= b }")
Output:

0: &gc.SimpleStmtOrAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:19: "b",
· },
},
Example (QuoAssign)
example(&SimpleStmtQuoAssign{}, "func foo() { a /= b }")
Output:

0: &gc.SimpleStmtQuoAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:19: "b",
· },
},
Example (RemAssign)
example(&SimpleStmtRemAssign{}, "func foo() { a %= b }")
Output:

0: &gc.SimpleStmtRemAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:19: "b",
· },
},
Example (Send)
example(&SimpleStmtSend{}, "func f() { a <- b }")
Output:

0: &gc.SimpleStmtSend{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:12: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:17: "b",
· },
},
Example (ShlAssign)
example(&SimpleStmtShlAssign{}, "func foo() { a <<= b }")
Output:

0: &gc.SimpleStmtShlAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:20: "b",
· },
},
Example (ShrAssign)
example(&SimpleStmtShrAssign{}, "func foo() { a >>= b }")
Output:

0: &gc.SimpleStmtShrAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:20: "b",
· },
},
Example (SubAssign)
example(&SimpleStmtSubAssign{}, "func foo() { a -= b }")
Output:

0: &gc.SimpleStmtSubAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:19: "b",
· },
},
Example (XorAssign)
example(&SimpleStmtXorAssign{}, "func foo() { a ^= b }")
Output:

0: &gc.SimpleStmtXorAssign{
· LHS: &gc.PrimaryExprIdent{
· · Ident: 2:14: "a",
· },
· RHS: &gc.PrimaryExprIdent{
· · Ident: 2:19: "b",
· },
},

type SimpleStmtAddAssign

type SimpleStmtAddAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtAddAssign describes expr += expr.

type SimpleStmtAndAssign

type SimpleStmtAndAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtAndAssign describes expr &= expr.

type SimpleStmtAndNotAssign

type SimpleStmtAndNotAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtAndNotAssign describes expr &^= expr.

type SimpleStmtAssignment

type SimpleStmtAssignment struct {
	LHS []Expr
	RHS []Expr
	// contains filtered or unexported fields
}

SimpleStmtAssignment describes exprList = exprList.

type SimpleStmtDec

type SimpleStmtDec struct {
	Expr Expr
	// contains filtered or unexported fields
}

SimpleStmtDec describes expr--.

type SimpleStmtDecl

type SimpleStmtDecl struct {
	List []Declaration
	// contains filtered or unexported fields
}

SimpleStmtDecl describes a list of declarations.

type SimpleStmtDefine

type SimpleStmtDefine struct {
	LHS []Expr
	RHS []Expr
	// contains filtered or unexported fields
}

SimpleStmtDefine describes exprList := exprList.

type SimpleStmtExpr

type SimpleStmtExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

SimpleStmtExpr describes an expresssion statement.

type SimpleStmtInc

type SimpleStmtInc struct {
	Expr Expr
	// contains filtered or unexported fields
}

SimpleStmtInc describes expr++.

type SimpleStmtMulAssign

type SimpleStmtMulAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtMulAssign describes expr *= expr.

type SimpleStmtOrAssign

type SimpleStmtOrAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtOrAssign describes expr |= expr.

type SimpleStmtQuoAssign

type SimpleStmtQuoAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtQuoAssign describes expr /= expr.

type SimpleStmtRemAssign

type SimpleStmtRemAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtRemAssign describes expr %= expr.

type SimpleStmtSend

type SimpleStmtSend struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtSend describes expr <- expr.

type SimpleStmtShlAssign

type SimpleStmtShlAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtShlAssign describes expr <<= expr.

type SimpleStmtShrAssign

type SimpleStmtShrAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtShrAssign describes expr >>= expr.

type SimpleStmtSubAssign

type SimpleStmtSubAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtSubAssign describes expr -= expr.

type SimpleStmtXorAssign

type SimpleStmtXorAssign struct {
	LHS Expr
	RHS Expr
	// contains filtered or unexported fields
}

SimpleStmtXorAssign describes expr ^= expr.

type SliceType

type SliceType struct {
	Element Type
	// contains filtered or unexported fields
}

SliceType represents '[]Element'.

Example
example(&SliceType{}, "type T []int")
Output:

&gc.SliceType{
· Element: &gc.NamedType{
· · Name: "int",
· },
}

func (*SliceType) AssignableTo

func (n *SliceType) AssignableTo(t Type) bool

func (*SliceType) ComparableWith

func (n *SliceType) ComparableWith(t Type) (r bool, _ string)

func (*SliceType) Identical

func (n *SliceType) Identical(t Type) bool

func (*SliceType) Implements

func (n *SliceType) Implements(t Type) (r bool)

func (*SliceType) IsDefined

func (n *SliceType) IsDefined() bool

func (*SliceType) Kind

func (n *SliceType) Kind() TypeKind

func (*SliceType) String

func (n *SliceType) String() string

func (*SliceType) UnderlyingType

func (n *SliceType) UnderlyingType() Type

type SourceFile

type SourceFile struct {
	File          *token.File
	ImportSpecs   []*ImportDecl
	InitFunctions []Declaration
	Package       *Package
	Path          string
	Scope         *Scope // File scope.
	TopLevelDecls []Declaration
	// contains filtered or unexported fields
}

SourceFile describes a source file.

type Stmt

type Stmt interface {
	// contains filtered or unexported methods
}

Stmt represents data reduced by productions

stmt:
|	"break" identOpt
|	"continue" identOpt
|	"defer" primaryExpr
|	"fallthrough"
|	"for" "range" expr loopBody
|	"for" exprList ":=" "range" expr loopBody
|	"for" exprList '=' "range" expr loopBody
|	"for" simpleStmtOpt ';' simpleStmtOpt ';' simpleStmtOpt loopBody
|	"for" simpleStmtOpt loopBody
|	"go" primaryExpr
|	"goto" IDENT
|	"if" ifHeader loopBody elseIfList
|	"if" ifHeader loopBody elseIfList "else" compoundStmt
|	"return"
|	"return" exprList
|	"select" BODY caseBlockList '}'
|	"switch" ifHeader BODY caseBlockList '}'
|	IDENT ':' stmt
|	commonDecl
|	compoundStmt
|	simpleStmt
Example (Block)
example(&StmtBlock{}, `
func foo() {
	{
		foo()
		bar()
	}
}	
`)
Output:

Body: &gc.StmtBlock{
· List: []*gc.StmtBlock{ // len 1
· · 0: &gc.StmtBlock{
· · · List: []*gc.SimpleStmtExpr{ // len 2
· · · · 0: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprCall{
· · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · Ident: 5:3: "foo",
· · · · · · },
· · · · · },
· · · · },
· · · · 1: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprCall{
· · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · Ident: 6:3: "bar",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (Break)
example(&StmtBreak{}, `
func foo() {
out:
	for range expr {
		break out
	}
}
`)
Output:

0: &gc.StmtBreak{
· Label: 6:9: "out",
},
Example (Continue)
example(&StmtContinue{}, `
func foo() {
next:
	for range expr {
		continue next
	}
}
`)
Output:

0: &gc.StmtContinue{
· Label: 6:12: "next",
},
Example (Defer)
example(&StmtDefer{}, "func foo() { defer bar() }")
Output:

0: &gc.StmtDefer{
· Expr: &gc.PrimaryExprCall{
· · PrimaryExpr: &gc.PrimaryExprIdent{
· · · Ident: 2:20: "bar",
· · },
· },
},
Example (Fallthrough)
example(StmtFallthrough{}, `
func foo() {
	switch x {
	case 1:
		fallthrough
	default:
	}
}
`)
Output:

Body: []*gc.StmtFallthrough{ // len 1
},
Example (For)
example(&StmtFor{}, `
func foo() {
	for i := 0; i < 10; i++ {
		bar()
	}
}
`)
Output:

0: &gc.StmtFor{
· Stmt: &gc.SimpleStmtDefine{
· · LHS: []*gc.PrimaryExprIdent{ // len 1
· · · 0: &gc.PrimaryExprIdent{
· · · · Ident: 4:6: "i",
· · · },
· · },
· · RHS: []*gc.PrimaryExprIntLiteral{ // len 1
· · · 0: &gc.PrimaryExprIntLiteral{
· · · · Literal: 4:11: "0",
· · · },
· · },
· },
· Stmt2: &gc.SimpleStmtExpr{
· · Expr: &gc.ExprLSS{
· · · LHS: &gc.PrimaryExprIdent{
· · · · Ident: 4:14: "i",
· · · },
· · · RHS: &gc.PrimaryExprIntLiteral{
· · · · Literal: 4:18: "10",
· · · },
· · },
· },
· Stmt3: &gc.SimpleStmtInc{
· · Expr: &gc.PrimaryExprIdent{
· · · Ident: 4:22: "i",
· · },
· },
· Body: &gc.StmtBlock{
· · List: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 5:3: "bar",
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (ForRange)
example(&StmtForRange{}, `
func foo() {
	for range expr {
		bar()
	}
}
`)
Output:

0: &gc.StmtForRange{
· Expr: &gc.PrimaryExprIdent{
· · Ident: 4:12: "expr",
· },
· Body: &gc.StmtBlock{
· · List: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 5:3: "bar",
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (ForRangeAssign)
example(&StmtForRange{}, `
func foo() {
	for i, v = range expr {
		bar()
	}
}
`)
Output:

0: &gc.StmtForRange{
· ExprList: []*gc.PrimaryExprIdent{ // len 2
· · 0: &gc.PrimaryExprIdent{
· · · Ident: 4:6: "i",
· · },
· · 1: &gc.PrimaryExprIdent{
· · · Ident: 4:9: "v",
· · },
· },
· Expr: &gc.PrimaryExprIdent{
· · Ident: 4:19: "expr",
· },
· Body: &gc.StmtBlock{
· · List: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 5:3: "bar",
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (ForRangeDefine)
example(&StmtForRange{}, `
func foo() {
	for i, v := range expr {
		bar()
	}
}
`)
Output:

0: &gc.StmtForRange{
· ExprList: []*gc.PrimaryExprIdent{ // len 2
· · 0: &gc.PrimaryExprIdent{
· · · Ident: 4:6: "i",
· · },
· · 1: &gc.PrimaryExprIdent{
· · · Ident: 4:9: "v",
· · },
· },
· Expr: &gc.PrimaryExprIdent{
· · Ident: 4:20: "expr",
· },
· Body: &gc.StmtBlock{
· · List: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 5:3: "bar",
· · · · · },
· · · · },
· · · },
· · },
· },
· Define: true,
},
Example (Go)
example(&StmtGo{}, "func foo() { go bar() }")
Output:

0: &gc.StmtGo{
· Expr: &gc.PrimaryExprCall{
· · PrimaryExpr: &gc.PrimaryExprIdent{
· · · Ident: 2:17: "bar",
· · },
· },
},
Example (Goto)
example(&StmtGoto{}, "func foo() { label: goto label }")
Output:

Stmt: &gc.StmtGoto{
· Ident: 2:26: "label",
},
Example (If)
example(&StmtIf{}, `
func foo() {
	if x {
		y()
	}
}	
`)
Output:

0: &gc.StmtIf{
· IfHeader: &gc.IfHeader1{
· · Stmt: &gc.SimpleStmtExpr{
· · · Expr: &gc.PrimaryExprIdent{
· · · · Ident: 4:5: "x",
· · · },
· · },
· },
· Body: &gc.StmtBlock{
· · List: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 5:3: "y",
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (IfAssign)
example(&StmtIf{}, `
func foo() {
	if x, y = bar(); x {
		y()
	}
}	
`)
Output:

0: &gc.StmtIf{
· IfHeader: &gc.IfHeader2{
· · Stmt: &gc.SimpleStmtAssignment{
· · · LHS: []*gc.PrimaryExprIdent{ // len 2
· · · · 0: &gc.PrimaryExprIdent{
· · · · · Ident: 4:5: "x",
· · · · },
· · · · 1: &gc.PrimaryExprIdent{
· · · · · Ident: 4:8: "y",
· · · · },
· · · },
· · · RHS: []*gc.PrimaryExprCall{ // len 1
· · · · 0: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 4:12: "bar",
· · · · · },
· · · · },
· · · },
· · },
· · Stmt2: &gc.SimpleStmtExpr{
· · · Expr: &gc.PrimaryExprIdent{
· · · · Ident: 4:19: "x",
· · · },
· · },
· },
· Body: &gc.StmtBlock{
· · List: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 5:3: "y",
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (IfDefine)
example(&StmtIf{}, `
func foo() {
	if x, y := bar(); x {
		y()
	}
}	
`)
Output:

0: &gc.StmtIf{
· IfHeader: &gc.IfHeader2{
· · Stmt: &gc.SimpleStmtDefine{
· · · LHS: []*gc.PrimaryExprIdent{ // len 2
· · · · 0: &gc.PrimaryExprIdent{
· · · · · Ident: 4:5: "x",
· · · · },
· · · · 1: &gc.PrimaryExprIdent{
· · · · · Ident: 4:8: "y",
· · · · },
· · · },
· · · RHS: []*gc.PrimaryExprCall{ // len 1
· · · · 0: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 4:13: "bar",
· · · · · },
· · · · },
· · · },
· · },
· · Stmt2: &gc.SimpleStmtExpr{
· · · Expr: &gc.PrimaryExprIdent{
· · · · Ident: 4:20: "x",
· · · },
· · },
· },
· Body: &gc.StmtBlock{
· · List: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 5:3: "y",
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (IfElseIf)
example(&StmtIf{}, `
func foo() {
	if x, y := bar(); x {
		y()
	} else if z {
		w()
	}
}	
`)
Output:

0: &gc.StmtIf{
· IfHeader: &gc.IfHeader2{
· · Stmt: &gc.SimpleStmtDefine{
· · · LHS: []*gc.PrimaryExprIdent{ // len 2
· · · · 0: &gc.PrimaryExprIdent{
· · · · · Ident: 4:5: "x",
· · · · },
· · · · 1: &gc.PrimaryExprIdent{
· · · · · Ident: 4:8: "y",
· · · · },
· · · },
· · · RHS: []*gc.PrimaryExprCall{ // len 1
· · · · 0: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 4:13: "bar",
· · · · · },
· · · · },
· · · },
· · },
· · Stmt2: &gc.SimpleStmtExpr{
· · · Expr: &gc.PrimaryExprIdent{
· · · · Ident: 4:20: "x",
· · · },
· · },
· },
· Body: &gc.StmtBlock{
· · List: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 5:3: "y",
· · · · · },
· · · · },
· · · },
· · },
· },
· ElseIf: []gc.ElseIf{ // len 1
· · 0: gc.ElseIf{
· · · IfHeader: &gc.IfHeader1{
· · · · Stmt: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprIdent{
· · · · · · Ident: 6:12: "z",
· · · · · },
· · · · },
· · · },
· · · Body: &gc.StmtBlock{
· · · · List: []*gc.SimpleStmtExpr{ // len 1
· · · · · 0: &gc.SimpleStmtExpr{
· · · · · · Expr: &gc.PrimaryExprCall{
· · · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · · Ident: 7:3: "w",
· · · · · · · },
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (IfElseIfElse)
example(&StmtIf{}, `
func foo() {
	if x, y := bar(); x {
		y()
	} else if z {
		w()
	} else {
		qux()
	}
}	
`)
Output:

0: &gc.StmtIf{
· IfHeader: &gc.IfHeader2{
· · Stmt: &gc.SimpleStmtDefine{
· · · LHS: []*gc.PrimaryExprIdent{ // len 2
· · · · 0: &gc.PrimaryExprIdent{
· · · · · Ident: 4:5: "x",
· · · · },
· · · · 1: &gc.PrimaryExprIdent{
· · · · · Ident: 4:8: "y",
· · · · },
· · · },
· · · RHS: []*gc.PrimaryExprCall{ // len 1
· · · · 0: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 4:13: "bar",
· · · · · },
· · · · },
· · · },
· · },
· · Stmt2: &gc.SimpleStmtExpr{
· · · Expr: &gc.PrimaryExprIdent{
· · · · Ident: 4:20: "x",
· · · },
· · },
· },
· Body: &gc.StmtBlock{
· · List: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 5:3: "y",
· · · · · },
· · · · },
· · · },
· · },
· },
· ElseIf: []gc.ElseIf{ // len 1
· · 0: gc.ElseIf{
· · · IfHeader: &gc.IfHeader1{
· · · · Stmt: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprIdent{
· · · · · · Ident: 6:12: "z",
· · · · · },
· · · · },
· · · },
· · · Body: &gc.StmtBlock{
· · · · List: []*gc.SimpleStmtExpr{ // len 1
· · · · · 0: &gc.SimpleStmtExpr{
· · · · · · Expr: &gc.PrimaryExprCall{
· · · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · · Ident: 7:3: "w",
· · · · · · · },
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· },
· Body2: &gc.StmtBlock{
· · List: []*gc.SimpleStmtExpr{ // len 1
· · · 0: &gc.SimpleStmtExpr{
· · · · Expr: &gc.PrimaryExprCall{
· · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · Ident: 9:3: "qux",
· · · · · },
· · · · },
· · · },
· · },
· },
},
Example (Labeled)
example(&StmtLabeled{}, "func foo() { label: bar() }")
Output:

0: &gc.StmtLabeled{
· Label: 2:14: "label",
· Stmt: &gc.SimpleStmtExpr{
· · Expr: &gc.PrimaryExprCall{
· · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · Ident: 2:21: "bar",
· · · },
· · },
· },
},
Example (Return)
example(&StmtReturn{}, `func foo() (int, string) { return 42, "314" }`)
Output:

0: &gc.StmtReturn{
· ExprList: []*gc.PrimaryExprIntLiteral{ // len 2
· · 0: &gc.PrimaryExprIntLiteral{
· · · Literal: 2:35: "42",
· · },
· · 1: &gc.PrimaryExprStringLiteral{
· · · Literal: 2:39: "\"314\"",
· · },
· },
},
Example (Select)
example(&StmtSelect{}, `
func foo() {
	select {
	case <-a:
		x()
	case <-b:
		y()
	default:
		z()
	}
}	
`)
Output:

0: &gc.StmtSelect{
· List: []gc.CaseBlock{ // len 3
· · 0: gc.CaseBlock{
· · · ExprOrTypeList: []*gc.ExprOrTypeExpr{ // len 1
· · · · 0: &gc.ExprOrTypeExpr{
· · · · · Expr: &gc.PrimaryExprIdent{
· · · · · · Ident: 5:9: "a",
· · · · · },
· · · · },
· · · },
· · · Body: []*gc.SimpleStmtExpr{ // len 1
· · · · 0: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprCall{
· · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · Ident: 6:3: "x",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· · 1: gc.CaseBlock{
· · · ExprOrTypeList: []*gc.ExprOrTypeExpr{ // len 1
· · · · 0: &gc.ExprOrTypeExpr{
· · · · · Expr: &gc.PrimaryExprIdent{
· · · · · · Ident: 7:9: "b",
· · · · · },
· · · · },
· · · },
· · · Body: []*gc.SimpleStmtExpr{ // len 1
· · · · 0: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprCall{
· · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · Ident: 8:3: "y",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· · 2: gc.CaseBlock{
· · · Body: []*gc.SimpleStmtExpr{ // len 1
· · · · 0: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprCall{
· · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · Ident: 10:3: "z",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · Default: true,
· · },
· },
},
Example (Switch)
example(&StmtSwitch{}, `
func foo() {
	switch x := y; 2*y {
	case 42:
		x()
	case 314:
		y()
	default:
		z()
	}
}	
`)
Output:

0: &gc.StmtSwitch{
· IfHeader: &gc.IfHeader2{
· · Stmt: &gc.SimpleStmtDefine{
· · · LHS: []*gc.PrimaryExprIdent{ // len 1
· · · · 0: &gc.PrimaryExprIdent{
· · · · · Ident: 4:9: "x",
· · · · },
· · · },
· · · RHS: []*gc.PrimaryExprIdent{ // len 1
· · · · 0: &gc.PrimaryExprIdent{
· · · · · Ident: 4:14: "y",
· · · · },
· · · },
· · },
· · Stmt2: &gc.SimpleStmtExpr{
· · · Expr: &gc.ExprMUL{
· · · · LHS: &gc.PrimaryExprIntLiteral{
· · · · · Literal: 4:17: "2",
· · · · },
· · · · RHS: &gc.PrimaryExprIdent{
· · · · · Ident: 4:19: "y",
· · · · },
· · · },
· · },
· },
· List: []gc.CaseBlock{ // len 3
· · 0: gc.CaseBlock{
· · · ExprOrTypeList: []*gc.ExprOrTypeExpr{ // len 1
· · · · 0: &gc.ExprOrTypeExpr{
· · · · · Expr: &gc.PrimaryExprIntLiteral{
· · · · · · Literal: 5:7: "42",
· · · · · },
· · · · },
· · · },
· · · Body: []*gc.SimpleStmtExpr{ // len 1
· · · · 0: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprCall{
· · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · Ident: 6:3: "x",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· · 1: gc.CaseBlock{
· · · ExprOrTypeList: []*gc.ExprOrTypeExpr{ // len 1
· · · · 0: &gc.ExprOrTypeExpr{
· · · · · Expr: &gc.PrimaryExprIntLiteral{
· · · · · · Literal: 7:7: "314",
· · · · · },
· · · · },
· · · },
· · · Body: []*gc.SimpleStmtExpr{ // len 1
· · · · 0: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprCall{
· · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · Ident: 8:3: "y",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· · 2: gc.CaseBlock{
· · · Body: []*gc.SimpleStmtExpr{ // len 1
· · · · 0: &gc.SimpleStmtExpr{
· · · · · Expr: &gc.PrimaryExprCall{
· · · · · · PrimaryExpr: &gc.PrimaryExprIdent{
· · · · · · · Ident: 10:3: "z",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · Default: true,
· · },
· },
},

type StmtBlock

type StmtBlock struct {
	List []Stmt
	// contains filtered or unexported fields
}

StmtBlock describes { stmt; stmt2; ... }.

func (*StmtBlock) Scope

func (n *StmtBlock) Scope() *Scope

Scope retruns the scope of the statement block.

type StmtBreak

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

StmtBreak describes break label.

type StmtContinue

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

StmtContinue describes continue label.

type StmtDefer

type StmtDefer struct {
	Expr Expr
	// contains filtered or unexported fields
}

StmtDefer describes defer expr.

type StmtFallthrough

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

StmtFallthrough describes falltrough.

type StmtFor

type StmtFor struct {
	Stmt  SimpleStmt
	Stmt2 SimpleStmt
	Stmt3 SimpleStmt
	Body  *StmtBlock
	// contains filtered or unexported fields
}

StmtFor describes for stmt; stmt2; stmt3 { body }.

type StmtForRange

type StmtForRange struct {
	ExprList []Expr
	Expr     Expr
	Body     *StmtBlock

	Define bool // true: for exprlist := range ..., false: for exprlist = range ...
	// contains filtered or unexported fields
}

StmtForRange describes for i := range expr { body } or the = variant.

type StmtGo

type StmtGo struct {
	Expr Expr
	// contains filtered or unexported fields
}

StmtGo describes go expr.

type StmtGoto

type StmtGoto struct {
	Ident Token
	// contains filtered or unexported fields
}

StmtGoto describes goto ident.

type StmtIf

type StmtIf struct {
	IfHeader IfHeader
	Body     *StmtBlock
	ElseIf   []ElseIf
	Body2    *StmtBlock
	// contains filtered or unexported fields
}

StmtIf descibes if ifHeader body elseIfList else body2

type StmtLabeled

type StmtLabeled struct {
	Label Token
	Stmt  Stmt
	// contains filtered or unexported fields
}

StmtLabeled describes label: stmt.

type StmtReturn

type StmtReturn struct {
	ExprList []Expr
	// contains filtered or unexported fields
}

StmtReturn describes return expr.

type StmtSelect

type StmtSelect struct {
	List []CaseBlock
	// contains filtered or unexported fields
}

StmtSelect describes select {}.

type StmtSwitch

type StmtSwitch struct {
	IfHeader IfHeader
	List     []CaseBlock
	// contains filtered or unexported fields
}

StmtSwitch describes switch {}.

type StructType

type StructType struct {
	Fields []FieldDeclaration
	// contains filtered or unexported fields
}

StructType represents 'struct{...}'.

Example
example(&StructType{}, "type T struct{ i int; s string }")
Output:

&gc.StructType{
· Fields: []*gc.FieldDeclarationNamed{ // len 2
· · 0: &gc.FieldDeclarationNamed{
· · · Name: 2:16: "i",
· · · Type: &gc.NamedType{
· · · · Name: "int",
· · · },
· · },
· · 1: &gc.FieldDeclarationNamed{
· · · Name: 2:23: "s",
· · · Type: &gc.NamedType{
· · · · Name: "string",
· · · },
· · },
· },
}

func (*StructType) AssignableTo

func (n *StructType) AssignableTo(t Type) bool

func (*StructType) ComparableWith

func (n *StructType) ComparableWith(t Type) (r bool, _ string)

func (*StructType) Identical

func (n *StructType) Identical(t Type) bool

func (*StructType) Implements

func (n *StructType) Implements(t Type) (r bool)

func (*StructType) IsDefined

func (n *StructType) IsDefined() bool

func (*StructType) Kind

func (n *StructType) Kind() TypeKind

func (*StructType) String

func (n *StructType) String() string

func (*StructType) UnderlyingType

func (n *StructType) UnderlyingType() Type

type Token

type Token struct {
	Val string
	// contains filtered or unexported fields
}

Token represents the position and value of a token.

func (*Token) Package

func (n *Token) Package() *Package

func (*Token) Pos

func (n *Token) Pos() token.Pos

func (*Token) Position

func (n *Token) Position() (r token.Position)

func (*Token) SourceFile

func (n *Token) SourceFile() *SourceFile

type TupleType

type TupleType struct {
	List []Type
	// contains filtered or unexported fields
}

TupleType represents '(T1, T2, ...)'.

func (*TupleType) AssignableTo

func (n *TupleType) AssignableTo(t Type) bool

func (*TupleType) ComparableWith

func (n *TupleType) ComparableWith(t Type) (r bool, _ string)

func (*TupleType) Identical

func (n *TupleType) Identical(t Type) bool

func (*TupleType) Implements

func (n *TupleType) Implements(t Type) (r bool)

func (*TupleType) IsDefined

func (n *TupleType) IsDefined() bool

func (*TupleType) Kind

func (n *TupleType) Kind() TypeKind

func (*TupleType) String

func (n *TupleType) String() string

func (*TupleType) UnderlyingType

func (n *TupleType) UnderlyingType() Type

type Type

type Type interface {
	//TODO Node
	AssignableTo(Type) bool             //TODO Operand method
	ComparableWith(Type) (bool, string) //TODO Operand method
	Identical(Type) bool
	Implements(Type) bool
	IsDefined() bool
	Kind() TypeKind
	Package() *Package
	Position() token.Position
	SourceFile() *SourceFile
	String() string
	UnderlyingType() Type
	// contains filtered or unexported methods
}

Type represents a Go type.

type TypeDecl

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

TypeDecl describes a type declaration.

func (*TypeDecl) Kind

func (d *TypeDecl) Kind() DeclarationKind

Kind implements Declaration.

func (*TypeDecl) Name

func (d *TypeDecl) Name() string

Name implements Declaration.

func (*TypeDecl) String

func (d *TypeDecl) String() string

String implements Declaration.

func (*TypeDecl) Type

func (d *TypeDecl) Type() Type

Type implements Declaration.

func (*TypeDecl) Visibility

func (d *TypeDecl) Visibility() token.Pos

Visibility implements Declaration.

type TypeKind

type TypeKind byte

TypeKind represents a particular type kind.

const (
	Invalid TypeKind = iota

	Bool
	Complex128
	Complex64
	Float32
	Float64
	Int
	Int16
	Int32
	Int64
	Int8
	String
	Uint
	Uint16
	Uint32
	Uint64
	Uint8
	Uintptr

	UntypedBool
	UntypedComplex
	UntypedFloat
	UntypedInt
	UntypedNil
	UntypedRune
	UntypedString

	BuiltinGenericComplex // U in 'func complex(r, i T) U'.
	BuiltinGenericFloat   // T in 'func complex(r, i T) U'.
	BuiltinGenericInteger // U in 'make(T, ...U)'.
	BuiltinGeneric        // T in 'func make(T)'.
	BuiltinGeneric2       // U in 'func delete(map[T]U)'.

	Array             // [Expr]Element
	Channel           // chan T
	Function          // func(params) result
	Interface         // interface{...}
	Map               // map[T]U
	Pointer           // *T
	QualifiedTypeName // qualifier.ident
	Slice             // []T
	Struct            // struct{...}
	Tuple             // (T1, T2, ...)
	TypeName          // ident

)

TypeKind values.

func (TypeKind) AssignableTo

func (n TypeKind) AssignableTo(t Type) bool

AssignableTo implements Type.

func (TypeKind) ComparableWith

func (n TypeKind) ComparableWith(t Type) (bool, string)

func (TypeKind) Identical

func (n TypeKind) Identical(t Type) bool

Identical implements Type.

func (TypeKind) Implements

func (n TypeKind) Implements(t Type) bool

Implements implements Type.

func (TypeKind) IsDefined

func (n TypeKind) IsDefined() bool

IsDefined implements Type.

func (TypeKind) Kind

func (n TypeKind) Kind() TypeKind

Kind implements Type.

func (TypeKind) Package

func (n TypeKind) Package() *Package

func (TypeKind) Position

func (n TypeKind) Position() (r token.Position)

Position implements Type.

func (TypeKind) SourceFile

func (n TypeKind) SourceFile() *SourceFile

func (TypeKind) String

func (n TypeKind) String() string

func (TypeKind) UnderlyingType

func (n TypeKind) UnderlyingType() Type

UnderlyingType implements Type.

type UnaryExpr

type UnaryExpr Expr

UnaryExpr represents data reduced by productions

unaryExpr:
	"<-" unaryExpr
|	'!' unaryExpr
|	'&' unaryExpr
|	'*' unaryExpr
|	'+' unaryExpr
|	'-' unaryExpr
|	'^' unaryExpr
|	primaryExpr
Example (Addr)
example(&UnaryExprAddr{}, "var v = &foo")
Output:

Initializer: &gc.UnaryExprAddr{
· Expr: &gc.PrimaryExprIdent{
· · Ident: 2:10: "foo",
· },
},
Example (Deref)
example(&UnaryExprDeref{}, "var v = *foo")
Output:

Initializer: &gc.UnaryExprDeref{
· Expr: &gc.PrimaryExprIdent{
· · Ident: 2:10: "foo",
· },
},
Example (Neg)
example(&UnaryExprNeg{}, "var v = -0")
Output:

Initializer: &gc.UnaryExprNeg{
· Expr: &gc.PrimaryExprIntLiteral{
· · Literal: 2:10: "0",
· },
},
Example (Not)
example(&UnaryExprNot{}, "var v = !foo")
Output:

Initializer: &gc.UnaryExprNot{
· Expr: &gc.PrimaryExprIdent{
· · Ident: 2:10: "foo",
· },
},
Example (Pos)
example(&UnaryExprPos{}, "var v = +0")
Output:

Initializer: &gc.UnaryExprPos{
· Expr: &gc.PrimaryExprIntLiteral{
· · Literal: 2:10: "0",
· },
},
Example (Receive)
example(&UnaryExprReceive{}, "var v = <-foo")
Output:

Initializer: &gc.UnaryExprReceive{
· Expr: &gc.PrimaryExprIdent{
· · Ident: 2:11: "foo",
· },
},
Example (Xor)
example(&UnaryExprXor{}, "var v = ^0")
Output:

Initializer: &gc.UnaryExprXor{
· Expr: &gc.PrimaryExprIntLiteral{
· · Literal: 2:10: "0",
· },
},

type UnaryExprAddr

type UnaryExprAddr struct {
	Expr Expr
	// contains filtered or unexported fields
}

UnaryExprAddr is an Expr.

func (*UnaryExprAddr) Package

func (n *UnaryExprAddr) Package() *Package

func (*UnaryExprAddr) Pos

func (n *UnaryExprAddr) Pos() token.Pos

func (*UnaryExprAddr) Position

func (n *UnaryExprAddr) Position() (r token.Position)

func (*UnaryExprAddr) SourceFile

func (n *UnaryExprAddr) SourceFile() *SourceFile

func (*UnaryExprAddr) Type

func (e *UnaryExprAddr) Type() Type

func (*UnaryExprAddr) Value

func (e *UnaryExprAddr) Value() Value

type UnaryExprDeref

type UnaryExprDeref struct {
	Expr Expr
	// contains filtered or unexported fields
}

UnaryExprDeref is an Expr.

func (*UnaryExprDeref) Package

func (n *UnaryExprDeref) Package() *Package

func (*UnaryExprDeref) Pos

func (n *UnaryExprDeref) Pos() token.Pos

func (*UnaryExprDeref) Position

func (n *UnaryExprDeref) Position() (r token.Position)

func (*UnaryExprDeref) SourceFile

func (n *UnaryExprDeref) SourceFile() *SourceFile

func (*UnaryExprDeref) Type

func (e *UnaryExprDeref) Type() Type

func (*UnaryExprDeref) Value

func (e *UnaryExprDeref) Value() Value

type UnaryExprNeg

type UnaryExprNeg struct {
	Expr Expr
	// contains filtered or unexported fields
}

UnaryExprNeg is an Expr.

func (*UnaryExprNeg) Package

func (n *UnaryExprNeg) Package() *Package

func (*UnaryExprNeg) Pos

func (n *UnaryExprNeg) Pos() token.Pos

func (*UnaryExprNeg) Position

func (n *UnaryExprNeg) Position() (r token.Position)

func (*UnaryExprNeg) SourceFile

func (n *UnaryExprNeg) SourceFile() *SourceFile

func (*UnaryExprNeg) Type

func (e *UnaryExprNeg) Type() Type

func (*UnaryExprNeg) Value

func (e *UnaryExprNeg) Value() Value

type UnaryExprNot

type UnaryExprNot struct {
	Expr Expr
	// contains filtered or unexported fields
}

UnaryExprNot is an Expr.

func (*UnaryExprNot) Package

func (n *UnaryExprNot) Package() *Package

func (*UnaryExprNot) Pos

func (n *UnaryExprNot) Pos() token.Pos

func (*UnaryExprNot) Position

func (n *UnaryExprNot) Position() (r token.Position)

func (*UnaryExprNot) SourceFile

func (n *UnaryExprNot) SourceFile() *SourceFile

func (*UnaryExprNot) Type

func (e *UnaryExprNot) Type() Type

func (*UnaryExprNot) Value

func (e *UnaryExprNot) Value() Value

type UnaryExprPos

type UnaryExprPos struct {
	Expr Expr
	// contains filtered or unexported fields
}

UnaryExprPos is an Expr.

func (*UnaryExprPos) Package

func (n *UnaryExprPos) Package() *Package

func (*UnaryExprPos) Pos

func (n *UnaryExprPos) Pos() token.Pos

func (*UnaryExprPos) Position

func (n *UnaryExprPos) Position() (r token.Position)

func (*UnaryExprPos) SourceFile

func (n *UnaryExprPos) SourceFile() *SourceFile

func (*UnaryExprPos) Type

func (e *UnaryExprPos) Type() Type

func (*UnaryExprPos) Value

func (e *UnaryExprPos) Value() Value

type UnaryExprReceive

type UnaryExprReceive struct {
	Expr Expr
	// contains filtered or unexported fields
}

UnaryExprReceive is an Expr.

func (*UnaryExprReceive) Package

func (n *UnaryExprReceive) Package() *Package

func (*UnaryExprReceive) Pos

func (n *UnaryExprReceive) Pos() token.Pos

func (*UnaryExprReceive) Position

func (n *UnaryExprReceive) Position() (r token.Position)

func (*UnaryExprReceive) SourceFile

func (n *UnaryExprReceive) SourceFile() *SourceFile

func (*UnaryExprReceive) Type

func (e *UnaryExprReceive) Type() Type

func (*UnaryExprReceive) Value

func (e *UnaryExprReceive) Value() Value

type UnaryExprXor

type UnaryExprXor struct {
	Expr Expr
	// contains filtered or unexported fields
}

UnaryExprXor is an Expr.

func (*UnaryExprXor) Package

func (n *UnaryExprXor) Package() *Package

func (*UnaryExprXor) Pos

func (n *UnaryExprXor) Pos() token.Pos

func (*UnaryExprXor) Position

func (n *UnaryExprXor) Position() (r token.Position)

func (*UnaryExprXor) SourceFile

func (n *UnaryExprXor) SourceFile() *SourceFile

func (*UnaryExprXor) Type

func (e *UnaryExprXor) Type() Type

func (*UnaryExprXor) Value

func (e *UnaryExprXor) Value() Value

type UntypedBooleanValue

type UntypedBooleanValue struct {
	V bool
	// contains filtered or unexported fields
}

UntypedBooleanValue represents a true/false value.

type UntypedFalse

type UntypedFalse struct{}

UntypedFalse represents a boolean false constant.

func (UntypedFalse) Type

func (UntypedFalse) Type() Type

Type implements Operand.

func (UntypedFalse) Value

func (UntypedFalse) Value() Value

Value implements Operand.

type UntypedIntOperand

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

UntypedIntOperand represents an integer operand.

func (UntypedIntOperand) Type

func (UntypedIntOperand) Type() Type

Type implements Operand.

func (UntypedIntOperand) Value

func (o UntypedIntOperand) Value() Value

Value implements Operand.

type UntypedIntValue

type UntypedIntValue struct {
	V *big.Int
	// contains filtered or unexported fields
}

UntypedIntValue represents an untyped integer.

type UntypedTrue

type UntypedTrue struct{}

UntypedTrue represents a bool true constant.

func (UntypedTrue) Type

func (UntypedTrue) Type() Type

Type implements Operand.

func (UntypedTrue) Value

func (UntypedTrue) Value() Value

Value implements Operand.

type Value

type Value interface {
	// contains filtered or unexported methods
}

Value represents operand's value.

type VarDecl

type VarDecl struct {
	Initializer Expr
	// contains filtered or unexported fields
}

VarDecl describes a variable declaration.

func (*VarDecl) Kind

func (d *VarDecl) Kind() DeclarationKind

Kind implements Declaration.

func (*VarDecl) Name

func (d *VarDecl) Name() string

Name implements Declaration.

func (*VarDecl) String

func (d *VarDecl) String() string

String implements Declaration.

func (*VarDecl) Type

func (d *VarDecl) Type() Type

Type implements Declaration.

func (*VarDecl) Visibility

func (d *VarDecl) Visibility() token.Pos

Visibility implements Declaration.

Jump to

Keyboard shortcuts

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