kmgGoParser

package
v0.0.0-...-05317bf Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustReadGoString

func MustReadGoString(r *kmgGoReader.Reader) (output []byte)

可以读这两种 "abc" `abc` ,返回这个东西实际存放的信息.

func MustWriteGoTypes

func MustWriteGoTypes(thisPackagePath string, typi Type) (s string, addPkgPathList []string)

Types

type ArrayType

type ArrayType struct {
	Size int
	Elem Type
}

TODO finish it

func (ArrayType) GetKind

func (t ArrayType) GetKind() Kind

type BuiltinType

type BuiltinType string

内置的,没有package前缀的类型.

func (BuiltinType) GetKind

func (t BuiltinType) GetKind() Kind

func (BuiltinType) String

func (t BuiltinType) String() string

type ChanDir

type ChanDir int
const (
	RecvDir ChanDir             = 1 << iota // <-chan
	SendDir                                 // chan<-
	BothDir = RecvDir | SendDir             // chan
)

type ChanType

type ChanType struct {
	Dir  ChanDir
	Elem Type
}

func (ChanType) GetKind

func (t ChanType) GetKind() Kind

type File

type File struct {
	PackageName    string //最开头的package上面写的东西.
	PackagePath    string
	ImportMap      map[string]bool //这个文件的导入表
	AliasImportMap map[string]string
	FuncList       []*FuncOrMethodDeclaration
	MethodList     []*FuncOrMethodDeclaration
	NamedTypeList  []*NamedType
	Pkg            *Package
}

表示一个go的file

func (*File) AddImport

func (pkg *File) AddImport(pkgPath string, aliasPath string)

func (*File) LookupFullPackagePath

func (gofile *File) LookupFullPackagePath(pkgAliasPath string) (string, error)

type FuncOrMethodDeclaration

type FuncOrMethodDeclaration struct {
	Name         string
	ReceiverType Type
	InParameter  []FuncParameter
	OutParameter []FuncParameter
}

func (*FuncOrMethodDeclaration) GetKind

func (t *FuncOrMethodDeclaration) GetKind() Kind

func (*FuncOrMethodDeclaration) IsExport

func (t *FuncOrMethodDeclaration) IsExport() bool

type FuncParameter

type FuncParameter struct {
	Name       string
	Type       Type
	IsVariadic bool //是否有3个点
}

type FuncType

type FuncType struct {
	InParameter  []FuncParameter
	OutParameter []FuncParameter
}

TODO finish it.

func (FuncType) GetKind

func (t FuncType) GetKind() Kind

type InterfaceType

type InterfaceType struct {
}

func (InterfaceType) GetKind

func (t InterfaceType) GetKind() Kind

type Kind

type Kind uint
const (
	Invalid Kind = iota
	Bool
	Int
	Int8
	Int16
	Int32
	Int64
	Uint
	Uint8
	Uint16
	Uint32
	Uint64
	Uintptr
	Float32
	Float64
	Complex64
	Complex128
	Array
	Chan
	Func
	Interface
	Map
	Ptr
	Slice
	String
	Struct
	UnsafePointer
	Method
	Named
)

func (Kind) String

func (k Kind) String() string

type MapType

type MapType struct {
	Key   Type
	Value Type
}

func (MapType) GetKind

func (t MapType) GetKind() Kind

type NamedType

type NamedType struct {
	PackagePath string
	Name        string

	Pkg *Package
	// contains filtered or unexported fields
}

func (*NamedType) GetKind

func (t *NamedType) GetKind() Kind

func (*NamedType) GetUnderType

func (t *NamedType) GetUnderType() Type

type Package

type Package struct {
	Program       *Program
	PkgPath       string
	ImportMap     map[string]bool //这个package第一层import
	FuncList      []*FuncOrMethodDeclaration
	MethodList    []*FuncOrMethodDeclaration
	NamedTypeList []*NamedType
}

表示一个package,注意: 一个目录下最多会有2个package.暂时忽略xxx_test 这种package

func MustParsePackage

func MustParsePackage(gopath string, pkgPath string) *Package

暂时忽略任何测试包. 此处不做编译检查,认为所有输入的go文件都是正常的.

func (*Package) AddImport

func (pkg *Package) AddImport(pkgPath string)

func (*Package) GetImportList

func (pkg *Package) GetImportList() []string

func (*Package) GetNamedTypeMethodSet

func (pkg *Package) GetNamedTypeMethodSet(typ *NamedType) (output []*FuncOrMethodDeclaration)

func (*Package) LookupNamedType

func (pkg *Package) LookupNamedType(name string) *NamedType

type PointerType

type PointerType struct {
	Elem Type
}

func NewPointer

func NewPointer(elem Type) PointerType

func (PointerType) GetKind

func (t PointerType) GetKind() Kind

type Program

type Program struct {
	PackageLookupPathList []string            // GOPATH, GOROOT
	CachedPackageMap      map[string]*Package // pkgPath
	// contains filtered or unexported fields
}

表示整个程序

func NewProgram

func NewProgram(lookupPathList []string) *Program

func NewProgramFromDefault

func NewProgramFromDefault() *Program

func (*Program) GetNamedType

func (prog *Program) GetNamedType(pkgPath string, name string) *NamedType

func (*Program) GetPackage

func (prog *Program) GetPackage(pkgPath string) *Package

type SliceType

type SliceType struct {
	Elem Type
}

func (SliceType) GetKind

func (t SliceType) GetKind() Kind

type StringType

type StringType struct {
}

type StructField

type StructField struct {
	Name             string
	Elem             Type
	IsAnonymousField bool
	Tag              string
}

type StructType

type StructType struct {
	Field []StructField
}

TODO finish it

func (StructType) GetKind

func (t StructType) GetKind() Kind

type Type

type Type interface {
	GetKind() Kind
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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