variable

package
v1.2.23 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var (
	// CONTEXT defines the type of "contextual" variables.
	CONTEXT = Kind(1)
	// PARAMETER defines the type of parameter variables.
	PARAMETER = Kind(2)
	// RETURN defines the type of return variables.
	RETURN = Kind(3)
	// LOCAL defines the type of local variables.
	LOCAL = Kind(4)
)

Functions

func DescriptorsToType

func DescriptorsToType[S symbol.Symbol[S]](vars ...Descriptor[S]) data.Type[S]

DescriptorsToType construct a single type representing a given set of variable descriptors.

Types

type Descriptor

type Descriptor[S symbol.Symbol[S]] struct {
	// Kind of variable (parameter, return, local, external)
	Kind Kind
	// Name of the variable
	Name string
	// Type of the variable
	DataType data.Type[S]
}

Descriptor describes a variable used within a function (or other component), such as a parameter, return or local variable. A descriptor contains all the key information about a variable, such as its name, type, etc.

func New

func New[S symbol.Symbol[S]](kind Kind, name string, datatype data.Type[S]) Descriptor[S]

New constructs a new variable declaration for a given kind of variable.

func (Descriptor[S]) IsLocal

func (p Descriptor[S]) IsLocal() bool

IsLocal indicates whether or not this is a local variable.

func (Descriptor[S]) IsParameter

func (p Descriptor[S]) IsParameter() bool

IsParameter indicates whether or not this variable is function parameter.

func (Descriptor[S]) IsReturn

func (p Descriptor[S]) IsReturn() bool

IsReturn indicates whether or not this variable is function return.

type Id

type Id = uint

Id is a convenient alias to help clarity a given variable's intended purpose.

type Kind

type Kind uint8

Kind determines the type of a given variable (e.g. a parameter, return, etc).

type Map

type Map[S symbol.Symbol[S]] interface {
	// Get the descriptor for a given variable.
	Variable(Id) Descriptor[S]
}

Map defines an abstract notion of mapping a variable identifier to a variable description.

func ArrayMap

func ArrayMap[S symbol.Symbol[S]](vars ...Descriptor[S]) Map[S]

ArrayMap constructs a variable map from an array of variables.

type ResolvedDescriptor

type ResolvedDescriptor = Descriptor[symbol.Resolved]

ResolvedDescriptor represents a resolved variable descriptor. That is, one whose types contains only resolved symbols.

type UnresolvedDescriptor

type UnresolvedDescriptor = Descriptor[symbol.Unresolved]

UnresolvedDescriptor represents am unresolved variable descriptor. That is, one whose type may contain unresolved symbols.

Jump to

Keyboard shortcuts

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