Documentation ¶
Overview ¶
Package gc is a Go compiler front end. Work in progess.
Index ¶
- func VersionTags() []string
- type Bindings
- type ConstDecl
- func (d *ConstDecl) Const() *ConstDecl
- func (d *ConstDecl) Func() *FuncDecl
- func (d *ConstDecl) ImportSpec() *ImportSpec
- func (d *ConstDecl) Kind() DeclarationKind
- func (d *ConstDecl) Method() *MethodDecl
- func (d *ConstDecl) Name() string
- func (d *ConstDecl) Pos() token.Pos
- func (d *ConstDecl) Type() *TypeDecl
- func (d *ConstDecl) Var() *VarDecl
- func (d *ConstDecl) Visibility() token.Pos
- type Context
- type Declaration
- type DeclarationKind
- type FuncDecl
- func (d *FuncDecl) Const() *ConstDecl
- func (d *FuncDecl) Func() *FuncDecl
- func (d *FuncDecl) ImportSpec() *ImportSpec
- func (d *FuncDecl) Kind() DeclarationKind
- func (d *FuncDecl) Method() *MethodDecl
- func (d *FuncDecl) Name() string
- func (d *FuncDecl) Pos() token.Pos
- func (d *FuncDecl) Type() *TypeDecl
- func (d *FuncDecl) Var() *VarDecl
- func (d *FuncDecl) Visibility() token.Pos
- type ImportSpec
- func (d *ImportSpec) Const() *ConstDecl
- func (d *ImportSpec) Func() *FuncDecl
- func (n *ImportSpec) ImportSpec() *ImportSpec
- func (n *ImportSpec) Kind() DeclarationKind
- func (d *ImportSpec) Method() *MethodDecl
- func (n *ImportSpec) Name() string
- func (d *ImportSpec) Pos() token.Pos
- func (d *ImportSpec) Type() *TypeDecl
- func (d *ImportSpec) Var() *VarDecl
- func (d *ImportSpec) Visibility() token.Pos
- type Lexer
- type MethodDecl
- func (d *MethodDecl) Const() *ConstDecl
- func (d *MethodDecl) Func() *FuncDecl
- func (d *MethodDecl) ImportSpec() *ImportSpec
- func (d *MethodDecl) Kind() DeclarationKind
- func (d *MethodDecl) Method() *MethodDecl
- func (d *MethodDecl) Name() string
- func (d *MethodDecl) Pos() token.Pos
- func (d *MethodDecl) Type() *TypeDecl
- func (d *MethodDecl) Var() *VarDecl
- func (d *MethodDecl) Visibility() token.Pos
- type Node
- type Option
- type Package
- type Scope
- type ScopeKind
- type SourceFile
- type Token
- type TypeDecl
- func (d *TypeDecl) Const() *ConstDecl
- func (d *TypeDecl) Func() *FuncDecl
- func (d *TypeDecl) ImportSpec() *ImportSpec
- func (d *TypeDecl) Kind() DeclarationKind
- func (d *TypeDecl) Method() *MethodDecl
- func (d *TypeDecl) Name() string
- func (d *TypeDecl) Pos() token.Pos
- func (d *TypeDecl) Type() *TypeDecl
- func (d *TypeDecl) Var() *VarDecl
- func (d *TypeDecl) Visibility() token.Pos
- type VarDecl
- func (d *VarDecl) Const() *ConstDecl
- func (d *VarDecl) Func() *FuncDecl
- func (d *VarDecl) ImportSpec() *ImportSpec
- func (d *VarDecl) Kind() DeclarationKind
- func (d *VarDecl) Method() *MethodDecl
- func (d *VarDecl) Name() string
- func (d *VarDecl) Pos() token.Pos
- func (d *VarDecl) Type() *TypeDecl
- func (d *VarDecl) Var() *VarDecl
- func (d *VarDecl) Visibility() token.Pos
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VersionTags ¶
func VersionTags() []string
VersionTags returns
[]string{"go1.1", "go1.2", "go1.3", "go1.4", "go1.5", "go1.6", "go1.7", "go1.8", "go1.9"}
Types ¶
type ConstDecl ¶
type ConstDecl struct {
// contains filtered or unexported fields
}
ConstDecl describes a constant declaration.
func (*ConstDecl) ImportSpec ¶
func (d *ConstDecl) ImportSpec() *ImportSpec
ImportSpec implements Declaration.
func (*ConstDecl) Visibility ¶
Visibility implements Declaration.
type Context ¶
type Context struct { FileSet *ftoken.FileSet // Contains all loaded files. // 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.org/pkg/go/build/#hdr-Build_Constraints for details). searchPaths are examined when looking for a package to load.
func (*Context) Load ¶
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 ¶
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 { Node // Const returns the Declaration's *ConstDecl. It panics if Kind is not // ConstDeclaration. Const() *ConstDecl // Func returns the Declaration's *FuncDecl. It panics if Kind is not // FuncDeclaration. Func() *FuncDecl // ImportSpec returns the Declaration's *ImportSpec. It panics if Kind // is not ImportDeclaration. ImportSpec() *ImportSpec // Kind returns the Declarations's kind. Kind() DeclarationKind // Method returns the Declaration's *MethodDecl. It panics if Kind is // not MethodDeclaration. Method() *MethodDecl // Name returns the declared name. Name() string // Type returns the Declaration's *TypeDecl. It panics if Kind is not // TypeDeclaration. Type() *TypeDecl // Var returns the Declaration's *VarDecl. It panics if Kind is not // VarDeclaration. Var() *VarDecl // 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 }
Declaration describes a constant, function, method, type or variable declaration.
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 FuncDecl ¶
type FuncDecl struct {
// contains filtered or unexported fields
}
FuncDecl describes a function declaration.
func (*FuncDecl) ImportSpec ¶
func (d *FuncDecl) ImportSpec() *ImportSpec
ImportSpec implements Declaration.
func (*FuncDecl) Visibility ¶
Visibility implements Declaration.
type ImportSpec ¶
type ImportSpec struct { Dot bool // The `import . "foo/bar"` variant is used. ImportPath string // `foo/bar` in `import "foo/bar"` Package *Package // The imported package, if exists. Qualifier string // `baz` in `import baz "foo/bar"`. // contains filtered or unexported fields }
ImportSpec is an import declaration.
func (*ImportSpec) ImportSpec ¶
func (n *ImportSpec) ImportSpec() *ImportSpec
ImportSpec implements Declaration.
func (*ImportSpec) Method ¶
func (d *ImportSpec) Method() *MethodDecl
Method implements Declaration.
func (*ImportSpec) Visibility ¶
Visibility implements Declaration.
type Lexer ¶
type Lexer struct { CommentHandler func(off int32, lit []byte) // contains filtered or unexported fields }
Lexer tokenizes source code.
type MethodDecl ¶
type MethodDecl struct {
// contains filtered or unexported fields
}
MethodDecl describes a method declaration.
func (*MethodDecl) ImportSpec ¶
func (d *MethodDecl) ImportSpec() *ImportSpec
ImportSpec implements Declaration.
func (*MethodDecl) Method ¶
func (d *MethodDecl) Method() *MethodDecl
Method implements Declaration.
func (*MethodDecl) Visibility ¶
Visibility implements Declaration.
type Option ¶
Option amends Context.
func DeclarationXref ¶
func DeclarationXref() Option
DeclarationXref enables keeping a declaration cross reference.
func IgnoreRedeclarations ¶
func IgnoreRedeclarations() Option
IgnoreRedeclarations disables reporting redeclarations as errors.
type Package ¶
type Package struct { Dir string ImportPath string ImportedBy map[string]struct{} // R/O, key: import path. Imports map[string]struct{} // R/O, key: import path. Name string Scope *Scope // Package scope. SourceFiles []*SourceFile // contains filtered or unexported fields }
Package describes a package.
type Scope ¶
type Scope struct { Bindings Bindings Kind ScopeKind Labels Bindings Parent *Scope Unbound []Declaration // Declarations named _. // contains filtered or unexported fields }
Scope tracks declarations.
type SourceFile ¶
type SourceFile struct { File *ftoken.File ImportSpecs []*ImportSpec InitFunctions []Declaration Package *Package Path string Scope *Scope // File scope. TopLevelDecls []Declaration Xref map[token.Pos]token.Pos // Identifier position: declaration position. Xref0 map[Token]*Scope // Token: Resolution scope. Enabled by DeclarationXref. // contains filtered or unexported fields }
SourceFile describes a source file.
type TypeDecl ¶
type TypeDecl struct {
// contains filtered or unexported fields
}
TypeDecl describes a type declaration.
func (*TypeDecl) ImportSpec ¶
func (d *TypeDecl) ImportSpec() *ImportSpec
ImportSpec implements Declaration.
func (*TypeDecl) Visibility ¶
Visibility implements Declaration.
type VarDecl ¶
type VarDecl struct {
// contains filtered or unexported fields
}
VarDecl describes a variable declaration.
func (*VarDecl) ImportSpec ¶
func (d *VarDecl) ImportSpec() *ImportSpec
ImportSpec implements Declaration.
func (*VarDecl) Visibility ¶
Visibility implements Declaration.