ast

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 10 Imported by: 15

Documentation

Overview

Package ast contains all AST nodes for Cadence. All AST nodes implement the Element interface, so have position information and can be traversed using the Visitor interface. Elements also implement the json.Marshaler interface so can be serialized to a standardized/stable JSON format.

Index

Constants

View Source
const NilConstant = "nil"
View Source
const ResourceDestructionDefaultEventName = "ResourceDestroyed"

Variables

View Source
var EmptyPosition = Position{}
View Source
var EmptyRange = Range{}

Functions

func AcceptDeclaration

func AcceptDeclaration[T any](declaration Declaration, visitor DeclarationVisitor[T]) (_ T)

func AcceptExpression

func AcceptExpression[T any](expression Expression, visitor ExpressionVisitor[T]) (_ T)

func AcceptStatement

func AcceptStatement[T any](statement Statement, visitor StatementVisitor[T]) (_ T)

func CompositeDocument

func CompositeDocument(
	access Access,
	kind common.CompositeKind,
	isInterface bool,
	identifier string,
	conformances []*NominalType,
	members *Members,
) prettier.Doc

func ConditionKindCount

func ConditionKindCount() int

func FunctionDocument

func FunctionDocument(
	access Access,
	purity FunctionPurity,
	isStatic bool,
	isNative bool,
	includeKeyword bool,
	identifier string,
	typeParameterList *TypeParameterList,
	parameterList *ParameterList,
	returnTypeAnnotation *TypeAnnotation,
	block *FunctionBlock,
) prettier.Doc

func Inspect

func Inspect(element Element, f func(Element) bool)

func IsEmptyType

func IsEmptyType(t Type) bool

func IsResourceDestructionDefaultEvent

func IsResourceDestructionDefaultEvent(identifier string) bool

func LocationDoc

func LocationDoc(location common.Location) prettier.Doc

func OperationCount

func OperationCount() int

func Prettier

func Prettier(element interface{ Doc() prettier.Doc }) string

func PrimitiveAccessCount

func PrimitiveAccessCount() int

func QuoteString

func QuoteString(s string) string

func RangeContains

func RangeContains(memoryGauge common.MemoryGauge, a, b HasPosition) bool

func StatementsDoc

func StatementsDoc(statements []Statement) prettier.Doc

func TransferOperationCount

func TransferOperationCount() int

func VariableKindCount

func VariableKindCount() int

func VariableKindDoc

func VariableKindDoc(kind VariableKind) prettier.Doc

func Walk

func Walk(walker Walker, element Element)

Walk traverses an AST in depth-first order: It starts by calling walker.Walk(element); If the returned walker is nil, child elements are not walked. If the returned walker is not-nil, then Walk is invoked recursively on this returned walker for each of the non-nil children of the element, followed by a call of Walk(nil) on the returned walker.

The initial walker may not be nil.

Types

type Access

type Access interface {
	Keyword() string
	Description() string
	String() string
	MarshalJSON() ([]byte, error)
	// contains filtered or unexported methods
}

type AccessExpression

type AccessExpression interface {
	Expression

	AccessedExpression() Expression
	// contains filtered or unexported methods
}

type Argument

type Argument struct {
	Expression           Expression
	LabelStartPos        *Position `json:",omitempty"`
	LabelEndPos          *Position `json:",omitempty"`
	Label                string    `json:",omitempty"`
	TrailingSeparatorPos Position
}

func NewArgument

func NewArgument(
	memoryGauge common.MemoryGauge,
	label string,
	labelStartPos,
	labelEndPos *Position,
	expression Expression,
) *Argument

func NewUnlabeledArgument

func NewUnlabeledArgument(memoryGauge common.MemoryGauge, expression Expression) *Argument

func (*Argument) Doc

func (a *Argument) Doc() prettier.Doc

func (*Argument) EndPosition

func (a *Argument) EndPosition(memoryGauge common.MemoryGauge) Position

func (*Argument) MarshalJSON

func (a *Argument) MarshalJSON() ([]byte, error)

func (*Argument) StartPosition

func (a *Argument) StartPosition() Position

func (*Argument) String

func (a *Argument) String() string

type Arguments

type Arguments []*Argument

func (Arguments) Doc

func (args Arguments) Doc() prettier.Doc

func (Arguments) String

func (args Arguments) String() string

type ArrayExpression

type ArrayExpression struct {
	Values []Expression
	Range
}

func NewArrayExpression

func NewArrayExpression(
	gauge common.MemoryGauge,
	values []Expression,
	tokenRange Range,
) *ArrayExpression

func (*ArrayExpression) Doc

func (e *ArrayExpression) Doc() prettier.Doc

func (*ArrayExpression) ElementType

func (*ArrayExpression) ElementType() ElementType

func (*ArrayExpression) MarshalJSON

func (e *ArrayExpression) MarshalJSON() ([]byte, error)

func (*ArrayExpression) String

func (e *ArrayExpression) String() string

func (*ArrayExpression) Walk

func (e *ArrayExpression) Walk(walkChild func(Element))

type ArrayExtractor

type ArrayExtractor interface {
	ExtractArray(extractor *ExpressionExtractor, expression *ArrayExpression) ExpressionExtraction
}

type AssignmentStatement

type AssignmentStatement struct {
	Target   Expression
	Transfer *Transfer
	Value    Expression
}

func NewAssignmentStatement

func NewAssignmentStatement(
	gauge common.MemoryGauge,
	expression Expression,
	transfer *Transfer,
	value Expression,
) *AssignmentStatement

func (*AssignmentStatement) Doc

func (s *AssignmentStatement) Doc() prettier.Doc

func (*AssignmentStatement) ElementType

func (*AssignmentStatement) ElementType() ElementType

func (*AssignmentStatement) EndPosition

func (s *AssignmentStatement) EndPosition(memoryGauge common.MemoryGauge) Position

func (*AssignmentStatement) MarshalJSON

func (s *AssignmentStatement) MarshalJSON() ([]byte, error)

func (*AssignmentStatement) StartPosition

func (s *AssignmentStatement) StartPosition() Position

func (*AssignmentStatement) String

func (s *AssignmentStatement) String() string

func (*AssignmentStatement) Walk

func (s *AssignmentStatement) Walk(walkChild func(Element))

type AttachExpression

type AttachExpression struct {
	Base       Expression
	Attachment *InvocationExpression
	StartPos   Position `json:"-"`
}

AttachExpression

func NewAttachExpression

func NewAttachExpression(
	gauge common.MemoryGauge,
	base Expression,
	attachment *InvocationExpression,
	startPos Position,
) *AttachExpression

func (*AttachExpression) Doc

func (e *AttachExpression) Doc() prettier.Doc

func (*AttachExpression) ElementType

func (*AttachExpression) ElementType() ElementType

func (*AttachExpression) EndPosition

func (e *AttachExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*AttachExpression) MarshalJSON

func (e *AttachExpression) MarshalJSON() ([]byte, error)

func (*AttachExpression) StartPosition

func (e *AttachExpression) StartPosition() Position

func (*AttachExpression) String

func (e *AttachExpression) String() string

func (*AttachExpression) Walk

func (e *AttachExpression) Walk(walkChild func(Element))

type AttachExtractor

type AttachExtractor interface {
	ExtractAttach(extractor *ExpressionExtractor, expression *AttachExpression) ExpressionExtraction
}

type AttachmentDeclaration

type AttachmentDeclaration struct {
	Access       Access
	Identifier   Identifier
	BaseType     *NominalType
	Conformances []*NominalType
	Members      *Members
	DocString    string
	Range
}

func NewAttachmentDeclaration

func NewAttachmentDeclaration(
	memoryGauge common.MemoryGauge,
	access Access,
	identifier Identifier,
	baseType *NominalType,
	conformances []*NominalType,
	members *Members,
	docString string,
	declarationRange Range,
) *AttachmentDeclaration

func (*AttachmentDeclaration) ConformanceList

func (d *AttachmentDeclaration) ConformanceList() []*NominalType

func (*AttachmentDeclaration) DeclarationAccess

func (d *AttachmentDeclaration) DeclarationAccess() Access

func (*AttachmentDeclaration) DeclarationDocString

func (d *AttachmentDeclaration) DeclarationDocString() string

func (*AttachmentDeclaration) DeclarationIdentifier

func (d *AttachmentDeclaration) DeclarationIdentifier() *Identifier

func (*AttachmentDeclaration) DeclarationKind

func (d *AttachmentDeclaration) DeclarationKind() common.DeclarationKind

func (*AttachmentDeclaration) DeclarationMembers

func (d *AttachmentDeclaration) DeclarationMembers() *Members

func (*AttachmentDeclaration) Doc

func (*AttachmentDeclaration) ElementType

func (*AttachmentDeclaration) ElementType() ElementType

func (*AttachmentDeclaration) Kind

func (*AttachmentDeclaration) MarshalJSON

func (d *AttachmentDeclaration) MarshalJSON() ([]byte, error)

func (*AttachmentDeclaration) String

func (d *AttachmentDeclaration) String() string

func (*AttachmentDeclaration) Walk

func (d *AttachmentDeclaration) Walk(walkChild func(Element))

type Authorization

type Authorization interface {
	// contains filtered or unexported methods
}

type BinaryExpression

type BinaryExpression struct {
	Left      Expression
	Right     Expression
	Operation Operation
}

func NewBinaryExpression

func NewBinaryExpression(
	gauge common.MemoryGauge,
	operation Operation,
	left Expression,
	right Expression,
) *BinaryExpression

func (*BinaryExpression) Doc

func (e *BinaryExpression) Doc() prettier.Doc

func (*BinaryExpression) ElementType

func (*BinaryExpression) ElementType() ElementType

func (*BinaryExpression) EndPosition

func (e *BinaryExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*BinaryExpression) IsLeftAssociative

func (e *BinaryExpression) IsLeftAssociative() bool

func (*BinaryExpression) MarshalJSON

func (e *BinaryExpression) MarshalJSON() ([]byte, error)

func (*BinaryExpression) StartPosition

func (e *BinaryExpression) StartPosition() Position

func (*BinaryExpression) String

func (e *BinaryExpression) String() string

func (*BinaryExpression) Walk

func (e *BinaryExpression) Walk(walkChild func(Element))

type BinaryExtractor

type BinaryExtractor interface {
	ExtractBinary(extractor *ExpressionExtractor, expression *BinaryExpression) ExpressionExtraction
}

type Block

type Block struct {
	Statements []Statement
	Range
}

func NewBlock

func NewBlock(memoryGauge common.MemoryGauge, statements []Statement, astRange Range) *Block

func (*Block) Doc

func (b *Block) Doc() prettier.Doc

func (*Block) ElementType

func (*Block) ElementType() ElementType

func (*Block) IsEmpty

func (b *Block) IsEmpty() bool

func (*Block) MarshalJSON

func (b *Block) MarshalJSON() ([]byte, error)

func (*Block) String

func (b *Block) String() string

func (*Block) Walk

func (b *Block) Walk(walkChild func(Element))

type BoolExpression

type BoolExpression struct {
	Value bool
	Range
}

func NewBoolExpression

func NewBoolExpression(gauge common.MemoryGauge, value bool, exprRange Range) *BoolExpression

func (*BoolExpression) Doc

func (e *BoolExpression) Doc() prettier.Doc

func (*BoolExpression) ElementType

func (*BoolExpression) ElementType() ElementType

func (*BoolExpression) MarshalJSON

func (e *BoolExpression) MarshalJSON() ([]byte, error)

func (*BoolExpression) String

func (e *BoolExpression) String() string

func (*BoolExpression) Walk

func (*BoolExpression) Walk(_ func(Element))

type BoolExtractor

type BoolExtractor interface {
	ExtractBool(extractor *ExpressionExtractor, expression *BoolExpression) ExpressionExtraction
}

type BreakStatement

type BreakStatement struct {
	Range
}

func NewBreakStatement

func NewBreakStatement(gauge common.MemoryGauge, tokenRange Range) *BreakStatement

func (*BreakStatement) Doc

func (*BreakStatement) Doc() prettier.Doc

func (*BreakStatement) ElementType

func (*BreakStatement) ElementType() ElementType

func (*BreakStatement) MarshalJSON

func (s *BreakStatement) MarshalJSON() ([]byte, error)

func (*BreakStatement) String

func (s *BreakStatement) String() string

func (*BreakStatement) Walk

func (*BreakStatement) Walk(_ func(Element))

type CastingExpression

type CastingExpression struct {
	Expression                Expression
	TypeAnnotation            *TypeAnnotation
	ParentVariableDeclaration *VariableDeclaration `json:"-"`
	Operation                 Operation
}

func NewCastingExpression

func NewCastingExpression(
	gauge common.MemoryGauge,
	expression Expression,
	operation Operation,
	typeAnnotation *TypeAnnotation,
	parentVariableDecl *VariableDeclaration,
) *CastingExpression

func (*CastingExpression) Doc

func (e *CastingExpression) Doc() prettier.Doc

func (*CastingExpression) ElementType

func (*CastingExpression) ElementType() ElementType

func (*CastingExpression) EndPosition

func (e *CastingExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*CastingExpression) MarshalJSON

func (e *CastingExpression) MarshalJSON() ([]byte, error)

func (*CastingExpression) StartPosition

func (e *CastingExpression) StartPosition() Position

func (*CastingExpression) String

func (e *CastingExpression) String() string

func (*CastingExpression) Walk

func (e *CastingExpression) Walk(walkChild func(Element))

type CastingExtractor

type CastingExtractor interface {
	ExtractCast(extractor *ExpressionExtractor, expression *CastingExpression) ExpressionExtraction
}

type CompositeDeclaration

type CompositeDeclaration struct {
	Members      *Members
	DocString    string
	Conformances []*NominalType
	Identifier   Identifier
	Range
	Access        Access
	CompositeKind common.CompositeKind
}

func NewCompositeDeclaration

func NewCompositeDeclaration(
	memoryGauge common.MemoryGauge,
	access Access,
	compositeKind common.CompositeKind,
	identifier Identifier,
	conformances []*NominalType,
	members *Members,
	docString string,
	declarationRange Range,
) *CompositeDeclaration

func (*CompositeDeclaration) ConformanceList

func (d *CompositeDeclaration) ConformanceList() []*NominalType

func (*CompositeDeclaration) DeclarationAccess

func (d *CompositeDeclaration) DeclarationAccess() Access

func (*CompositeDeclaration) DeclarationDocString

func (d *CompositeDeclaration) DeclarationDocString() string

func (*CompositeDeclaration) DeclarationIdentifier

func (d *CompositeDeclaration) DeclarationIdentifier() *Identifier

func (*CompositeDeclaration) DeclarationKind

func (d *CompositeDeclaration) DeclarationKind() common.DeclarationKind

func (*CompositeDeclaration) DeclarationMembers

func (d *CompositeDeclaration) DeclarationMembers() *Members

func (*CompositeDeclaration) Doc

func (*CompositeDeclaration) ElementType

func (*CompositeDeclaration) ElementType() ElementType

func (*CompositeDeclaration) EventDoc

func (d *CompositeDeclaration) EventDoc() prettier.Doc

func (*CompositeDeclaration) IsResourceDestructionDefaultEvent

func (d *CompositeDeclaration) IsResourceDestructionDefaultEvent() bool

func (*CompositeDeclaration) Kind

func (*CompositeDeclaration) MarshalJSON

func (d *CompositeDeclaration) MarshalJSON() ([]byte, error)

func (*CompositeDeclaration) String

func (d *CompositeDeclaration) String() string

func (*CompositeDeclaration) Walk

func (d *CompositeDeclaration) Walk(walkChild func(Element))

type CompositeLikeDeclaration

type CompositeLikeDeclaration interface {
	ConformingDeclaration

	Kind() common.CompositeKind
	// contains filtered or unexported methods
}

type Condition

type Condition interface {
	Element

	CodeElement() Element
	Doc() prettier.Doc
	HasPosition
	// contains filtered or unexported methods
}

type ConditionKind

type ConditionKind uint
const (
	ConditionKindUnknown ConditionKind = iota
	ConditionKindPre
	ConditionKindPost
)

func (ConditionKind) Keyword

func (k ConditionKind) Keyword() string

func (ConditionKind) MarshalJSON

func (k ConditionKind) MarshalJSON() ([]byte, error)

func (ConditionKind) Name

func (k ConditionKind) Name() string

func (ConditionKind) String

func (i ConditionKind) String() string

type ConditionalExpression

type ConditionalExpression struct {
	Test Expression
	Then Expression
	Else Expression
}

func NewConditionalExpression

func NewConditionalExpression(
	gauge common.MemoryGauge,
	testExpr Expression,
	thenExpr Expression,
	elseExpr Expression,
) *ConditionalExpression

func (*ConditionalExpression) Doc

func (*ConditionalExpression) ElementType

func (*ConditionalExpression) ElementType() ElementType

func (*ConditionalExpression) EndPosition

func (e *ConditionalExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*ConditionalExpression) MarshalJSON

func (e *ConditionalExpression) MarshalJSON() ([]byte, error)

func (*ConditionalExpression) StartPosition

func (e *ConditionalExpression) StartPosition() Position

func (*ConditionalExpression) String

func (e *ConditionalExpression) String() string

func (*ConditionalExpression) Walk

func (e *ConditionalExpression) Walk(walkChild func(Element))

type ConditionalExtractor

type ConditionalExtractor interface {
	ExtractConditional(extractor *ExpressionExtractor, expression *ConditionalExpression) ExpressionExtraction
}

type Conditions

type Conditions struct {
	Conditions []Condition
	Range
}

func (*Conditions) Doc

func (c *Conditions) Doc(keywordDoc prettier.Doc) prettier.Doc

func (*Conditions) IsEmpty

func (c *Conditions) IsEmpty() bool

func (*Conditions) Walk

func (c *Conditions) Walk(walkChild func(Element))

type ConformingDeclaration

type ConformingDeclaration interface {
	Declaration
	ConformanceList() []*NominalType
}

ConformingDeclaration

type ConjunctiveEntitlementSet

type ConjunctiveEntitlementSet struct {
	Elements []*NominalType `json:"ConjunctiveElements"`
}

func NewConjunctiveEntitlementSet

func NewConjunctiveEntitlementSet(entitlements []*NominalType) *ConjunctiveEntitlementSet

func (*ConjunctiveEntitlementSet) Entitlements

func (s *ConjunctiveEntitlementSet) Entitlements() []*NominalType

func (*ConjunctiveEntitlementSet) Separator

func (s *ConjunctiveEntitlementSet) Separator() Separator

type ConstantSizedType

type ConstantSizedType struct {
	Type Type `json:"ElementType"`
	Size *IntegerExpression
	Range
}

func NewConstantSizedType

func NewConstantSizedType(
	memoryGauge common.MemoryGauge,
	typ Type,
	size *IntegerExpression,
	astRange Range,
) *ConstantSizedType

func (*ConstantSizedType) CheckEqual

func (t *ConstantSizedType) CheckEqual(other Type, checker TypeEqualityChecker) error

func (*ConstantSizedType) Doc

func (t *ConstantSizedType) Doc() prettier.Doc

func (*ConstantSizedType) MarshalJSON

func (t *ConstantSizedType) MarshalJSON() ([]byte, error)

func (*ConstantSizedType) String

func (t *ConstantSizedType) String() string

type ContinueStatement

type ContinueStatement struct {
	Range
}

func NewContinueStatement

func NewContinueStatement(gauge common.MemoryGauge, tokenRange Range) *ContinueStatement

func (*ContinueStatement) Doc

func (*ContinueStatement) ElementType

func (*ContinueStatement) ElementType() ElementType

func (*ContinueStatement) MarshalJSON

func (s *ContinueStatement) MarshalJSON() ([]byte, error)

func (*ContinueStatement) String

func (s *ContinueStatement) String() string

func (*ContinueStatement) Walk

func (*ContinueStatement) Walk(_ func(Element))

type CreateExpression

type CreateExpression struct {
	InvocationExpression *InvocationExpression
	StartPos             Position `json:"-"`
}

func NewCreateExpression

func NewCreateExpression(
	gauge common.MemoryGauge,
	invocationExpression *InvocationExpression,
	startPos Position,
) *CreateExpression

func (*CreateExpression) Doc

func (e *CreateExpression) Doc() prettier.Doc

func (*CreateExpression) ElementType

func (*CreateExpression) ElementType() ElementType

func (*CreateExpression) EndPosition

func (e *CreateExpression) EndPosition(common.MemoryGauge) Position

func (*CreateExpression) MarshalJSON

func (e *CreateExpression) MarshalJSON() ([]byte, error)

func (*CreateExpression) StartPosition

func (e *CreateExpression) StartPosition() Position

func (*CreateExpression) String

func (e *CreateExpression) String() string

func (*CreateExpression) Walk

func (e *CreateExpression) Walk(walkChild func(Element))

type CreateExtractor

type CreateExtractor interface {
	ExtractCreate(extractor *ExpressionExtractor, expression *CreateExpression) ExpressionExtraction
}

type Declaration

type Declaration interface {
	Element
	fmt.Stringer

	DeclarationIdentifier() *Identifier
	DeclarationKind() common.DeclarationKind
	DeclarationAccess() Access
	DeclarationMembers() *Members
	DeclarationDocString() string
	Doc() prettier.Doc
	// contains filtered or unexported methods
}

type DeclarationVisitor

type DeclarationVisitor[T any] interface {
	StatementDeclarationVisitor[T]
	VisitFieldDeclaration(*FieldDeclaration) T
	VisitEnumCaseDeclaration(*EnumCaseDeclaration) T
	VisitPragmaDeclaration(*PragmaDeclaration) T
	VisitImportDeclaration(*ImportDeclaration) T
}

type DestroyExpression

type DestroyExpression struct {
	Expression Expression
	StartPos   Position `json:"-"`
}

func NewDestroyExpression

func NewDestroyExpression(
	gauge common.MemoryGauge,
	expression Expression,
	startPos Position,
) *DestroyExpression

func (*DestroyExpression) Doc

func (e *DestroyExpression) Doc() prettier.Doc

func (*DestroyExpression) ElementType

func (*DestroyExpression) ElementType() ElementType

func (*DestroyExpression) EndPosition

func (e *DestroyExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*DestroyExpression) MarshalJSON

func (e *DestroyExpression) MarshalJSON() ([]byte, error)

func (*DestroyExpression) StartPosition

func (e *DestroyExpression) StartPosition() Position

func (*DestroyExpression) String

func (e *DestroyExpression) String() string

func (*DestroyExpression) Walk

func (e *DestroyExpression) Walk(walkChild func(Element))

type DestroyExtractor

type DestroyExtractor interface {
	ExtractDestroy(extractor *ExpressionExtractor, expression *DestroyExpression) ExpressionExtraction
}

type DictionaryEntry

type DictionaryEntry struct {
	Key   Expression
	Value Expression
}

func NewDictionaryEntry

func NewDictionaryEntry(
	gauge common.MemoryGauge,
	key Expression,
	value Expression,
) DictionaryEntry

func (DictionaryEntry) Doc

func (e DictionaryEntry) Doc() prettier.Doc

func (DictionaryEntry) MarshalJSON

func (e DictionaryEntry) MarshalJSON() ([]byte, error)

type DictionaryExpression

type DictionaryExpression struct {
	Entries []DictionaryEntry
	Range
}

func NewDictionaryExpression

func NewDictionaryExpression(
	gauge common.MemoryGauge,
	entries []DictionaryEntry,
	tokenRange Range,
) *DictionaryExpression

func (*DictionaryExpression) Doc

func (*DictionaryExpression) ElementType

func (*DictionaryExpression) ElementType() ElementType

func (*DictionaryExpression) MarshalJSON

func (e *DictionaryExpression) MarshalJSON() ([]byte, error)

func (*DictionaryExpression) String

func (e *DictionaryExpression) String() string

func (*DictionaryExpression) Walk

func (e *DictionaryExpression) Walk(walkChild func(Element))

type DictionaryExtractor

type DictionaryExtractor interface {
	ExtractDictionary(extractor *ExpressionExtractor, expression *DictionaryExpression) ExpressionExtraction
}

type DictionaryType

type DictionaryType struct {
	KeyType   Type
	ValueType Type
	Range
}

func NewDictionaryType

func NewDictionaryType(
	memoryGauge common.MemoryGauge,
	keyType Type,
	valueType Type,
	astRange Range,
) *DictionaryType

func (*DictionaryType) CheckEqual

func (t *DictionaryType) CheckEqual(other Type, checker TypeEqualityChecker) error

func (*DictionaryType) Doc

func (t *DictionaryType) Doc() prettier.Doc

func (*DictionaryType) MarshalJSON

func (t *DictionaryType) MarshalJSON() ([]byte, error)

func (*DictionaryType) String

func (t *DictionaryType) String() string

type DisjunctiveEntitlementSet

type DisjunctiveEntitlementSet struct {
	Elements []*NominalType `json:"DisjunctiveElements"`
}

func NewDisjunctiveEntitlementSet

func NewDisjunctiveEntitlementSet(entitlements []*NominalType) *DisjunctiveEntitlementSet

func (*DisjunctiveEntitlementSet) Entitlements

func (s *DisjunctiveEntitlementSet) Entitlements() []*NominalType

func (*DisjunctiveEntitlementSet) Separator

func (s *DisjunctiveEntitlementSet) Separator() Separator

type Element

type Element interface {
	HasPosition
	ElementType() ElementType
	Walk(walkChild func(Element))
}

type ElementType

type ElementType uint64
const (
	ElementTypeUnknown ElementType = iota

	ElementTypeProgram
	ElementTypeBlock
	ElementTypeFunctionBlock

	ElementTypeFunctionDeclaration
	ElementTypeSpecialFunctionDeclaration
	ElementTypeCompositeDeclaration
	ElementTypeInterfaceDeclaration
	ElementTypeEntitlementDeclaration
	ElementTypeEntitlementMappingDeclaration
	ElementTypeAttachmentDeclaration
	ElementTypeFieldDeclaration
	ElementTypeEnumCaseDeclaration
	ElementTypePragmaDeclaration
	ElementTypeImportDeclaration
	ElementTypeTransactionDeclaration

	ElementTypeReturnStatement
	ElementTypeBreakStatement
	ElementTypeContinueStatement
	ElementTypeIfStatement
	ElementTypeSwitchStatement
	ElementTypeWhileStatement
	ElementTypeForStatement
	ElementTypeEmitStatement
	ElementTypeVariableDeclaration
	ElementTypeAssignmentStatement
	ElementTypeSwapStatement
	ElementTypeExpressionStatement
	ElementTypeRemoveStatement

	ElementTypeVoidExpression
	ElementTypeBoolExpression
	ElementTypeNilExpression
	ElementTypeIntegerExpression
	ElementTypeFixedPointExpression
	ElementTypeArrayExpression
	ElementTypeDictionaryExpression
	ElementTypeIdentifierExpression
	ElementTypeInvocationExpression
	ElementTypeMemberExpression
	ElementTypeIndexExpression
	ElementTypeConditionalExpression
	ElementTypeUnaryExpression
	ElementTypeBinaryExpression
	ElementTypeFunctionExpression
	ElementTypeStringExpression
	ElementTypeCastingExpression
	ElementTypeCreateExpression
	ElementTypeDestroyExpression
	ElementTypeReferenceExpression
	ElementTypeForceExpression
	ElementTypePathExpression
	ElementTypeAttachExpression
	ElementTypeStringTemplateExpression
)

func (ElementType) String

func (i ElementType) String() string

type EmitCondition

type EmitCondition EmitStatement

func (*EmitCondition) CodeElement

func (c *EmitCondition) CodeElement() Element

func (*EmitCondition) Doc

func (c *EmitCondition) Doc() prettier.Doc

func (*EmitCondition) ElementType

func (c *EmitCondition) ElementType() ElementType

func (*EmitCondition) EndPosition

func (c *EmitCondition) EndPosition(memoryGauge common.MemoryGauge) Position

func (*EmitCondition) MarshalJSON

func (c *EmitCondition) MarshalJSON() ([]byte, error)

func (*EmitCondition) StartPosition

func (c *EmitCondition) StartPosition() Position

func (*EmitCondition) Walk

func (c *EmitCondition) Walk(walkChild func(Element))

type EmitStatement

type EmitStatement struct {
	InvocationExpression *InvocationExpression
	StartPos             Position `json:"-"`
}

func NewEmitStatement

func NewEmitStatement(
	gauge common.MemoryGauge,
	invocation *InvocationExpression,
	startPos Position,
) *EmitStatement

func (*EmitStatement) Doc

func (s *EmitStatement) Doc() prettier.Doc

func (*EmitStatement) ElementType

func (*EmitStatement) ElementType() ElementType

func (*EmitStatement) EndPosition

func (s *EmitStatement) EndPosition(memoryGauge common.MemoryGauge) Position

func (*EmitStatement) MarshalJSON

func (s *EmitStatement) MarshalJSON() ([]byte, error)

func (*EmitStatement) StartPosition

func (s *EmitStatement) StartPosition() Position

func (*EmitStatement) String

func (s *EmitStatement) String() string

func (*EmitStatement) Walk

func (s *EmitStatement) Walk(walkChild func(Element))

type EntitlementAccess

type EntitlementAccess struct {
	EntitlementSet EntitlementSet
}

func NewEntitlementAccess

func NewEntitlementAccess(entitlements EntitlementSet) EntitlementAccess

func (EntitlementAccess) Description

func (EntitlementAccess) Description() string

func (EntitlementAccess) Keyword

func (e EntitlementAccess) Keyword() string

func (EntitlementAccess) MarshalJSON

func (e EntitlementAccess) MarshalJSON() ([]byte, error)

func (EntitlementAccess) String

func (e EntitlementAccess) String() string

type EntitlementDeclaration

type EntitlementDeclaration struct {
	Access     Access
	DocString  string
	Identifier Identifier
	Range
}

func NewEntitlementDeclaration

func NewEntitlementDeclaration(
	gauge common.MemoryGauge,
	access Access,
	identifier Identifier,
	docString string,
	declRange Range,
) *EntitlementDeclaration

func (*EntitlementDeclaration) DeclarationAccess

func (d *EntitlementDeclaration) DeclarationAccess() Access

func (*EntitlementDeclaration) DeclarationDocString

func (d *EntitlementDeclaration) DeclarationDocString() string

func (*EntitlementDeclaration) DeclarationIdentifier

func (d *EntitlementDeclaration) DeclarationIdentifier() *Identifier

func (*EntitlementDeclaration) DeclarationKind

func (d *EntitlementDeclaration) DeclarationKind() common.DeclarationKind

func (*EntitlementDeclaration) DeclarationMembers

func (d *EntitlementDeclaration) DeclarationMembers() *Members

func (*EntitlementDeclaration) Doc

func (*EntitlementDeclaration) ElementType

func (*EntitlementDeclaration) ElementType() ElementType

func (*EntitlementDeclaration) MarshalJSON

func (d *EntitlementDeclaration) MarshalJSON() ([]byte, error)

func (*EntitlementDeclaration) String

func (d *EntitlementDeclaration) String() string

func (*EntitlementDeclaration) Walk

func (*EntitlementDeclaration) Walk(_ func(Element))

type EntitlementMapElement

type EntitlementMapElement interface {
	Doc() prettier.Doc
	// contains filtered or unexported methods
}

type EntitlementMapRelation

type EntitlementMapRelation struct {
	Input  *NominalType
	Output *NominalType
}

func NewEntitlementMapRelation

func NewEntitlementMapRelation(
	gauge common.MemoryGauge,
	input *NominalType,
	output *NominalType,
) *EntitlementMapRelation

func (*EntitlementMapRelation) Doc

type EntitlementMappingDeclaration

type EntitlementMappingDeclaration struct {
	Access     Access
	DocString  string
	Identifier Identifier
	Elements   []EntitlementMapElement
	Range
}

EntitlementMappingDeclaration

func NewEntitlementMappingDeclaration

func NewEntitlementMappingDeclaration(
	gauge common.MemoryGauge,
	access Access,
	identifier Identifier,
	elements []EntitlementMapElement,
	docString string,
	declRange Range,
) *EntitlementMappingDeclaration

func (*EntitlementMappingDeclaration) DeclarationAccess

func (d *EntitlementMappingDeclaration) DeclarationAccess() Access

func (*EntitlementMappingDeclaration) DeclarationDocString

func (d *EntitlementMappingDeclaration) DeclarationDocString() string

func (*EntitlementMappingDeclaration) DeclarationIdentifier

func (d *EntitlementMappingDeclaration) DeclarationIdentifier() *Identifier

func (*EntitlementMappingDeclaration) DeclarationKind

func (*EntitlementMappingDeclaration) DeclarationMembers

func (d *EntitlementMappingDeclaration) DeclarationMembers() *Members

func (*EntitlementMappingDeclaration) Doc

func (*EntitlementMappingDeclaration) ElementType

func (*EntitlementMappingDeclaration) Inclusions

func (d *EntitlementMappingDeclaration) Inclusions() (inclusions []*NominalType)

func (*EntitlementMappingDeclaration) MarshalJSON

func (d *EntitlementMappingDeclaration) MarshalJSON() ([]byte, error)

func (*EntitlementMappingDeclaration) Relations

func (d *EntitlementMappingDeclaration) Relations() (relations []*EntitlementMapRelation)

func (*EntitlementMappingDeclaration) String

func (*EntitlementMappingDeclaration) Walk

func (*EntitlementMappingDeclaration) Walk(_ func(Element))

type EntitlementSet

type EntitlementSet interface {
	Authorization
	Entitlements() []*NominalType
	Separator() Separator
}

type EnumCaseDeclaration

type EnumCaseDeclaration struct {
	DocString  string
	Identifier Identifier
	StartPos   Position `json:"-"`
	Access     Access
}

func NewEnumCaseDeclaration

func NewEnumCaseDeclaration(
	memoryGauge common.MemoryGauge,
	access Access,
	identifier Identifier,
	docString string,
	startPos Position,
) *EnumCaseDeclaration

func (*EnumCaseDeclaration) DeclarationAccess

func (d *EnumCaseDeclaration) DeclarationAccess() Access

func (*EnumCaseDeclaration) DeclarationDocString

func (d *EnumCaseDeclaration) DeclarationDocString() string

func (*EnumCaseDeclaration) DeclarationIdentifier

func (d *EnumCaseDeclaration) DeclarationIdentifier() *Identifier

func (*EnumCaseDeclaration) DeclarationKind

func (d *EnumCaseDeclaration) DeclarationKind() common.DeclarationKind

func (*EnumCaseDeclaration) DeclarationMembers

func (d *EnumCaseDeclaration) DeclarationMembers() *Members

func (*EnumCaseDeclaration) Doc

func (d *EnumCaseDeclaration) Doc() prettier.Doc

func (*EnumCaseDeclaration) ElementType

func (*EnumCaseDeclaration) ElementType() ElementType

func (*EnumCaseDeclaration) EndPosition

func (d *EnumCaseDeclaration) EndPosition(memoryGauge common.MemoryGauge) Position

func (*EnumCaseDeclaration) MarshalJSON

func (d *EnumCaseDeclaration) MarshalJSON() ([]byte, error)

func (*EnumCaseDeclaration) StartPosition

func (d *EnumCaseDeclaration) StartPosition() Position

func (*EnumCaseDeclaration) String

func (d *EnumCaseDeclaration) String() string

func (*EnumCaseDeclaration) Walk

func (*EnumCaseDeclaration) Walk(_ func(Element))

type Expression

type Expression interface {
	Element
	fmt.Stringer
	IfStatementTest

	Doc() prettier.Doc
	// contains filtered or unexported methods
}

type ExpressionExtraction

type ExpressionExtraction struct {
	RewrittenExpression  Expression
	ExtractedExpressions []ExtractedExpression
}

type ExpressionExtractor

type ExpressionExtractor struct {
	IndexExtractor          IndexExtractor
	ForceExtractor          ForceExtractor
	BoolExtractor           BoolExtractor
	NilExtractor            NilExtractor
	IntExtractor            IntExtractor
	FixedPointExtractor     FixedPointExtractor
	StringExtractor         StringExtractor
	StringTemplateExtractor StringTemplateExtractor
	ArrayExtractor          ArrayExtractor
	DictionaryExtractor     DictionaryExtractor
	IdentifierExtractor     IdentifierExtractor
	AttachExtractor         AttachExtractor
	MemoryGauge             common.MemoryGauge
	VoidExtractor           VoidExtractor
	UnaryExtractor          UnaryExtractor
	ConditionalExtractor    ConditionalExtractor
	InvocationExtractor     InvocationExtractor
	BinaryExtractor         BinaryExtractor
	FunctionExtractor       FunctionExtractor
	CastingExtractor        CastingExtractor
	CreateExtractor         CreateExtractor
	DestroyExtractor        DestroyExtractor
	ReferenceExtractor      ReferenceExtractor
	MemberExtractor         MemberExtractor
	PathExtractor           PathExtractor
	// contains filtered or unexported fields
}

func (*ExpressionExtractor) Extract

func (extractor *ExpressionExtractor) Extract(expression Expression) ExpressionExtraction

func (*ExpressionExtractor) ExtractArray

func (extractor *ExpressionExtractor) ExtractArray(expression *ArrayExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractAttach

func (extractor *ExpressionExtractor) ExtractAttach(expression *AttachExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractBinary

func (extractor *ExpressionExtractor) ExtractBinary(expression *BinaryExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractBool

func (extractor *ExpressionExtractor) ExtractBool(expression *BoolExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractCast

func (extractor *ExpressionExtractor) ExtractCast(expression *CastingExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractConditional

func (extractor *ExpressionExtractor) ExtractConditional(expression *ConditionalExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractCreate

func (extractor *ExpressionExtractor) ExtractCreate(expression *CreateExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractDestroy

func (extractor *ExpressionExtractor) ExtractDestroy(expression *DestroyExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractDictionary

func (extractor *ExpressionExtractor) ExtractDictionary(expression *DictionaryExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractFixedPoint

func (extractor *ExpressionExtractor) ExtractFixedPoint(expression *FixedPointExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractForce

func (extractor *ExpressionExtractor) ExtractForce(expression *ForceExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractFunction

func (extractor *ExpressionExtractor) ExtractFunction(_ *FunctionExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractIdentifier

func (extractor *ExpressionExtractor) ExtractIdentifier(expression *IdentifierExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractIndex

func (extractor *ExpressionExtractor) ExtractIndex(expression *IndexExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractInteger

func (extractor *ExpressionExtractor) ExtractInteger(expression *IntegerExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractInvocation

func (extractor *ExpressionExtractor) ExtractInvocation(expression *InvocationExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractMember

func (extractor *ExpressionExtractor) ExtractMember(expression *MemberExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractNil

func (extractor *ExpressionExtractor) ExtractNil(expression *NilExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractPath

func (extractor *ExpressionExtractor) ExtractPath(expression *PathExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractReference

func (extractor *ExpressionExtractor) ExtractReference(expression *ReferenceExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractString

func (extractor *ExpressionExtractor) ExtractString(expression *StringExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractStringTemplate added in v1.3.0

func (extractor *ExpressionExtractor) ExtractStringTemplate(expression *StringTemplateExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractUnary

func (extractor *ExpressionExtractor) ExtractUnary(expression *UnaryExpression) ExpressionExtraction

func (*ExpressionExtractor) ExtractVoid

func (extractor *ExpressionExtractor) ExtractVoid(expression *VoidExpression) ExpressionExtraction

func (*ExpressionExtractor) FormatIdentifier

func (extractor *ExpressionExtractor) FormatIdentifier(identifier int) string

func (*ExpressionExtractor) FreshIdentifier

func (extractor *ExpressionExtractor) FreshIdentifier() string

func (*ExpressionExtractor) VisitArrayExpression

func (extractor *ExpressionExtractor) VisitArrayExpression(expression *ArrayExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitAttachExpression

func (extractor *ExpressionExtractor) VisitAttachExpression(expression *AttachExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitBinaryExpression

func (extractor *ExpressionExtractor) VisitBinaryExpression(expression *BinaryExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitBoolExpression

func (extractor *ExpressionExtractor) VisitBoolExpression(expression *BoolExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitCastingExpression

func (extractor *ExpressionExtractor) VisitCastingExpression(expression *CastingExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitConditionalExpression

func (extractor *ExpressionExtractor) VisitConditionalExpression(expression *ConditionalExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitCreateExpression

func (extractor *ExpressionExtractor) VisitCreateExpression(expression *CreateExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitDestroyExpression

func (extractor *ExpressionExtractor) VisitDestroyExpression(expression *DestroyExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitDictionaryExpression

func (extractor *ExpressionExtractor) VisitDictionaryExpression(expression *DictionaryExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitExpressions

func (extractor *ExpressionExtractor) VisitExpressions(
	expressions []Expression,
) (
	[]Expression, []ExtractedExpression,
)

func (*ExpressionExtractor) VisitFixedPointExpression

func (extractor *ExpressionExtractor) VisitFixedPointExpression(expression *FixedPointExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitForceExpression

func (extractor *ExpressionExtractor) VisitForceExpression(expression *ForceExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitFunctionExpression

func (extractor *ExpressionExtractor) VisitFunctionExpression(expression *FunctionExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitIdentifierExpression

func (extractor *ExpressionExtractor) VisitIdentifierExpression(expression *IdentifierExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitIndexExpression

func (extractor *ExpressionExtractor) VisitIndexExpression(expression *IndexExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitIntegerExpression

func (extractor *ExpressionExtractor) VisitIntegerExpression(expression *IntegerExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitInvocationExpression

func (extractor *ExpressionExtractor) VisitInvocationExpression(expression *InvocationExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitMemberExpression

func (extractor *ExpressionExtractor) VisitMemberExpression(expression *MemberExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitNilExpression

func (extractor *ExpressionExtractor) VisitNilExpression(expression *NilExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitPathExpression

func (extractor *ExpressionExtractor) VisitPathExpression(expression *PathExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitReferenceExpression

func (extractor *ExpressionExtractor) VisitReferenceExpression(expression *ReferenceExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitStringExpression

func (extractor *ExpressionExtractor) VisitStringExpression(expression *StringExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitStringTemplateExpression added in v1.3.0

func (extractor *ExpressionExtractor) VisitStringTemplateExpression(expression *StringTemplateExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitUnaryExpression

func (extractor *ExpressionExtractor) VisitUnaryExpression(expression *UnaryExpression) ExpressionExtraction

func (*ExpressionExtractor) VisitVoidExpression

func (extractor *ExpressionExtractor) VisitVoidExpression(expression *VoidExpression) ExpressionExtraction

type ExpressionStatement

type ExpressionStatement struct {
	Expression Expression
}

func NewExpressionStatement

func NewExpressionStatement(gauge common.MemoryGauge, expression Expression) *ExpressionStatement

func (*ExpressionStatement) Doc

func (s *ExpressionStatement) Doc() prettier.Doc

func (*ExpressionStatement) ElementType

func (*ExpressionStatement) ElementType() ElementType

func (*ExpressionStatement) EndPosition

func (s *ExpressionStatement) EndPosition(memoryGauge common.MemoryGauge) Position

func (*ExpressionStatement) MarshalJSON

func (s *ExpressionStatement) MarshalJSON() ([]byte, error)

func (*ExpressionStatement) StartPosition

func (s *ExpressionStatement) StartPosition() Position

func (*ExpressionStatement) String

func (s *ExpressionStatement) String() string

func (*ExpressionStatement) Walk

func (s *ExpressionStatement) Walk(walkChild func(Element))

type ExpressionVisitor

type ExpressionVisitor[T any] interface {
	VisitVoidExpression(*VoidExpression) T
	VisitNilExpression(*NilExpression) T
	VisitBoolExpression(*BoolExpression) T
	VisitStringExpression(*StringExpression) T
	VisitStringTemplateExpression(*StringTemplateExpression) T
	VisitIntegerExpression(*IntegerExpression) T
	VisitFixedPointExpression(*FixedPointExpression) T
	VisitDictionaryExpression(*DictionaryExpression) T
	VisitPathExpression(*PathExpression) T
	VisitForceExpression(*ForceExpression) T
	VisitArrayExpression(*ArrayExpression) T
	VisitInvocationExpression(*InvocationExpression) T
	VisitIdentifierExpression(*IdentifierExpression) T
	VisitIndexExpression(*IndexExpression) T
	VisitUnaryExpression(*UnaryExpression) T
	VisitFunctionExpression(*FunctionExpression) T
	VisitCreateExpression(*CreateExpression) T
	VisitMemberExpression(*MemberExpression) T
	VisitReferenceExpression(*ReferenceExpression) T
	VisitDestroyExpression(*DestroyExpression) T
	VisitCastingExpression(*CastingExpression) T
	VisitBinaryExpression(*BinaryExpression) T
	VisitConditionalExpression(*ConditionalExpression) T
	VisitAttachExpression(*AttachExpression) T
}

type ExtractedExpression

type ExtractedExpression struct {
	Expression Expression
	Identifier Identifier
}

type FieldDeclaration

type FieldDeclaration struct {
	TypeAnnotation *TypeAnnotation
	DocString      string
	Identifier     Identifier
	Range
	Access       Access
	VariableKind VariableKind
	Flags        FieldDeclarationFlags
}

func NewFieldDeclaration

func NewFieldDeclaration(
	memoryGauge common.MemoryGauge,
	access Access,
	isStatic bool,
	isNative bool,
	variableKind VariableKind,
	identifier Identifier,
	typeAnnotation *TypeAnnotation,
	docString string,
	declRange Range,
) *FieldDeclaration

func (*FieldDeclaration) DeclarationAccess

func (d *FieldDeclaration) DeclarationAccess() Access

func (*FieldDeclaration) DeclarationDocString

func (d *FieldDeclaration) DeclarationDocString() string

func (*FieldDeclaration) DeclarationIdentifier

func (d *FieldDeclaration) DeclarationIdentifier() *Identifier

func (*FieldDeclaration) DeclarationKind

func (d *FieldDeclaration) DeclarationKind() common.DeclarationKind

func (*FieldDeclaration) DeclarationMembers

func (d *FieldDeclaration) DeclarationMembers() *Members

func (*FieldDeclaration) Doc

func (d *FieldDeclaration) Doc() prettier.Doc

func (*FieldDeclaration) ElementType

func (*FieldDeclaration) ElementType() ElementType

func (*FieldDeclaration) IsNative

func (d *FieldDeclaration) IsNative() bool

func (*FieldDeclaration) IsStatic

func (d *FieldDeclaration) IsStatic() bool

func (*FieldDeclaration) MarshalJSON

func (d *FieldDeclaration) MarshalJSON() ([]byte, error)

func (*FieldDeclaration) String

func (d *FieldDeclaration) String() string

func (*FieldDeclaration) Walk

func (d *FieldDeclaration) Walk(_ func(Element))

type FieldDeclarationFlags

type FieldDeclarationFlags uint8
const (
	FieldDeclarationFlagsIsStatic FieldDeclarationFlags = 1 << iota
	FieldDeclarationFlagsIsNative
)

type FixedPointExpression

type FixedPointExpression struct {
	UnsignedInteger *big.Int `json:"-"`
	Fractional      *big.Int `json:"-"`
	PositiveLiteral []byte
	Range
	Scale    uint
	Negative bool
}

func NewFixedPointExpression

func NewFixedPointExpression(
	gauge common.MemoryGauge,
	literal []byte,
	isNegative bool,
	integer *big.Int,
	fractional *big.Int,
	scale uint,
	tokenRange Range,
) *FixedPointExpression

func (*FixedPointExpression) Doc

func (*FixedPointExpression) ElementType

func (*FixedPointExpression) ElementType() ElementType

func (*FixedPointExpression) MarshalJSON

func (e *FixedPointExpression) MarshalJSON() ([]byte, error)

func (*FixedPointExpression) String

func (e *FixedPointExpression) String() string

func (*FixedPointExpression) Walk

func (*FixedPointExpression) Walk(_ func(Element))

type FixedPointExtractor

type FixedPointExtractor interface {
	ExtractFixedPoint(extractor *ExpressionExtractor, expression *FixedPointExpression) ExpressionExtraction
}

type ForStatement

type ForStatement struct {
	Value      Expression
	Index      *Identifier
	Block      *Block
	Identifier Identifier
	StartPos   Position `json:"-"`
}

func NewForStatement

func NewForStatement(
	gauge common.MemoryGauge,
	identifier Identifier,
	index *Identifier,
	block *Block,
	expression Expression,
	startPos Position,
) *ForStatement

func (*ForStatement) Doc

func (s *ForStatement) Doc() prettier.Doc

func (*ForStatement) ElementType

func (*ForStatement) ElementType() ElementType

func (*ForStatement) EndPosition

func (s *ForStatement) EndPosition(memoryGauge common.MemoryGauge) Position

func (*ForStatement) MarshalJSON

func (s *ForStatement) MarshalJSON() ([]byte, error)

func (*ForStatement) StartPosition

func (s *ForStatement) StartPosition() Position

func (*ForStatement) String

func (s *ForStatement) String() string

func (*ForStatement) Walk

func (s *ForStatement) Walk(walkChild func(Element))

type ForceExpression

type ForceExpression struct {
	Expression Expression
	EndPos     Position `json:"-"`
}

func NewForceExpression

func NewForceExpression(
	gauge common.MemoryGauge,
	expression Expression,
	endPos Position,
) *ForceExpression

func (*ForceExpression) Doc

func (e *ForceExpression) Doc() prettier.Doc

func (*ForceExpression) ElementType

func (*ForceExpression) ElementType() ElementType

func (*ForceExpression) EndPosition

func (e *ForceExpression) EndPosition(common.MemoryGauge) Position

func (*ForceExpression) MarshalJSON

func (e *ForceExpression) MarshalJSON() ([]byte, error)

func (*ForceExpression) StartPosition

func (e *ForceExpression) StartPosition() Position

func (*ForceExpression) String

func (e *ForceExpression) String() string

func (*ForceExpression) Walk

func (e *ForceExpression) Walk(walkChild func(Element))

type ForceExtractor

type ForceExtractor interface {
	ExtractForce(extractor *ExpressionExtractor, expression *ForceExpression) ExpressionExtraction
}

type FunctionBlock

type FunctionBlock struct {
	Block          *Block
	PreConditions  *Conditions `json:",omitempty"`
	PostConditions *Conditions `json:",omitempty"`
}

func NewFunctionBlock

func NewFunctionBlock(
	memoryGauge common.MemoryGauge,
	block *Block,
	preConditions *Conditions,
	postConditions *Conditions,
) *FunctionBlock

func (*FunctionBlock) Doc

func (b *FunctionBlock) Doc() prettier.Doc

func (*FunctionBlock) ElementType

func (*FunctionBlock) ElementType() ElementType

func (*FunctionBlock) EndPosition

func (b *FunctionBlock) EndPosition(common.MemoryGauge) Position

func (*FunctionBlock) HasConditions

func (b *FunctionBlock) HasConditions() bool

func (*FunctionBlock) HasStatements

func (b *FunctionBlock) HasStatements() bool

func (*FunctionBlock) IsEmpty

func (b *FunctionBlock) IsEmpty() bool

func (*FunctionBlock) MarshalJSON

func (b *FunctionBlock) MarshalJSON() ([]byte, error)

func (*FunctionBlock) StartPosition

func (b *FunctionBlock) StartPosition() Position

func (*FunctionBlock) String

func (b *FunctionBlock) String() string

func (*FunctionBlock) Walk

func (b *FunctionBlock) Walk(walkChild func(Element))

type FunctionDeclaration

type FunctionDeclaration struct {
	Purity               FunctionPurity
	TypeParameterList    *TypeParameterList
	ParameterList        *ParameterList
	ReturnTypeAnnotation *TypeAnnotation
	FunctionBlock        *FunctionBlock
	DocString            string
	Identifier           Identifier
	StartPos             Position `json:"-"`
	Access               Access
	Flags                FunctionDeclarationFlags
}

func NewFunctionDeclaration

func NewFunctionDeclaration(
	gauge common.MemoryGauge,
	access Access,
	purity FunctionPurity,
	isStatic bool,
	isNative bool,
	identifier Identifier,
	typeParameterList *TypeParameterList,
	parameterList *ParameterList,
	returnTypeAnnotation *TypeAnnotation,
	functionBlock *FunctionBlock,
	startPos Position,
	docString string,
) *FunctionDeclaration

func (*FunctionDeclaration) DeclarationAccess

func (d *FunctionDeclaration) DeclarationAccess() Access

func (*FunctionDeclaration) DeclarationDocString

func (d *FunctionDeclaration) DeclarationDocString() string

func (*FunctionDeclaration) DeclarationIdentifier

func (d *FunctionDeclaration) DeclarationIdentifier() *Identifier

func (*FunctionDeclaration) DeclarationKind

func (d *FunctionDeclaration) DeclarationKind() common.DeclarationKind

func (*FunctionDeclaration) DeclarationMembers

func (d *FunctionDeclaration) DeclarationMembers() *Members

func (*FunctionDeclaration) Doc

func (d *FunctionDeclaration) Doc() prettier.Doc

func (*FunctionDeclaration) ElementType

func (*FunctionDeclaration) ElementType() ElementType

func (*FunctionDeclaration) EndPosition

func (d *FunctionDeclaration) EndPosition(memoryGauge common.MemoryGauge) Position

func (*FunctionDeclaration) IsNative

func (d *FunctionDeclaration) IsNative() bool

func (*FunctionDeclaration) IsStatic

func (d *FunctionDeclaration) IsStatic() bool

func (*FunctionDeclaration) MarshalJSON

func (d *FunctionDeclaration) MarshalJSON() ([]byte, error)

func (*FunctionDeclaration) StartPosition

func (d *FunctionDeclaration) StartPosition() Position

func (*FunctionDeclaration) String

func (d *FunctionDeclaration) String() string

func (*FunctionDeclaration) ToExpression

func (d *FunctionDeclaration) ToExpression(memoryGauge common.MemoryGauge) *FunctionExpression

func (*FunctionDeclaration) Walk

func (d *FunctionDeclaration) Walk(walkChild func(Element))

type FunctionDeclarationFlags

type FunctionDeclarationFlags uint8
const (
	FunctionDeclarationFlagsIsStatic FunctionDeclarationFlags = 1 << iota
	FunctionDeclarationFlagsIsNative
)

type FunctionExpression

type FunctionExpression struct {
	Purity               FunctionPurity
	ParameterList        *ParameterList
	ReturnTypeAnnotation *TypeAnnotation
	FunctionBlock        *FunctionBlock
	StartPos             Position `json:"-"`
}

func NewFunctionExpression

func NewFunctionExpression(
	gauge common.MemoryGauge,
	purity FunctionPurity,
	parameters *ParameterList,
	returnType *TypeAnnotation,
	functionBlock *FunctionBlock,
	startPos Position,
) *FunctionExpression

func (*FunctionExpression) Doc

func (e *FunctionExpression) Doc() prettier.Doc

func (*FunctionExpression) ElementType

func (*FunctionExpression) ElementType() ElementType

func (*FunctionExpression) EndPosition

func (e *FunctionExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*FunctionExpression) MarshalJSON

func (e *FunctionExpression) MarshalJSON() ([]byte, error)

func (*FunctionExpression) StartPosition

func (e *FunctionExpression) StartPosition() Position

func (*FunctionExpression) String

func (e *FunctionExpression) String() string

func (*FunctionExpression) Walk

func (e *FunctionExpression) Walk(walkChild func(Element))

type FunctionExtractor

type FunctionExtractor interface {
	ExtractFunction(extractor *ExpressionExtractor, expression *FunctionExpression) ExpressionExtraction
}

type FunctionPurity

type FunctionPurity int
const (
	FunctionPurityUnspecified FunctionPurity = iota
	FunctionPurityView
)

func (FunctionPurity) Keyword

func (p FunctionPurity) Keyword() string

func (FunctionPurity) MarshalJSON

func (p FunctionPurity) MarshalJSON() ([]byte, error)

type FunctionType

type FunctionType struct {
	PurityAnnotation         FunctionPurity
	ReturnTypeAnnotation     *TypeAnnotation
	ParameterTypeAnnotations []*TypeAnnotation `json:",omitempty"`
	Range
}

func NewFunctionType

func NewFunctionType(
	memoryGauge common.MemoryGauge,
	purity FunctionPurity,
	parameterTypes []*TypeAnnotation,
	returnType *TypeAnnotation,
	astRange Range,
) *FunctionType

func (*FunctionType) CheckEqual

func (t *FunctionType) CheckEqual(other Type, checker TypeEqualityChecker) error

func (*FunctionType) Doc

func (t *FunctionType) Doc() prettier.Doc

func (*FunctionType) MarshalJSON

func (t *FunctionType) MarshalJSON() ([]byte, error)

func (*FunctionType) String

func (t *FunctionType) String() string

type HasPosition

type HasPosition interface {
	StartPosition() Position
	EndPosition(memoryGauge common.MemoryGauge) Position
}

type Identifier

type Identifier struct {
	Identifier string
	Pos        Position
}

func NewEmptyIdentifier

func NewEmptyIdentifier(memoryGauge common.MemoryGauge, pos Position) Identifier

func NewIdentifier

func NewIdentifier(memoryGauge common.MemoryGauge, identifier string, pos Position) Identifier

func (Identifier) EndPosition

func (i Identifier) EndPosition(memoryGauge common.MemoryGauge) Position

func (Identifier) MarshalJSON

func (i Identifier) MarshalJSON() ([]byte, error)

func (Identifier) StartPosition

func (i Identifier) StartPosition() Position

func (Identifier) String

func (i Identifier) String() string

type IdentifierExpression

type IdentifierExpression struct {
	Identifier Identifier
}

func NewIdentifierExpression

func NewIdentifierExpression(
	gauge common.MemoryGauge,
	identifier Identifier,
) *IdentifierExpression

func (*IdentifierExpression) Doc

func (*IdentifierExpression) ElementType

func (*IdentifierExpression) ElementType() ElementType

func (*IdentifierExpression) EndPosition

func (e *IdentifierExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*IdentifierExpression) MarshalJSON

func (e *IdentifierExpression) MarshalJSON() ([]byte, error)

func (*IdentifierExpression) StartPosition

func (e *IdentifierExpression) StartPosition() Position

func (*IdentifierExpression) String

func (e *IdentifierExpression) String() string

func (*IdentifierExpression) Walk

func (*IdentifierExpression) Walk(_ func(Element))

type IdentifierExtractor

type IdentifierExtractor interface {
	ExtractIdentifier(extractor *ExpressionExtractor, expression *IdentifierExpression) ExpressionExtraction
}

type IfStatement

type IfStatement struct {
	Test     IfStatementTest
	Then     *Block
	Else     *Block
	StartPos Position `json:"-"`
}

func NewIfStatement

func NewIfStatement(
	gauge common.MemoryGauge,
	test IfStatementTest,
	thenBlock *Block,
	elseBlock *Block,
	startPos Position,
) *IfStatement

func (*IfStatement) Doc

func (s *IfStatement) Doc() prettier.Doc

func (*IfStatement) ElementType

func (*IfStatement) ElementType() ElementType

func (*IfStatement) EndPosition

func (s *IfStatement) EndPosition(memoryGauge common.MemoryGauge) Position

func (*IfStatement) MarshalJSON

func (s *IfStatement) MarshalJSON() ([]byte, error)

func (*IfStatement) StartPosition

func (s *IfStatement) StartPosition() Position

func (*IfStatement) String

func (s *IfStatement) String() string

func (*IfStatement) Walk

func (s *IfStatement) Walk(walkChild func(Element))

type IfStatementTest

type IfStatementTest interface {
	Element

	Doc() prettier.Doc
	// contains filtered or unexported methods
}

type ImportDeclaration

type ImportDeclaration struct {
	Location    common.Location
	Identifiers []Identifier
	Range
	LocationPos Position
}

func NewImportDeclaration

func NewImportDeclaration(
	gauge common.MemoryGauge,
	identifiers []Identifier,
	location common.Location,
	declRange Range,
	locationPos Position,
) *ImportDeclaration

func (*ImportDeclaration) DeclarationAccess

func (d *ImportDeclaration) DeclarationAccess() Access

func (*ImportDeclaration) DeclarationDocString

func (d *ImportDeclaration) DeclarationDocString() string

func (*ImportDeclaration) DeclarationIdentifier

func (d *ImportDeclaration) DeclarationIdentifier() *Identifier

func (*ImportDeclaration) DeclarationKind

func (d *ImportDeclaration) DeclarationKind() common.DeclarationKind

func (*ImportDeclaration) DeclarationMembers

func (d *ImportDeclaration) DeclarationMembers() *Members

func (*ImportDeclaration) Doc

func (d *ImportDeclaration) Doc() prettier.Doc

func (*ImportDeclaration) ElementType

func (*ImportDeclaration) ElementType() ElementType

func (*ImportDeclaration) MarshalJSON

func (d *ImportDeclaration) MarshalJSON() ([]byte, error)

func (*ImportDeclaration) String

func (d *ImportDeclaration) String() string

func (*ImportDeclaration) Walk

func (*ImportDeclaration) Walk(_ func(Element))

type IndexExpression

type IndexExpression struct {
	TargetExpression   Expression
	IndexingExpression Expression
	Range
}

func NewIndexExpression

func NewIndexExpression(
	gauge common.MemoryGauge,
	target Expression,
	index Expression,
	tokenRange Range,
) *IndexExpression

func (*IndexExpression) AccessedExpression

func (e *IndexExpression) AccessedExpression() Expression

func (*IndexExpression) Doc

func (e *IndexExpression) Doc() prettier.Doc

func (*IndexExpression) ElementType

func (*IndexExpression) ElementType() ElementType

func (*IndexExpression) MarshalJSON

func (e *IndexExpression) MarshalJSON() ([]byte, error)

func (*IndexExpression) String

func (e *IndexExpression) String() string

func (*IndexExpression) Walk

func (e *IndexExpression) Walk(walkChild func(Element))

type IndexExtractor

type IndexExtractor interface {
	ExtractIndex(extractor *ExpressionExtractor, expression *IndexExpression) ExpressionExtraction
}

type Inspector

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

Inspector provides methods for inspecting (traversing) an AST element.

The inspecting methods allow element filtering by type, and materialization of the traversal stack.

During construction, the inspector does a complete traversal and builds a list of push/pop events and their element type. Subsequent method calls that request a traversal scan this list, rather than walk the AST, and perform type filtering using efficient bit sets.

Inspector's traversals are faster than using the Inspect function, but it may take multiple traversals for this benefit to amortize the inspector's construction cost. If efficiency is the primary concern, do not use Inspector for one-off traversals.

There are four orthogonal features in a traversal:

1 type filtering
2 pruning
3 postorder calls to f
4 stack

Rather than offer all of them in the API, only a few combinations are exposed:

  • Preorder is the fastest and has the fewest features, but is the most commonly needed traversal.
  • Elements and WithStack both provide pruning and postorder calls, even though few clients need it, because supporting two versions is not justified.

More combinations could be supported by expressing them as wrappers around a more generic traversal, but likely has worse performance.

func NewInspector

func NewInspector(element Element) *Inspector

NewInspector returns an Inspector for the specified AST element.

func (*Inspector) Elements

func (in *Inspector) Elements(types []Element, f func(element Element, push bool) (proceed bool))

Elements visits the elements in depth-first order. It calls f(e, true) for each element e before it visits e's children. If f returns true, Elements invokes f recursively for each of the non-nil children of the element, followed by a call of f(n, false).

The types argument, if non-empty, enables type-based filtering of events. The function f if is called only for elements whose type matches an element of the types slice.

func (*Inspector) Preorder

func (in *Inspector) Preorder(types []Element, f func(Element))

Preorder visits all elements in depth-first order. It calls f(e) for each element e before it visits e's children.

The types argument, if non-empty, enables type-based filtering of events. The function f if is called only for elements whose type matches an element of the types slice.

Preorder is almost twice as fast as Elements, because it avoids postorder calls to f, and the pruning check.

func (*Inspector) WithStack

func (in *Inspector) WithStack(types []Element, f func(element Element, push bool, stack []Element) (proceed bool))

WithStack visits elements in a similar manner to Elements, but it supplies each call to f an additional argument, the current traversal stack.

The stack's first element is the outermost element, its last is the innermost.

type InstantiationType

type InstantiationType struct {
	Type                  Type `json:"InstantiatedType"`
	TypeArguments         []*TypeAnnotation
	TypeArgumentsStartPos Position
	EndPos                Position `json:"-"`
}

func NewInstantiationType

func NewInstantiationType(
	memoryGauge common.MemoryGauge,
	typ Type,
	typeArguments []*TypeAnnotation,
	typeArgumentsStartPos Position,
	endPos Position,
) *InstantiationType

func (*InstantiationType) CheckEqual

func (t *InstantiationType) CheckEqual(other Type, checker TypeEqualityChecker) error

func (*InstantiationType) Doc

func (t *InstantiationType) Doc() prettier.Doc

func (*InstantiationType) EndPosition

func (t *InstantiationType) EndPosition(common.MemoryGauge) Position

func (*InstantiationType) MarshalJSON

func (t *InstantiationType) MarshalJSON() ([]byte, error)

func (*InstantiationType) StartPosition

func (t *InstantiationType) StartPosition() Position

func (*InstantiationType) String

func (t *InstantiationType) String() string

type IntExtractor

type IntExtractor interface {
	ExtractInteger(extractor *ExpressionExtractor, expression *IntegerExpression) ExpressionExtraction
}

type IntegerExpression

type IntegerExpression struct {
	Value           *big.Int `json:"-"`
	PositiveLiteral []byte
	Range
	Base int
}

func NewIntegerExpression

func NewIntegerExpression(
	gauge common.MemoryGauge,
	literal []byte,
	value *big.Int,
	base int,
	tokenRange Range,
) *IntegerExpression

func (*IntegerExpression) Doc

func (e *IntegerExpression) Doc() prettier.Doc

func (*IntegerExpression) ElementType

func (*IntegerExpression) ElementType() ElementType

func (*IntegerExpression) MarshalJSON

func (e *IntegerExpression) MarshalJSON() ([]byte, error)

func (*IntegerExpression) String

func (e *IntegerExpression) String() string

func (*IntegerExpression) Walk

func (*IntegerExpression) Walk(_ func(Element))

type InterfaceDeclaration

type InterfaceDeclaration struct {
	Members      *Members
	DocString    string
	Identifier   Identifier
	Conformances []*NominalType
	Range
	Access        Access
	CompositeKind common.CompositeKind
}

func NewInterfaceDeclaration

func NewInterfaceDeclaration(
	gauge common.MemoryGauge,
	access Access,
	compositeKind common.CompositeKind,
	identifier Identifier,
	conformances []*NominalType,
	members *Members,
	docString string,
	declRange Range,
) *InterfaceDeclaration

func (*InterfaceDeclaration) ConformanceList

func (d *InterfaceDeclaration) ConformanceList() []*NominalType

func (*InterfaceDeclaration) DeclarationAccess

func (d *InterfaceDeclaration) DeclarationAccess() Access

func (*InterfaceDeclaration) DeclarationDocString

func (d *InterfaceDeclaration) DeclarationDocString() string

func (*InterfaceDeclaration) DeclarationIdentifier

func (d *InterfaceDeclaration) DeclarationIdentifier() *Identifier

func (*InterfaceDeclaration) DeclarationKind

func (d *InterfaceDeclaration) DeclarationKind() common.DeclarationKind

func (*InterfaceDeclaration) DeclarationMembers

func (d *InterfaceDeclaration) DeclarationMembers() *Members

func (*InterfaceDeclaration) Doc

func (*InterfaceDeclaration) ElementType

func (*InterfaceDeclaration) ElementType() ElementType

func (*InterfaceDeclaration) Kind

func (*InterfaceDeclaration) MarshalJSON

func (d *InterfaceDeclaration) MarshalJSON() ([]byte, error)

func (*InterfaceDeclaration) String

func (d *InterfaceDeclaration) String() string

func (*InterfaceDeclaration) Walk

func (d *InterfaceDeclaration) Walk(walkChild func(Element))

type IntersectionType

type IntersectionType struct {
	LegacyRestrictedType Type // Deprecated
	Types                []*NominalType
	Range
}

func NewIntersectionType

func NewIntersectionType(
	memoryGauge common.MemoryGauge,
	types []*NominalType,
	astRange Range,
) *IntersectionType

func (*IntersectionType) CheckEqual

func (t *IntersectionType) CheckEqual(other Type, checker TypeEqualityChecker) error

func (*IntersectionType) Doc

func (t *IntersectionType) Doc() prettier.Doc

func (*IntersectionType) MarshalJSON

func (t *IntersectionType) MarshalJSON() ([]byte, error)

func (*IntersectionType) String

func (t *IntersectionType) String() string

type InvocationExpression

type InvocationExpression struct {
	InvokedExpression Expression
	TypeArguments     []*TypeAnnotation
	Arguments         Arguments
	ArgumentsStartPos Position
	EndPos            Position `json:"-"`
}

func NewInvocationExpression

func NewInvocationExpression(
	gauge common.MemoryGauge,
	invokedExpression Expression,
	typeArguments []*TypeAnnotation,
	arguments Arguments,
	argsStartPos Position,
	endPos Position,
) *InvocationExpression

func (*InvocationExpression) Doc

func (*InvocationExpression) ElementType

func (*InvocationExpression) ElementType() ElementType

func (*InvocationExpression) EndPosition

func (e *InvocationExpression) EndPosition(_ common.MemoryGauge) Position

func (*InvocationExpression) MarshalJSON

func (e *InvocationExpression) MarshalJSON() ([]byte, error)

func (*InvocationExpression) StartPosition

func (e *InvocationExpression) StartPosition() Position

func (*InvocationExpression) String

func (e *InvocationExpression) String() string

func (*InvocationExpression) Walk

func (e *InvocationExpression) Walk(walkChild func(Element))

type InvocationExtractor

type InvocationExtractor interface {
	ExtractInvocation(extractor *ExpressionExtractor, expression *InvocationExpression) ExpressionExtraction
}

type MappedAccess

type MappedAccess struct {
	EntitlementMap *NominalType
	StartPos       Position
}

func NewMappedAccess

func NewMappedAccess(
	typ *NominalType,
	startPos Position,
) *MappedAccess

func (*MappedAccess) Description

func (*MappedAccess) Description() string

func (*MappedAccess) EndPosition

func (t *MappedAccess) EndPosition(memoryGauge common.MemoryGauge) Position

func (*MappedAccess) Keyword

func (e *MappedAccess) Keyword() string

func (*MappedAccess) MarshalJSON

func (e *MappedAccess) MarshalJSON() ([]byte, error)

func (*MappedAccess) StartPosition

func (t *MappedAccess) StartPosition() Position

func (*MappedAccess) String

func (e *MappedAccess) String() string

type MemberExpression

type MemberExpression struct {
	Expression Expression
	Identifier Identifier
	// The position of the token (`.`, `?.`) that separates the accessed expression
	// and the identifier of the member
	AccessPos Position
	Optional  bool
}

func NewMemberExpression

func NewMemberExpression(
	gauge common.MemoryGauge,
	expression Expression,
	optional bool,
	accessPos Position,
	identifier Identifier,
) *MemberExpression

func (*MemberExpression) AccessedExpression

func (e *MemberExpression) AccessedExpression() Expression

func (*MemberExpression) Doc

func (e *MemberExpression) Doc() prettier.Doc

func (*MemberExpression) ElementType

func (*MemberExpression) ElementType() ElementType

func (*MemberExpression) EndPosition

func (e *MemberExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*MemberExpression) MarshalJSON

func (e *MemberExpression) MarshalJSON() ([]byte, error)

func (*MemberExpression) StartPosition

func (e *MemberExpression) StartPosition() Position

func (*MemberExpression) String

func (e *MemberExpression) String() string

func (*MemberExpression) Walk

func (e *MemberExpression) Walk(walkChild func(Element))

type MemberExtractor

type MemberExtractor interface {
	ExtractMember(extractor *ExpressionExtractor, expression *MemberExpression) ExpressionExtraction
}

type Members

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

func NewMembers

func NewMembers(memoryGauge common.MemoryGauge, declarations []Declaration) *Members

func NewUnmeteredMembers

func NewUnmeteredMembers(declarations []Declaration) *Members

func (*Members) Attachments

func (m *Members) Attachments() []*AttachmentDeclaration

func (*Members) AttachmentsByIdentifier

func (m *Members) AttachmentsByIdentifier() map[string]*AttachmentDeclaration

func (*Members) Composites

func (m *Members) Composites() []*CompositeDeclaration

func (*Members) CompositesByIdentifier

func (m *Members) CompositesByIdentifier() map[string]*CompositeDeclaration

func (*Members) Declarations

func (m *Members) Declarations() []Declaration

func (*Members) Doc

func (m *Members) Doc() prettier.Doc

func (*Members) EntitlementMappingsByIdentifier

func (m *Members) EntitlementMappingsByIdentifier() map[string]*EntitlementMappingDeclaration

func (*Members) EntitlementMaps

func (m *Members) EntitlementMaps() []*EntitlementMappingDeclaration

func (*Members) Entitlements

func (m *Members) Entitlements() []*EntitlementDeclaration

func (*Members) EntitlementsByIdentifier

func (m *Members) EntitlementsByIdentifier() map[string]*EntitlementDeclaration

func (*Members) EnumCases

func (m *Members) EnumCases() []*EnumCaseDeclaration

func (*Members) FieldPosition

func (m *Members) FieldPosition(name string, compositeKind common.CompositeKind) Position

func (*Members) Fields

func (m *Members) Fields() []*FieldDeclaration

func (*Members) FieldsByIdentifier

func (m *Members) FieldsByIdentifier() map[string]*FieldDeclaration

func (*Members) Functions

func (m *Members) Functions() []*FunctionDeclaration

func (*Members) FunctionsByIdentifier

func (m *Members) FunctionsByIdentifier() map[string]*FunctionDeclaration

func (*Members) Initializers

func (m *Members) Initializers() []*SpecialFunctionDeclaration

func (*Members) Interfaces

func (m *Members) Interfaces() []*InterfaceDeclaration

func (*Members) InterfacesByIdentifier

func (m *Members) InterfacesByIdentifier() map[string]*InterfaceDeclaration

func (*Members) MarshalJSON

func (m *Members) MarshalJSON() ([]byte, error)

func (*Members) Pragmas

func (m *Members) Pragmas() []*PragmaDeclaration

func (*Members) SpecialFunctions

func (m *Members) SpecialFunctions() []*SpecialFunctionDeclaration

type NilExpression

type NilExpression struct {
	Pos Position `json:"-"`
}

func NewNilExpression

func NewNilExpression(gauge common.MemoryGauge, pos Position) *NilExpression

func (*NilExpression) Doc

func (*NilExpression) Doc() prettier.Doc

func (*NilExpression) ElementType

func (*NilExpression) ElementType() ElementType

func (*NilExpression) EndPosition

func (e *NilExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*NilExpression) MarshalJSON

func (e *NilExpression) MarshalJSON() ([]byte, error)

func (*NilExpression) StartPosition

func (e *NilExpression) StartPosition() Position

func (*NilExpression) String

func (e *NilExpression) String() string

func (*NilExpression) Walk

func (*NilExpression) Walk(_ func(Element))

type NilExtractor

type NilExtractor interface {
	ExtractNil(extractor *ExpressionExtractor, expression *NilExpression) ExpressionExtraction
}

type NominalType

type NominalType struct {
	NestedIdentifiers []Identifier `json:",omitempty"`
	Identifier        Identifier
}

func NewNominalType

func NewNominalType(
	memoryGauge common.MemoryGauge,
	identifier Identifier,
	nestedIdentifiers []Identifier,
) *NominalType

func (*NominalType) CheckEqual

func (t *NominalType) CheckEqual(other Type, checker TypeEqualityChecker) error

func (*NominalType) Doc

func (t *NominalType) Doc() prettier.Doc

func (*NominalType) EndPosition

func (t *NominalType) EndPosition(memoryGauge common.MemoryGauge) Position

func (*NominalType) IsQualifiedName

func (t *NominalType) IsQualifiedName() bool

func (*NominalType) MarshalJSON

func (t *NominalType) MarshalJSON() ([]byte, error)

func (*NominalType) StartPosition

func (t *NominalType) StartPosition() Position

func (*NominalType) String

func (t *NominalType) String() string

type Operation

type Operation uint
const (
	OperationUnknown Operation = iota
	OperationOr
	OperationAnd
	OperationEqual
	OperationNotEqual
	OperationLess
	OperationGreater
	OperationLessEqual
	OperationGreaterEqual
	OperationPlus
	OperationMinus
	OperationMul
	OperationDiv
	OperationMod
	OperationNegate
	OperationNilCoalesce
	OperationMove
	OperationCast
	OperationFailableCast
	OperationForceCast
	OperationBitwiseOr
	OperationBitwiseXor
	OperationBitwiseAnd
	OperationBitwiseLeftShift
	OperationBitwiseRightShift
)

func (Operation) Category

func (s Operation) Category() string

func (Operation) MarshalJSON

func (s Operation) MarshalJSON() ([]byte, error)

func (Operation) String

func (i Operation) String() string

func (Operation) Symbol

func (s Operation) Symbol() string

type OptionalType

type OptionalType struct {
	Type   Type     `json:"ElementType"`
	EndPos Position `json:"-"`
}

func NewOptionalType

func NewOptionalType(
	memoryGauge common.MemoryGauge,
	typ Type,
	endPos Position,
) *OptionalType

func (*OptionalType) CheckEqual

func (t *OptionalType) CheckEqual(other Type, checker TypeEqualityChecker) error

func (*OptionalType) Doc

func (t *OptionalType) Doc() prettier.Doc

func (*OptionalType) EndPosition

func (t *OptionalType) EndPosition(memoryGauge common.MemoryGauge) Position

func (*OptionalType) MarshalJSON

func (t *OptionalType) MarshalJSON() ([]byte, error)

func (*OptionalType) StartPosition

func (t *OptionalType) StartPosition() Position

func (*OptionalType) String

func (t *OptionalType) String() string

type Parameter

type Parameter struct {
	TypeAnnotation  *TypeAnnotation
	DefaultArgument Expression
	Label           string
	Identifier      Identifier
	StartPos        Position `json:"-"`
}

func NewParameter

func NewParameter(
	gauge common.MemoryGauge,
	label string,
	identifier Identifier,
	typeAnnotation *TypeAnnotation,
	defaultArgument Expression,
	startPos Position,
) *Parameter

func (*Parameter) Doc

func (p *Parameter) Doc() prettier.Doc

func (*Parameter) EffectiveArgumentLabel

func (p *Parameter) EffectiveArgumentLabel() string

EffectiveArgumentLabel returns the effective argument label that an argument in a call must use: If no argument label is declared for parameter, the parameter name is used as the argument label

func (*Parameter) EndPosition

func (p *Parameter) EndPosition(memoryGauge common.MemoryGauge) Position

func (*Parameter) HasDefaultArgument

func (p *Parameter) HasDefaultArgument() bool

func (*Parameter) MarshalJSON

func (p *Parameter) MarshalJSON() ([]byte, error)

func (*Parameter) StartPosition

func (p *Parameter) StartPosition() Position

type ParameterList

type ParameterList struct {
	Parameters []*Parameter
	Range
	// contains filtered or unexported fields
}

func NewParameterList

func NewParameterList(
	gauge common.MemoryGauge,
	parameters []*Parameter,
	astRange Range,
) *ParameterList

func (*ParameterList) Doc

func (l *ParameterList) Doc() prettier.Doc

func (*ParameterList) EffectiveArgumentLabels

func (l *ParameterList) EffectiveArgumentLabels() []string

EffectiveArgumentLabels returns the effective argument labels that the arguments of a call must use: If no argument label is declared for parameter, the parameter name is used as the argument label

func (*ParameterList) IsEmpty

func (l *ParameterList) IsEmpty() bool

func (*ParameterList) ParametersByIdentifier

func (l *ParameterList) ParametersByIdentifier() map[string]*Parameter

func (*ParameterList) String

func (l *ParameterList) String() string

type PathExpression

type PathExpression struct {
	Domain     Identifier
	Identifier Identifier
	StartPos   Position `json:"-"`
}

func NewPathExpression

func NewPathExpression(
	gauge common.MemoryGauge,
	domain Identifier,
	identifier Identifier,
	startPos Position,
) *PathExpression

func (*PathExpression) Doc

func (e *PathExpression) Doc() prettier.Doc

func (*PathExpression) ElementType

func (*PathExpression) ElementType() ElementType

func (*PathExpression) EndPosition

func (e *PathExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*PathExpression) MarshalJSON

func (e *PathExpression) MarshalJSON() ([]byte, error)

func (*PathExpression) StartPosition

func (e *PathExpression) StartPosition() Position

func (*PathExpression) String

func (e *PathExpression) String() string

func (*PathExpression) Walk

func (*PathExpression) Walk(_ func(Element))

type PathExtractor

type PathExtractor interface {
	ExtractPath(extractor *ExpressionExtractor, expression *PathExpression) ExpressionExtraction
}

type Position

type Position struct {
	// offset, starting at 0
	Offset int
	// line number, starting at 1
	Line int
	// column number, starting at 0 (byte count)
	Column int
}

Position defines a row/column within a Cadence script.

func EarlierPosition

func EarlierPosition(p1, p2 *Position) *Position

func EarliestPosition

func EarliestPosition(p Position, ps ...*Position) (earliest Position)

func EndPosition

func EndPosition(memoryGauge common.MemoryGauge, startPosition Position, end int) Position

func NewPosition

func NewPosition(memoryGauge common.MemoryGauge, offset, line, column int) Position

func (Position) Compare

func (position Position) Compare(other Position) int

func (Position) Shifted

func (position Position) Shifted(memoryGauge common.MemoryGauge, length int) Position

func (Position) String

func (position Position) String() string

type PragmaDeclaration

type PragmaDeclaration struct {
	Expression Expression
	Range
}

func NewPragmaDeclaration

func NewPragmaDeclaration(gauge common.MemoryGauge, expression Expression, declRange Range) *PragmaDeclaration

func (*PragmaDeclaration) DeclarationAccess

func (d *PragmaDeclaration) DeclarationAccess() Access

func (*PragmaDeclaration) DeclarationDocString

func (d *PragmaDeclaration) DeclarationDocString() string

func (*PragmaDeclaration) DeclarationIdentifier

func (d *PragmaDeclaration) DeclarationIdentifier() *Identifier

func (*PragmaDeclaration) DeclarationKind

func (d *PragmaDeclaration) DeclarationKind() common.DeclarationKind

func (*PragmaDeclaration) DeclarationMembers

func (d *PragmaDeclaration) DeclarationMembers() *Members

func (*PragmaDeclaration) Doc

func (d *PragmaDeclaration) Doc() prettier.Doc

func (*PragmaDeclaration) ElementType

func (*PragmaDeclaration) ElementType() ElementType

func (*PragmaDeclaration) MarshalJSON

func (d *PragmaDeclaration) MarshalJSON() ([]byte, error)

func (*PragmaDeclaration) String

func (d *PragmaDeclaration) String() string

func (*PragmaDeclaration) Walk

func (d *PragmaDeclaration) Walk(walkChild func(Element))

type PrimitiveAccess

type PrimitiveAccess uint8
const (
	AccessNotSpecified PrimitiveAccess = iota
	AccessNone                         // "top" access, only used for mapping operations, not actually expressible in the language
	AccessSelf
	AccessContract
	AccessAccount
	AccessAll
	AccessPubSettableLegacy // Deprecated
)

func (PrimitiveAccess) Description

func (a PrimitiveAccess) Description() string

func (PrimitiveAccess) Keyword

func (a PrimitiveAccess) Keyword() string

func (PrimitiveAccess) MarshalJSON

func (a PrimitiveAccess) MarshalJSON() ([]byte, error)

func (PrimitiveAccess) String

func (i PrimitiveAccess) String() string

type Program

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

func NewProgram

func NewProgram(memoryGauge common.MemoryGauge, declarations []Declaration) *Program

func (*Program) AttachmentDeclarations

func (p *Program) AttachmentDeclarations() []*AttachmentDeclaration

func (*Program) CompositeDeclarations

func (p *Program) CompositeDeclarations() []*CompositeDeclaration

func (*Program) Declarations

func (p *Program) Declarations() []Declaration

func (*Program) Doc

func (p *Program) Doc() prettier.Doc

func (*Program) ElementType

func (*Program) ElementType() ElementType

func (*Program) EndPosition

func (p *Program) EndPosition(memoryGauge common.MemoryGauge) Position

func (*Program) EntitlementDeclarations

func (p *Program) EntitlementDeclarations() []*EntitlementDeclaration

func (*Program) EntitlementMappingDeclarations

func (p *Program) EntitlementMappingDeclarations() []*EntitlementMappingDeclaration

func (*Program) FunctionDeclarations

func (p *Program) FunctionDeclarations() []*FunctionDeclaration

func (*Program) ImportDeclarations

func (p *Program) ImportDeclarations() []*ImportDeclaration

func (*Program) InterfaceDeclarations

func (p *Program) InterfaceDeclarations() []*InterfaceDeclaration

func (*Program) MarshalJSON

func (p *Program) MarshalJSON() ([]byte, error)

func (*Program) PragmaDeclarations

func (p *Program) PragmaDeclarations() []*PragmaDeclaration

func (*Program) SoleContractDeclaration

func (p *Program) SoleContractDeclaration() *CompositeDeclaration

SoleContractDeclaration returns the sole contract declaration, if any, and if there are no other actionable declarations.

func (*Program) SoleContractInterfaceDeclaration

func (p *Program) SoleContractInterfaceDeclaration() *InterfaceDeclaration

SoleContractInterfaceDeclaration returns the sole contract interface declaration, if any, and if there are no other actionable declarations.

func (*Program) SoleTransactionDeclaration

func (p *Program) SoleTransactionDeclaration() *TransactionDeclaration

SoleTransactionDeclaration returns the sole transaction declaration, if any, and if there are no other actionable declarations.

func (*Program) StartPosition

func (p *Program) StartPosition() Position

func (*Program) TransactionDeclarations

func (p *Program) TransactionDeclarations() []*TransactionDeclaration

func (*Program) VariableDeclarations

func (p *Program) VariableDeclarations() []*VariableDeclaration

func (*Program) Walk

func (p *Program) Walk(walkChild func(Element))

type Range

type Range struct {
	StartPos Position
	EndPos   Position
}

func NewRange

func NewRange(memoryGauge common.MemoryGauge, startPos, endPos Position) Range

func NewRangeFromPositioned

func NewRangeFromPositioned(memoryGauge common.MemoryGauge, hasPosition HasPosition) Range

func NewUnmeteredRange

func NewUnmeteredRange(startPos, endPos Position) Range

func NewUnmeteredRangeFromPositioned

func NewUnmeteredRangeFromPositioned(hasPosition HasPosition) Range

func (Range) EndPosition

func (e Range) EndPosition(common.MemoryGauge) Position

func (Range) StartPosition

func (e Range) StartPosition() Position

type ReferenceExpression

type ReferenceExpression struct {
	Expression Expression
	StartPos   Position `json:"-"`
}

func NewReferenceExpression

func NewReferenceExpression(
	gauge common.MemoryGauge,
	expression Expression,
	startPos Position,
) *ReferenceExpression

func (*ReferenceExpression) Doc

func (e *ReferenceExpression) Doc() prettier.Doc

func (*ReferenceExpression) ElementType

func (*ReferenceExpression) ElementType() ElementType

func (*ReferenceExpression) EndPosition

func (e *ReferenceExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*ReferenceExpression) MarshalJSON

func (e *ReferenceExpression) MarshalJSON() ([]byte, error)

func (*ReferenceExpression) StartPosition

func (e *ReferenceExpression) StartPosition() Position

func (*ReferenceExpression) String

func (e *ReferenceExpression) String() string

func (*ReferenceExpression) Walk

func (e *ReferenceExpression) Walk(walkChild func(Element))

type ReferenceExtractor

type ReferenceExtractor interface {
	ExtractReference(extractor *ExpressionExtractor, expression *ReferenceExpression) ExpressionExtraction
}

type ReferenceType

type ReferenceType struct {
	Type             Type     `json:"ReferencedType"`
	StartPos         Position `json:"-"`
	LegacyAuthorized bool
	Authorization    Authorization `json:"Authorization"`
}

ReferenceType

func NewReferenceType

func NewReferenceType(
	memoryGauge common.MemoryGauge,
	authorization Authorization,
	typ Type,
	startPos Position,
) *ReferenceType

func (*ReferenceType) CheckEqual

func (t *ReferenceType) CheckEqual(other Type, checker TypeEqualityChecker) error

func (*ReferenceType) Doc

func (t *ReferenceType) Doc() prettier.Doc

func (*ReferenceType) EndPosition

func (t *ReferenceType) EndPosition(memoryGauge common.MemoryGauge) Position

func (*ReferenceType) MarshalJSON

func (t *ReferenceType) MarshalJSON() ([]byte, error)

func (*ReferenceType) StartPosition

func (t *ReferenceType) StartPosition() Position

func (*ReferenceType) String

func (t *ReferenceType) String() string

type RemoveStatement

type RemoveStatement struct {
	Attachment *NominalType
	Value      Expression
	StartPos   Position `json:"-"`
}

RemoveStatement

func NewRemoveStatement

func NewRemoveStatement(
	gauge common.MemoryGauge,
	attachment *NominalType,
	value Expression,
	startPos Position,
) *RemoveStatement

func (*RemoveStatement) Doc

func (s *RemoveStatement) Doc() prettier.Doc

func (*RemoveStatement) ElementType

func (*RemoveStatement) ElementType() ElementType

func (*RemoveStatement) EndPosition

func (s *RemoveStatement) EndPosition(memoryGauge common.MemoryGauge) Position

func (*RemoveStatement) MarshalJSON

func (s *RemoveStatement) MarshalJSON() ([]byte, error)

func (*RemoveStatement) StartPosition

func (s *RemoveStatement) StartPosition() Position

func (*RemoveStatement) String

func (s *RemoveStatement) String() string

func (*RemoveStatement) Walk

func (s *RemoveStatement) Walk(walkChild func(Element))

type ReturnStatement

type ReturnStatement struct {
	Expression Expression
	Range
}

func NewReturnStatement

func NewReturnStatement(gauge common.MemoryGauge, expression Expression, stmtRange Range) *ReturnStatement

func (*ReturnStatement) Doc

func (s *ReturnStatement) Doc() prettier.Doc

func (*ReturnStatement) ElementType

func (*ReturnStatement) ElementType() ElementType

func (*ReturnStatement) MarshalJSON

func (s *ReturnStatement) MarshalJSON() ([]byte, error)

func (*ReturnStatement) String

func (s *ReturnStatement) String() string

func (*ReturnStatement) Walk

func (s *ReturnStatement) Walk(walkChild func(Element))

type Separator

type Separator uint8
const (
	Disjunction Separator = iota
	Conjunction
)

func (Separator) String

func (s Separator) String() string

type SpecialFunctionDeclaration

type SpecialFunctionDeclaration struct {
	FunctionDeclaration *FunctionDeclaration
	Kind                common.DeclarationKind
}

func NewSpecialFunctionDeclaration

func NewSpecialFunctionDeclaration(
	gauge common.MemoryGauge,
	kind common.DeclarationKind,
	funcDecl *FunctionDeclaration,
) *SpecialFunctionDeclaration

func (*SpecialFunctionDeclaration) DeclarationAccess

func (d *SpecialFunctionDeclaration) DeclarationAccess() Access

func (*SpecialFunctionDeclaration) DeclarationDocString

func (d *SpecialFunctionDeclaration) DeclarationDocString() string

func (*SpecialFunctionDeclaration) DeclarationIdentifier

func (d *SpecialFunctionDeclaration) DeclarationIdentifier() *Identifier

func (*SpecialFunctionDeclaration) DeclarationKind

func (d *SpecialFunctionDeclaration) DeclarationKind() common.DeclarationKind

func (*SpecialFunctionDeclaration) DeclarationMembers

func (d *SpecialFunctionDeclaration) DeclarationMembers() *Members

func (*SpecialFunctionDeclaration) Doc

func (*SpecialFunctionDeclaration) ElementType

func (*SpecialFunctionDeclaration) ElementType() ElementType

func (*SpecialFunctionDeclaration) EndPosition

func (d *SpecialFunctionDeclaration) EndPosition(memoryGauge common.MemoryGauge) Position

func (*SpecialFunctionDeclaration) MarshalJSON

func (d *SpecialFunctionDeclaration) MarshalJSON() ([]byte, error)

func (*SpecialFunctionDeclaration) StartPosition

func (d *SpecialFunctionDeclaration) StartPosition() Position

func (*SpecialFunctionDeclaration) String

func (d *SpecialFunctionDeclaration) String() string

func (*SpecialFunctionDeclaration) Walk

func (d *SpecialFunctionDeclaration) Walk(walkChild func(Element))

type Statement

type Statement interface {
	Element
	fmt.Stringer

	Doc() prettier.Doc
	// contains filtered or unexported methods
}

type StatementDeclarationVisitor

type StatementDeclarationVisitor[T any] interface {
	VisitVariableDeclaration(*VariableDeclaration) T
	VisitFunctionDeclaration(*FunctionDeclaration) T
	VisitSpecialFunctionDeclaration(*SpecialFunctionDeclaration) T
	VisitCompositeDeclaration(*CompositeDeclaration) T
	VisitAttachmentDeclaration(*AttachmentDeclaration) T
	VisitInterfaceDeclaration(*InterfaceDeclaration) T
	VisitEntitlementDeclaration(*EntitlementDeclaration) T
	VisitEntitlementMappingDeclaration(*EntitlementMappingDeclaration) T
	VisitTransactionDeclaration(*TransactionDeclaration) T
}

type StatementVisitor

type StatementVisitor[T any] interface {
	StatementDeclarationVisitor[T]
	VisitReturnStatement(*ReturnStatement) T
	VisitContinueStatement(*ContinueStatement) T
	VisitBreakStatement(*BreakStatement) T
	VisitIfStatement(*IfStatement) T
	VisitForStatement(*ForStatement) T
	VisitAssignmentStatement(*AssignmentStatement) T
	VisitWhileStatement(*WhileStatement) T
	VisitSwapStatement(*SwapStatement) T
	VisitSwitchStatement(*SwitchStatement) T
	VisitEmitStatement(*EmitStatement) T
	VisitExpressionStatement(*ExpressionStatement) T
	VisitRemoveStatement(*RemoveStatement) T
}

type StringExpression

type StringExpression struct {
	Value string
	Range
}

func NewStringExpression

func NewStringExpression(gauge common.MemoryGauge, value string, exprRange Range) *StringExpression

func (*StringExpression) Doc

func (e *StringExpression) Doc() prettier.Doc

func (*StringExpression) ElementType

func (*StringExpression) ElementType() ElementType

func (*StringExpression) MarshalJSON

func (e *StringExpression) MarshalJSON() ([]byte, error)

func (*StringExpression) String

func (e *StringExpression) String() string

func (*StringExpression) Walk

func (*StringExpression) Walk(_ func(Element))

type StringExtractor

type StringExtractor interface {
	ExtractString(extractor *ExpressionExtractor, expression *StringExpression) ExpressionExtraction
}

type StringTemplateExpression added in v1.3.0

type StringTemplateExpression struct {
	// Values and Expressions are assumed to be interleaved, V[0] + E[0] + V[1] + ... + E[n-1] + V[n]
	// this is enforced in the parser e.g. "a\(b)c" will be parsed as follows
	// Values: 			[]string{"a","c"}
	// Expressions:		[]Expression{b}
	Values      []string
	Expressions []Expression
	Range
}

func NewStringTemplateExpression added in v1.3.0

func NewStringTemplateExpression(
	gauge common.MemoryGauge,
	values []string,
	exprs []Expression,
	exprRange Range,
) *StringTemplateExpression

func (*StringTemplateExpression) Doc added in v1.3.0

func (*StringTemplateExpression) ElementType added in v1.3.0

func (*StringTemplateExpression) ElementType() ElementType

func (*StringTemplateExpression) MarshalJSON added in v1.3.0

func (e *StringTemplateExpression) MarshalJSON() ([]byte, error)

func (*StringTemplateExpression) String added in v1.3.0

func (e *StringTemplateExpression) String() string

func (*StringTemplateExpression) Walk added in v1.3.0

func (e *StringTemplateExpression) Walk(walkChild func(Element))

type StringTemplateExtractor added in v1.3.0

type StringTemplateExtractor interface {
	ExtractStringTemplate(extractor *ExpressionExtractor, expression *StringTemplateExpression) ExpressionExtraction
}

type SwapStatement

type SwapStatement struct {
	Left  Expression
	Right Expression
}

func NewSwapStatement

func NewSwapStatement(gauge common.MemoryGauge, expression Expression, right Expression) *SwapStatement

func (*SwapStatement) Doc

func (s *SwapStatement) Doc() prettier.Doc

func (*SwapStatement) ElementType

func (*SwapStatement) ElementType() ElementType

func (*SwapStatement) EndPosition

func (s *SwapStatement) EndPosition(memoryGauge common.MemoryGauge) Position

func (*SwapStatement) MarshalJSON

func (s *SwapStatement) MarshalJSON() ([]byte, error)

func (*SwapStatement) StartPosition

func (s *SwapStatement) StartPosition() Position

func (*SwapStatement) String

func (s *SwapStatement) String() string

func (*SwapStatement) Walk

func (s *SwapStatement) Walk(walkChild func(Element))

type SwitchCase

type SwitchCase struct {
	Expression Expression
	Statements []Statement
	Range
}

func (*SwitchCase) Doc

func (s *SwitchCase) Doc() prettier.Doc

func (*SwitchCase) MarshalJSON

func (s *SwitchCase) MarshalJSON() ([]byte, error)

type SwitchStatement

type SwitchStatement struct {
	Expression Expression
	Cases      []*SwitchCase
	Range
}

func NewSwitchStatement

func NewSwitchStatement(
	gauge common.MemoryGauge,
	expression Expression,
	cases []*SwitchCase,
	stmtRange Range,
) *SwitchStatement

func (*SwitchStatement) Doc

func (s *SwitchStatement) Doc() prettier.Doc

func (*SwitchStatement) ElementType

func (*SwitchStatement) ElementType() ElementType

func (*SwitchStatement) MarshalJSON

func (s *SwitchStatement) MarshalJSON() ([]byte, error)

func (*SwitchStatement) String

func (s *SwitchStatement) String() string

func (*SwitchStatement) Walk

func (s *SwitchStatement) Walk(walkChild func(Element))

type TestCondition

type TestCondition struct {
	Test    Expression
	Message Expression
}

func (TestCondition) CodeElement

func (c TestCondition) CodeElement() Element

func (TestCondition) Doc

func (c TestCondition) Doc() prettier.Doc

func (TestCondition) ElementType

func (c TestCondition) ElementType() ElementType

func (TestCondition) EndPosition

func (c TestCondition) EndPosition(memoryGauge common.MemoryGauge) Position

func (TestCondition) MarshalJSON

func (c TestCondition) MarshalJSON() ([]byte, error)

func (TestCondition) StartPosition

func (c TestCondition) StartPosition() Position

func (TestCondition) Walk

func (c TestCondition) Walk(walkChild func(Element))

type TextEdit

type TextEdit struct {
	Replacement string
	Insertion   string
	Range
}

type TransactionDeclaration

type TransactionDeclaration struct {
	ParameterList  *ParameterList
	Prepare        *SpecialFunctionDeclaration
	PreConditions  *Conditions
	Execute        *SpecialFunctionDeclaration
	PostConditions *Conditions
	DocString      string
	Fields         []*FieldDeclaration
	Range
}

func NewTransactionDeclaration

func NewTransactionDeclaration(
	gauge common.MemoryGauge,
	parameterList *ParameterList,
	fields []*FieldDeclaration,
	prepare *SpecialFunctionDeclaration,
	preConditions *Conditions,
	postConditions *Conditions,
	execute *SpecialFunctionDeclaration,
	docString string,
	declRange Range,
) *TransactionDeclaration

func (*TransactionDeclaration) DeclarationAccess

func (d *TransactionDeclaration) DeclarationAccess() Access

func (*TransactionDeclaration) DeclarationDocString

func (d *TransactionDeclaration) DeclarationDocString() string

func (*TransactionDeclaration) DeclarationIdentifier

func (d *TransactionDeclaration) DeclarationIdentifier() *Identifier

func (*TransactionDeclaration) DeclarationKind

func (d *TransactionDeclaration) DeclarationKind() common.DeclarationKind

func (*TransactionDeclaration) DeclarationMembers

func (d *TransactionDeclaration) DeclarationMembers() *Members

func (*TransactionDeclaration) Doc

func (*TransactionDeclaration) ElementType

func (*TransactionDeclaration) ElementType() ElementType

func (*TransactionDeclaration) MarshalJSON

func (d *TransactionDeclaration) MarshalJSON() ([]byte, error)

func (*TransactionDeclaration) String

func (d *TransactionDeclaration) String() string

func (*TransactionDeclaration) Walk

func (d *TransactionDeclaration) Walk(walkChild func(Element))

type Transfer

type Transfer struct {
	Operation TransferOperation
	Pos       Position `json:"-"`
}

Transfer represents the operation in variable declarations and assignments

func NewTransfer

func NewTransfer(memoryGauge common.MemoryGauge, operation TransferOperation, position Position) *Transfer

func (Transfer) Doc

func (f Transfer) Doc() prettier.Doc

func (Transfer) EndPosition

func (f Transfer) EndPosition(memoryGauge common.MemoryGauge) Position

func (Transfer) MarshalJSON

func (f Transfer) MarshalJSON() ([]byte, error)

func (Transfer) StartPosition

func (f Transfer) StartPosition() Position

type TransferOperation

type TransferOperation uint
const (
	TransferOperationUnknown TransferOperation = iota
	TransferOperationCopy
	TransferOperationMove
	TransferOperationMoveForced
)

func (TransferOperation) IsMove

func (k TransferOperation) IsMove() bool

func (TransferOperation) MarshalJSON

func (k TransferOperation) MarshalJSON() ([]byte, error)

func (TransferOperation) Operator

func (k TransferOperation) Operator() string

func (TransferOperation) String

func (i TransferOperation) String() string

type Type

type Type interface {
	HasPosition
	fmt.Stringer

	Doc() prettier.Doc
	CheckEqual(other Type, checker TypeEqualityChecker) error
	// contains filtered or unexported methods
}

func ExpressionAsType

func ExpressionAsType(expression Expression) Type

ExpressionAsType attempts to convert an expression to a type. Some expressions can be considered both an expression and a type

type TypeAnnotation

type TypeAnnotation struct {
	Type       Type     `json:"AnnotatedType"`
	StartPos   Position `json:"-"`
	IsResource bool
}

func NewTypeAnnotation

func NewTypeAnnotation(
	memoryGauge common.MemoryGauge,
	isResource bool,
	typ Type,
	startPos Position,
) *TypeAnnotation

func (*TypeAnnotation) Doc

func (t *TypeAnnotation) Doc() prettier.Doc

func (*TypeAnnotation) EndPosition

func (t *TypeAnnotation) EndPosition(memoryGauge common.MemoryGauge) Position

func (*TypeAnnotation) MarshalJSON

func (t *TypeAnnotation) MarshalJSON() ([]byte, error)

func (*TypeAnnotation) StartPosition

func (t *TypeAnnotation) StartPosition() Position

func (*TypeAnnotation) String

func (t *TypeAnnotation) String() string

type TypeEqualityChecker

type TypeEqualityChecker interface {
	CheckNominalTypeEquality(*NominalType, Type) error
	CheckOptionalTypeEquality(*OptionalType, Type) error
	CheckVariableSizedTypeEquality(*VariableSizedType, Type) error
	CheckConstantSizedTypeEquality(*ConstantSizedType, Type) error
	CheckDictionaryTypeEquality(*DictionaryType, Type) error
	CheckFunctionTypeEquality(*FunctionType, Type) error
	CheckReferenceTypeEquality(*ReferenceType, Type) error
	CheckIntersectionTypeEquality(*IntersectionType, Type) error
	CheckInstantiationTypeEquality(*InstantiationType, Type) error
}

type TypeParameter

type TypeParameter struct {
	Identifier Identifier
	TypeBound  *TypeAnnotation
}

func NewTypeParameter

func NewTypeParameter(
	gauge common.MemoryGauge,
	identifier Identifier,
	typeBound *TypeAnnotation,
) *TypeParameter

func (*TypeParameter) EndPosition

func (t *TypeParameter) EndPosition(memoryGauge common.MemoryGauge) Position

func (*TypeParameter) StartPosition

func (t *TypeParameter) StartPosition() Position

type TypeParameterList

type TypeParameterList struct {
	TypeParameters []*TypeParameter

	Range
	// contains filtered or unexported fields
}

func NewTypeParameterList

func NewTypeParameterList(
	gauge common.MemoryGauge,
	typeParameters []*TypeParameter,
	astRange Range,
) *TypeParameterList

func (*TypeParameterList) Doc

func (l *TypeParameterList) Doc() prettier.Doc

func (*TypeParameterList) IsEmpty

func (l *TypeParameterList) IsEmpty() bool

func (*TypeParameterList) String

func (l *TypeParameterList) String() string

func (*TypeParameterList) TypeParametersByIdentifier

func (l *TypeParameterList) TypeParametersByIdentifier() map[string]*TypeParameter

type UnaryExpression

type UnaryExpression struct {
	Expression Expression
	StartPos   Position `json:"-"`
	Operation  Operation
}

func NewUnaryExpression

func NewUnaryExpression(
	gauge common.MemoryGauge,
	operation Operation,
	expression Expression,
	startPos Position,
) *UnaryExpression

func (*UnaryExpression) Doc

func (e *UnaryExpression) Doc() prettier.Doc

func (*UnaryExpression) ElementType

func (*UnaryExpression) ElementType() ElementType

func (*UnaryExpression) EndPosition

func (e *UnaryExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*UnaryExpression) MarshalJSON

func (e *UnaryExpression) MarshalJSON() ([]byte, error)

func (*UnaryExpression) StartPosition

func (e *UnaryExpression) StartPosition() Position

func (*UnaryExpression) String

func (e *UnaryExpression) String() string

func (*UnaryExpression) Walk

func (e *UnaryExpression) Walk(walkChild func(Element))

type UnaryExtractor

type UnaryExtractor interface {
	ExtractUnary(extractor *ExpressionExtractor, expression *UnaryExpression) ExpressionExtraction
}

type VariableDeclaration

type VariableDeclaration struct {
	Value             Expression
	SecondValue       Expression
	TypeAnnotation    *TypeAnnotation
	Transfer          *Transfer
	SecondTransfer    *Transfer
	ParentIfStatement *IfStatement `json:"-"`
	DocString         string
	Identifier        Identifier
	StartPos          Position `json:"-"`
	Access            Access
	IsConstant        bool
}

func NewEmptyVariableDeclaration

func NewEmptyVariableDeclaration(gauge common.MemoryGauge) *VariableDeclaration

func NewVariableDeclaration

func NewVariableDeclaration(
	gauge common.MemoryGauge,
	access Access,
	isLet bool,
	identifier Identifier,
	typeAnnotation *TypeAnnotation,
	value Expression,
	transfer *Transfer,
	startPos Position,
	secondTransfer *Transfer,
	secondValue Expression,
	docString string,
) *VariableDeclaration

func (*VariableDeclaration) DeclarationAccess

func (d *VariableDeclaration) DeclarationAccess() Access

func (*VariableDeclaration) DeclarationDocString

func (d *VariableDeclaration) DeclarationDocString() string

func (*VariableDeclaration) DeclarationIdentifier

func (d *VariableDeclaration) DeclarationIdentifier() *Identifier

func (*VariableDeclaration) DeclarationKind

func (d *VariableDeclaration) DeclarationKind() common.DeclarationKind

func (*VariableDeclaration) DeclarationMembers

func (d *VariableDeclaration) DeclarationMembers() *Members

func (*VariableDeclaration) Doc

func (d *VariableDeclaration) Doc() prettier.Doc

func (*VariableDeclaration) ElementType

func (*VariableDeclaration) ElementType() ElementType

func (*VariableDeclaration) EndPosition

func (d *VariableDeclaration) EndPosition(memoryGauge common.MemoryGauge) Position

func (*VariableDeclaration) MarshalJSON

func (d *VariableDeclaration) MarshalJSON() ([]byte, error)

func (*VariableDeclaration) StartPosition

func (d *VariableDeclaration) StartPosition() Position

func (*VariableDeclaration) String

func (d *VariableDeclaration) String() string

func (*VariableDeclaration) Walk

func (d *VariableDeclaration) Walk(walkChild func(Element))

type VariableKind

type VariableKind uint
const (
	VariableKindNotSpecified VariableKind = iota
	VariableKindVariable
	VariableKindConstant
)

func (VariableKind) Keyword

func (k VariableKind) Keyword() string

func (VariableKind) MarshalJSON

func (k VariableKind) MarshalJSON() ([]byte, error)

func (VariableKind) Name

func (k VariableKind) Name() string

func (VariableKind) String

func (i VariableKind) String() string

type VariableSizedType

type VariableSizedType struct {
	Type Type `json:"ElementType"`
	Range
}

func NewVariableSizedType

func NewVariableSizedType(
	memoryGauge common.MemoryGauge,
	typ Type,
	astRange Range,
) *VariableSizedType

func (*VariableSizedType) CheckEqual

func (t *VariableSizedType) CheckEqual(other Type, checker TypeEqualityChecker) error

func (*VariableSizedType) Doc

func (t *VariableSizedType) Doc() prettier.Doc

func (*VariableSizedType) MarshalJSON

func (t *VariableSizedType) MarshalJSON() ([]byte, error)

func (*VariableSizedType) String

func (t *VariableSizedType) String() string

type VoidExpression

type VoidExpression struct {
	Range
}

()

func NewVoidExpression

func NewVoidExpression(
	gauge common.MemoryGauge,
	startPos Position,
	endPos Position,
) *VoidExpression

func (*VoidExpression) Doc

func (v *VoidExpression) Doc() prettier.Doc

func (*VoidExpression) ElementType

func (v *VoidExpression) ElementType() ElementType

func (*VoidExpression) EndPosition

func (v *VoidExpression) EndPosition(memoryGauge common.MemoryGauge) Position

func (*VoidExpression) StartPosition

func (v *VoidExpression) StartPosition() Position

func (*VoidExpression) String

func (v *VoidExpression) String() string

func (*VoidExpression) Walk

func (v *VoidExpression) Walk(walkChild func(Element))

type VoidExtractor

type VoidExtractor interface {
	ExtractVoid(extractor *ExpressionExtractor, expression *VoidExpression) ExpressionExtraction
}

type Walker

type Walker interface {
	Walk(element Element) Walker
}

type WhileStatement

type WhileStatement struct {
	Test     Expression
	Block    *Block
	StartPos Position `json:"-"`
}

func NewWhileStatement

func NewWhileStatement(
	gauge common.MemoryGauge,
	expression Expression,
	block *Block,
	startPos Position,
) *WhileStatement

func (*WhileStatement) Doc

func (s *WhileStatement) Doc() prettier.Doc

func (*WhileStatement) ElementType

func (*WhileStatement) ElementType() ElementType

func (*WhileStatement) EndPosition

func (s *WhileStatement) EndPosition(memoryGauge common.MemoryGauge) Position

func (*WhileStatement) MarshalJSON

func (s *WhileStatement) MarshalJSON() ([]byte, error)

func (*WhileStatement) StartPosition

func (s *WhileStatement) StartPosition() Position

func (*WhileStatement) String

func (s *WhileStatement) String() string

func (*WhileStatement) Walk

func (s *WhileStatement) Walk(walkChild func(Element))

Jump to

Keyboard shortcuts

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