typechecker

package
v0.0.0-...-f8c0f81 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2011 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

DEPRECATED PACKAGE - SEE go/types INSTEAD. This package implements typechecking of a Go AST. The result of the typecheck is an augmented AST with object and type information for each identifier.

Index

Constants

View Source
const (
	Bool = iota
	Byte
	Uint
	Int
	Float
	Complex
	Uintptr
	String

	Uint8
	Uint16
	Uint32
	Uint64

	Int8
	Int16
	Int32
	Int64

	Float32
	Float64

	Complex64
	Complex128
)

The list of basic type id's.

Variables

View Source
var BasicTypes = map[uint]string{
	Bool:    "bool",
	Byte:    "byte",
	Uint:    "uint",
	Int:     "int",
	Float:   "float",
	Complex: "complex",
	Uintptr: "uintptr",
	String:  "string",

	Uint8:  "uint8",
	Uint16: "uint16",
	Uint32: "uint32",
	Uint64: "uint64",

	Int8:  "int8",
	Int16: "int16",
	Int32: "int32",
	Int64: "int64",

	Float32: "float32",
	Float64: "float64",

	Complex64:  "complex64",
	Complex128: "complex128",
}
View Source
var Universe *ast.Scope

The Universe scope contains all predeclared identifiers.

Functions

func CheckFile

func CheckFile(fset *token.FileSet, file *ast.File, importer Importer) os.Error

CheckFile typechecks a single file, but otherwise behaves like CheckPackage. If the complete package consists of more than just one file, the file may not typecheck without errors.

func CheckPackage

func CheckPackage(fset *token.FileSet, pkg *ast.Package, importer Importer) os.Error

CheckPackage typechecks a package and augments the AST by setting *ast.Object, *ast.Type, and *ast.Scope fields accordingly. If an importer is provided, it is used to handle imports, otherwise they are ignored (likely leading to typechecking errors).

If errors are reported, the AST may be incompletely augmented (fields may be nil) or contain incomplete object, type, or scope information.

Types

type Form

type Form int

Form describes the form of a type.

const (
	BadType    Form = iota // for error handling
	Unresolved             // type not fully setup
	Basic
	Array
	Struct
	Pointer
	Function
	Method
	Interface
	Slice
	Map
	Channel
	Tuple
)

The list of possible type forms.

func (Form) String

func (form Form) String() string

type Importer

type Importer func(path string) ([]byte, os.Error)

An importer takes an import path and returns the data describing the respective package's exported interface. The data format is TBD.

type Type

type Type struct {
	Form     Form
	Obj      *ast.Object // corresponding type name, or nil
	Scope    *ast.Scope  // fields and methods, always present
	N        uint        // basic type id, array length, number of function results, or channel direction
	Key, Elt *Type       // map key and array, pointer, slice, map or channel element
	Params   *ast.Scope  // function (receiver, input and result) parameters, tuple expressions (results of function calls), or nil
	Expr     ast.Expr    // corresponding AST expression
}

A Type represents a Go type.

func NewType

func NewType(form Form) *Type

NewType creates a new type of a given form.

Jump to

Keyboard shortcuts

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