decls

package
v0.0.0-...-97dcd37 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package decls provides helpers for creating variable and function declarations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error type used to communicate issues during type-checking.
	Error = &checked.Type{
		TypeKind: &checked.Type_Error{
			Error: &empty.Empty{}}}

	// Dyn is a top-type used to represent any value.
	Dyn = &checked.Type{
		TypeKind: &checked.Type_Dyn{
			Dyn: &empty.Empty{}}}

	// Commonly used types.
	Bool   = NewPrimitiveType(checked.Type_BOOL)
	Bytes  = NewPrimitiveType(checked.Type_BYTES)
	Double = NewPrimitiveType(checked.Type_DOUBLE)
	Int    = NewPrimitiveType(checked.Type_INT64)
	Null   = &checked.Type{
		TypeKind: &checked.Type_Null{
			Null: structpb.NullValue_NULL_VALUE}}
	String = NewPrimitiveType(checked.Type_STRING)
	Uint   = NewPrimitiveType(checked.Type_UINT64)

	// Well-known types.
	// TODO: Replace with an abstract type registry.
	Any       = NewWellKnownType(checked.Type_ANY)
	Duration  = NewWellKnownType(checked.Type_DURATION)
	Timestamp = NewWellKnownType(checked.Type_TIMESTAMP)
)

Functions

func NewFunction

func NewFunction(name string,
	overloads ...*checked.Decl_FunctionDecl_Overload) *checked.Decl

NewFunction creates a named function declaration with one or more overloads.

func NewFunctionType

func NewFunctionType(resultType *checked.Type,
	argTypes ...*checked.Type) *checked.Type

NewFunctionType creates a function invocation contract, typically only used by type-checking steps after overload resolution.

func NewIdent

func NewIdent(name string, t *checked.Type, v *expr.Literal) *checked.Decl

NewIdent creates a named identifier declaration with an optional literal value.

Literal values are typically only associated with enum identifiers.

func NewInstanceOverload

func NewInstanceOverload(id string, argTypes []*checked.Type,
	resultType *checked.Type) *checked.Decl_FunctionDecl_Overload

NewInstanceOverload creates a instance function overload contract.

func NewListType

func NewListType(elem *checked.Type) *checked.Type

NewListType generates a new list with elements of a certain type.

func NewMapType

func NewMapType(key *checked.Type, value *checked.Type) *checked.Type

NewMapType generates a new map with typed keys and values.

func NewObjectType

func NewObjectType(typeName string) *checked.Type

NewObjectType creates an object type for a qualified type name.

func NewOverload

func NewOverload(id string, argTypes []*checked.Type,
	resultType *checked.Type) *checked.Decl_FunctionDecl_Overload

NewOverload creates a function overload declaration which contains a unique overload id as well as the expected argument and result types. Overloads must be aggregated within a Function declaration.

func NewParameterizedInstanceOverload

func NewParameterizedInstanceOverload(id string,
	argTypes []*checked.Type,
	resultType *checked.Type,
	typeParams []string) *checked.Decl_FunctionDecl_Overload

NewParameterizedOverload creates a parametric function instance overload type.

func NewParameterizedOverload

func NewParameterizedOverload(id string,
	argTypes []*checked.Type,
	resultType *checked.Type,
	typeParams []string) *checked.Decl_FunctionDecl_Overload

NewParameterizedOverload creates a parametric function overload type.

func NewPrimitiveType

func NewPrimitiveType(primitive checked.Type_PrimitiveType) *checked.Type

NewPrimitiveType creates a type for a primitive value. See the var declarations for Int, Uint, etc.

func NewTypeParamType

func NewTypeParamType(name string) *checked.Type

NewTypeParamType creates a type corresponding to a named, contextual parameter.

func NewTypeType

func NewTypeType(nested *checked.Type) *checked.Type

NewTypeType creates a new type designating a type.

func NewWellKnownType

func NewWellKnownType(wellKnown checked.Type_WellKnownType) *checked.Type

NewWellKnownType creates a type corresponding to a protobuf well-known type value.

func NewWrapperType

func NewWrapperType(wrapped *checked.Type) *checked.Type

NewWrapperType creates a wrapped primitive type instance. Wrapped types are roughly equivalent to a nullable, or optionally valued type.

Types

type Group

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

type Scopes

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

func NewScopes

func NewScopes() *Scopes

func (*Scopes) AddFunction

func (s *Scopes) AddFunction(fn *checked.Decl)

func (*Scopes) AddIdent

func (s *Scopes) AddIdent(decl *checked.Decl)

func (*Scopes) FindFunction

func (s *Scopes) FindFunction(name string) *checked.Decl

func (*Scopes) FindIdent

func (s *Scopes) FindIdent(name string) *checked.Decl

func (*Scopes) FindIdentInScope

func (s *Scopes) FindIdentInScope(name string) *checked.Decl

func (*Scopes) Pop

func (s *Scopes) Pop()

func (*Scopes) Push

func (s *Scopes) Push()

Jump to

Keyboard shortcuts

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