typechecker

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TypeChecker

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

TypeChecker leverages dst/decorator and go/types to infer the expression types. The decorator keeps the mapping between ast.Node and dst.Node while go/types extracts the types. Call check() after instanciation and before calling ofType() or typeOf().

func New

func New(dec *decorator.Decorator) *TypeChecker

newTypeChecker constructs a typeChecker.

func (*TypeChecker) Check

func (tc *TypeChecker) Check(name string, fset *token.FileSet, file *ast.File)

check analyses a target file and stores object types. It must be called at least once before calling ofType or typeOf.

func (TypeChecker) OfType

func (tc TypeChecker) OfType(expr dst.Expr, t string) bool

ofType checks the type of an expression.

func (TypeChecker) TypeOf

func (tc TypeChecker) TypeOf(expr dst.Expr) string

typeOf returns the type of an expression.

Jump to

Keyboard shortcuts

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