typecheck

package
v0.0.0-...-d472ff9 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2018 License: BSD-2-Clause Imports: 22 Imported by: 0

Documentation

Overview

Package typecheck is a Neugram type checker.

Index

Constants

This section is empty.

Variables

View Source
var Universe = &Scope{Objs: universeObjs}

Functions

func IsError

func IsError(t tipe.Type) bool

Types

type Checker

type Checker struct {
	ImportGo func(path string) (*gotypes.Package, error)
	// contains filtered or unexported fields
}

func New

func New(initPkg string) *Checker

func (*Checker) Add

func (c *Checker) Add(s stmt.Stmt) tipe.Type

func (*Checker) Check

func (c *Checker) Check(path string) (*Package, error)

Check typechecks a Neugram package.

func (*Checker) Errs

func (c *Checker) Errs() []error

Errs returns any errors encountered during type checking.

func (*Checker) Ident

func (c *Checker) Ident(e *expr.Ident) *Obj

Ident reports the object an identifier refers to.

func (*Checker) Lookup

func (c *Checker) Lookup(name string) *Obj

func (*Checker) NewScope

func (c *Checker) NewScope() *Checker

NewScope make a copy of Checker with a new, blank current scope. The two checkers share all type checked data.

func (*Checker) Pkg

func (c *Checker) Pkg(path string) *Package

Pkg returns the type-checked Neugram or Go package. If the type checker has not processed the package, nil is returned.

func (*Checker) Type

func (c *Checker) Type(e expr.Expr) (t tipe.Type)

func (*Checker) TypesWithPrefix

func (c *Checker) TypesWithPrefix(prefix string) (res []string)

TypesWithPrefix returns the names of all types currently in scope that start with prefix.

type Obj

type Obj struct {
	Name string
	Kind ObjKind
	Type tipe.Type
	Decl interface{} // *expr.FuncLiteral, *stmt.MethodikDecl, constant.Value, *stmt.TypeDecl, *Package
	Used bool
}

An Obj represents a declared constant, type, variable, or function.

type ObjKind

type ObjKind int
const (
	ObjUnknown ObjKind = iota
	ObjVar
	ObjConst
	ObjPkg
	ObjType
)

func (ObjKind) String

func (o ObjKind) String() string

type Package

type Package struct {
	GoPkg       *gotypes.Package
	Path        string
	Type        *tipe.Package
	Globals     []*Obj
	GlobalNames map[string]*Obj
	Syntax      *syntax.File
}

type Scope

type Scope struct {
	Parent *Scope
	Objs   map[string]*Obj
	// contains filtered or unexported fields
}

func (*Scope) DebugPrint

func (s *Scope) DebugPrint(indent int)

func (*Scope) LookupRec

func (s *Scope) LookupRec(name string) *Obj

Jump to

Keyboard shortcuts

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