Documentation
¶
Overview ¶
Package decls provides helpers for creating variable and function declarations.
Index ¶
- Variables
- func NewFunction(name string, overloads ...*checked.Decl_FunctionDecl_Overload) *checked.Decl
- func NewFunctionType(resultType *checked.Type, argTypes ...*checked.Type) *checked.Type
- func NewIdent(name string, t *checked.Type, v *expr.Literal) *checked.Decl
- func NewInstanceOverload(id string, argTypes []*checked.Type, resultType *checked.Type) *checked.Decl_FunctionDecl_Overload
- func NewListType(elem *checked.Type) *checked.Type
- func NewMapType(key *checked.Type, value *checked.Type) *checked.Type
- func NewObjectType(typeName string) *checked.Type
- func NewOverload(id string, argTypes []*checked.Type, resultType *checked.Type) *checked.Decl_FunctionDecl_Overload
- func NewParameterizedInstanceOverload(id string, argTypes []*checked.Type, resultType *checked.Type, ...) *checked.Decl_FunctionDecl_Overload
- func NewParameterizedOverload(id string, argTypes []*checked.Type, resultType *checked.Type, ...) *checked.Decl_FunctionDecl_Overload
- func NewPrimitiveType(primitive checked.Type_PrimitiveType) *checked.Type
- func NewTypeParamType(name string) *checked.Type
- func NewTypeType(nested *checked.Type) *checked.Type
- func NewWellKnownType(wellKnown checked.Type_WellKnownType) *checked.Type
- func NewWrapperType(wrapped *checked.Type) *checked.Type
- type Group
- type Scopes
- func (s *Scopes) AddFunction(fn *checked.Decl)
- func (s *Scopes) AddIdent(decl *checked.Decl)
- func (s *Scopes) FindFunction(name string) *checked.Decl
- func (s *Scopes) FindIdent(name string) *checked.Decl
- func (s *Scopes) FindIdentInScope(name string) *checked.Decl
- func (s *Scopes) Pop()
- func (s *Scopes) Push()
Constants ¶
This section is empty.
Variables ¶
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 ¶
NewFunctionType creates a function invocation contract, typically only used by type-checking steps after overload resolution.
func NewIdent ¶
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 ¶
NewListType generates a new list with elements of a certain type.
func NewMapType ¶
NewMapType generates a new map with typed keys and values.
func NewObjectType ¶
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 ¶
NewTypeParamType creates a type corresponding to a named, contextual parameter.
func NewTypeType ¶
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.
Types ¶
type Scopes ¶
type Scopes struct {
// contains filtered or unexported fields
}