ast

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const AddressPrefix = "A"
View Source
const NilConstant = "nil"

Variables

Functions

func LocationsMatch

func LocationsMatch(first, second Location) bool

Types

type Access

type Access uint
const (
	AccessNotSpecified Access = iota
	AccessPrivate
	AccessContract
	AccessAccount
	AccessPublic
	AccessPublicSettable
)

func (Access) Description

func (a Access) Description() string

func (Access) IsLessPermissiveThan

func (a Access) IsLessPermissiveThan(otherAccess Access) bool

func (Access) Keyword

func (a Access) Keyword() string

func (Access) String

func (i Access) String() string

type AccessExpression

type AccessExpression interface {
	Expression

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

type AddressLocation

type AddressLocation []byte

func (AddressLocation) ID

func (l AddressLocation) ID() LocationID

func (AddressLocation) String

func (l AddressLocation) String() string

func (AddressLocation) ToAddress

func (l AddressLocation) ToAddress() common.Address

type Argument

type Argument struct {
	Label         string
	LabelStartPos *Position
	LabelEndPos   *Position
	Expression    Expression
}

func (Argument) String

func (a Argument) String() string

type Arguments

type Arguments []*Argument

func (Arguments) String

func (args Arguments) String() string

type ArrayExpression

type ArrayExpression struct {
	Values []Expression
	Range
}

func (*ArrayExpression) Accept

func (e *ArrayExpression) Accept(visitor Visitor) Repr

func (*ArrayExpression) AcceptExp

func (e *ArrayExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*ArrayExpression) String

func (e *ArrayExpression) String() string

type ArrayExtractor

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

type AssignmentStatement

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

func (*AssignmentStatement) Accept

func (s *AssignmentStatement) Accept(visitor Visitor) Repr

func (*AssignmentStatement) EndPosition

func (s *AssignmentStatement) EndPosition() Position

func (*AssignmentStatement) StartPosition

func (s *AssignmentStatement) StartPosition() Position

type BinaryExpression

type BinaryExpression struct {
	Operation Operation
	Left      Expression
	Right     Expression
}

func (*BinaryExpression) Accept

func (e *BinaryExpression) Accept(visitor Visitor) Repr

func (*BinaryExpression) AcceptExp

func (e *BinaryExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*BinaryExpression) EndPosition

func (e *BinaryExpression) EndPosition() Position

func (*BinaryExpression) StartPosition

func (e *BinaryExpression) StartPosition() Position

func (*BinaryExpression) String

func (e *BinaryExpression) String() string

type BinaryExtractor

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

type Block

type Block struct {
	Statements []Statement
	Range
}

func (*Block) Accept

func (b *Block) Accept(visitor Visitor) Repr

type BoolExpression

type BoolExpression struct {
	Value bool
	Range
}

func (*BoolExpression) Accept

func (e *BoolExpression) Accept(visitor Visitor) Repr

func (*BoolExpression) AcceptExp

func (e *BoolExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*BoolExpression) String

func (e *BoolExpression) String() string

type BoolExtractor

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

type BreakStatement

type BreakStatement struct {
	Range
}

func (*BreakStatement) Accept

func (s *BreakStatement) Accept(visitor Visitor) Repr

type CastingExpression

type CastingExpression struct {
	Expression                Expression
	Operation                 Operation
	TypeAnnotation            *TypeAnnotation
	ParentVariableDeclaration *VariableDeclaration
}

func (*CastingExpression) Accept

func (e *CastingExpression) Accept(visitor Visitor) Repr

func (*CastingExpression) AcceptExp

func (e *CastingExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*CastingExpression) EndPosition

func (e *CastingExpression) EndPosition() Position

func (*CastingExpression) StartPosition

func (e *CastingExpression) StartPosition() Position

func (*CastingExpression) String

func (e *CastingExpression) String() string

type CastingExtractor

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

type CompositeDeclaration

type CompositeDeclaration struct {
	Access                Access
	CompositeKind         common.CompositeKind
	Identifier            Identifier
	Conformances          []*NominalType
	Members               *Members
	CompositeDeclarations []*CompositeDeclaration
	InterfaceDeclarations []*InterfaceDeclaration
	Range
}

func (*CompositeDeclaration) Accept

func (d *CompositeDeclaration) Accept(visitor Visitor) Repr

func (*CompositeDeclaration) DeclarationAccess

func (d *CompositeDeclaration) DeclarationAccess() Access

func (*CompositeDeclaration) DeclarationIdentifier

func (d *CompositeDeclaration) DeclarationIdentifier() *Identifier

func (*CompositeDeclaration) DeclarationKind

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

type Condition

type Condition struct {
	Kind    ConditionKind
	Test    Expression
	Message Expression
}

func (*Condition) Accept

func (c *Condition) Accept(visitor Visitor) Repr

type ConditionKind

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

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 (*ConditionalExpression) Accept

func (e *ConditionalExpression) Accept(visitor Visitor) Repr

func (*ConditionalExpression) AcceptExp

func (e *ConditionalExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*ConditionalExpression) EndPosition

func (e *ConditionalExpression) EndPosition() Position

func (*ConditionalExpression) StartPosition

func (e *ConditionalExpression) StartPosition() Position

func (*ConditionalExpression) String

func (e *ConditionalExpression) String() string

type ConditionalExtractor

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

type Conditions

type Conditions []*Condition

func (*Conditions) Append

func (c *Conditions) Append(conditions Conditions)

type ConstantSizedType

type ConstantSizedType struct {
	Type Type
	Size *IntegerExpression
	Range
}

func (*ConstantSizedType) String

func (t *ConstantSizedType) String() string

type ContinueStatement

type ContinueStatement struct {
	Range
}

func (*ContinueStatement) Accept

func (s *ContinueStatement) Accept(visitor Visitor) Repr

type CreateExpression

type CreateExpression struct {
	InvocationExpression *InvocationExpression
	StartPos             Position
}

func (*CreateExpression) Accept

func (e *CreateExpression) Accept(visitor Visitor) Repr

func (*CreateExpression) AcceptExp

func (e *CreateExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*CreateExpression) EndPosition

func (e *CreateExpression) EndPosition() Position

func (*CreateExpression) StartPosition

func (e *CreateExpression) StartPosition() Position

func (*CreateExpression) String

func (e *CreateExpression) String() string

type CreateExtractor

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

type CyclicImportsError

type CyclicImportsError struct {
	Location Location
}

func (CyclicImportsError) Error

func (e CyclicImportsError) Error() string

type Declaration

type Declaration interface {
	Element

	DeclarationIdentifier() *Identifier
	DeclarationKind() common.DeclarationKind
	DeclarationAccess() Access
	// contains filtered or unexported methods
}

type DestroyExpression

type DestroyExpression struct {
	Expression Expression
	StartPos   Position
}

func (*DestroyExpression) Accept

func (e *DestroyExpression) Accept(visitor Visitor) Repr

func (*DestroyExpression) AcceptExp

func (e *DestroyExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*DestroyExpression) EndPosition

func (e *DestroyExpression) EndPosition() Position

func (*DestroyExpression) StartPosition

func (e *DestroyExpression) StartPosition() Position

func (*DestroyExpression) String

func (e *DestroyExpression) String() string

type DestroyExtractor

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

type DictionaryExpression

type DictionaryExpression struct {
	Entries []Entry
	Range
}

func (*DictionaryExpression) Accept

func (e *DictionaryExpression) Accept(visitor Visitor) Repr

func (*DictionaryExpression) AcceptExp

func (e *DictionaryExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*DictionaryExpression) String

func (e *DictionaryExpression) String() string

type DictionaryExtractor

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

type DictionaryType

type DictionaryType struct {
	KeyType   Type
	ValueType Type
	Range
}

func (*DictionaryType) String

func (t *DictionaryType) String() string

type Element

type Element interface {
	HasPosition
	Accept(Visitor) Repr
}

type EmitStatement

type EmitStatement struct {
	InvocationExpression *InvocationExpression
	StartPos             Position
}

func (*EmitStatement) Accept

func (s *EmitStatement) Accept(visitor Visitor) Repr

func (*EmitStatement) EndPosition

func (s *EmitStatement) EndPosition() Position

func (*EmitStatement) StartPosition

func (s *EmitStatement) StartPosition() Position

type Entry

type Entry struct {
	Key   Expression
	Value Expression
}

type Expression

type Expression interface {
	Element
	fmt.Stringer
	IfStatementTest

	AcceptExp(ExpressionVisitor) Repr
	// contains filtered or unexported methods
}

type ExpressionExtraction

type ExpressionExtraction struct {
	RewrittenExpression  Expression
	ExtractedExpressions []ExtractedExpression
}

type ExpressionExtractor

type ExpressionExtractor struct {
	BoolExtractor        BoolExtractor
	NilExtractor         NilExtractor
	IntExtractor         IntExtractor
	FixedPointExtractor  FixedPointExtractor
	StringExtractor      StringExtractor
	ArrayExtractor       ArrayExtractor
	DictionaryExtractor  DictionaryExtractor
	IdentifierExtractor  IdentifierExtractor
	InvocationExtractor  InvocationExtractor
	MemberExtractor      MemberExtractor
	IndexExtractor       IndexExtractor
	ConditionalExtractor ConditionalExtractor
	UnaryExtractor       UnaryExtractor
	BinaryExtractor      BinaryExtractor
	FunctionExtractor    FunctionExtractor
	CastingExtractor     CastingExtractor
	CreateExtractor      CreateExtractor
	DestroyExtractor     DestroyExtractor
	ReferenceExtractor   ReferenceExtractor
	ForceExtractor       ForceExtractor
	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) 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) ExtractUnary

func (extractor *ExpressionExtractor) ExtractUnary(expression *UnaryExpression) 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) Repr

func (*ExpressionExtractor) VisitBinaryExpression

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

func (*ExpressionExtractor) VisitBoolExpression

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

func (*ExpressionExtractor) VisitCastingExpression

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

func (*ExpressionExtractor) VisitConditionalExpression

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

func (*ExpressionExtractor) VisitCreateExpression

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

func (*ExpressionExtractor) VisitDestroyExpression

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

func (*ExpressionExtractor) VisitDictionaryExpression

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

func (*ExpressionExtractor) VisitExpressions

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

func (*ExpressionExtractor) VisitFixedPointExpression

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

func (*ExpressionExtractor) VisitForceExpression

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

func (*ExpressionExtractor) VisitFunctionExpression

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

func (*ExpressionExtractor) VisitIdentifierExpression

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

func (*ExpressionExtractor) VisitIndexExpression

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

func (*ExpressionExtractor) VisitIntegerExpression

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

func (*ExpressionExtractor) VisitInvocationExpression

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

func (*ExpressionExtractor) VisitMemberExpression

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

func (*ExpressionExtractor) VisitNilExpression

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

func (*ExpressionExtractor) VisitPathExpression

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

func (*ExpressionExtractor) VisitReferenceExpression

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

func (*ExpressionExtractor) VisitStringExpression

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

func (*ExpressionExtractor) VisitUnaryExpression

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

type ExpressionStatement

type ExpressionStatement struct {
	Expression Expression
}

func (*ExpressionStatement) Accept

func (s *ExpressionStatement) Accept(visitor Visitor) Repr

func (*ExpressionStatement) EndPosition

func (s *ExpressionStatement) EndPosition() Position

func (*ExpressionStatement) StartPosition

func (s *ExpressionStatement) StartPosition() Position

type ExpressionVisitor

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

type ExtractedExpression

type ExtractedExpression struct {
	Identifier Identifier
	Expression Expression
}

type FieldDeclaration

type FieldDeclaration struct {
	Access         Access
	VariableKind   VariableKind
	Identifier     Identifier
	TypeAnnotation *TypeAnnotation
	Range
}

func (*FieldDeclaration) Accept

func (f *FieldDeclaration) Accept(visitor Visitor) Repr

func (*FieldDeclaration) DeclarationAccess

func (f *FieldDeclaration) DeclarationAccess() Access

func (*FieldDeclaration) DeclarationIdentifier

func (f *FieldDeclaration) DeclarationIdentifier() *Identifier

func (*FieldDeclaration) DeclarationKind

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

type FixedPointExpression

type FixedPointExpression struct {
	Negative        bool
	UnsignedInteger *big.Int
	Fractional      *big.Int
	Scale           uint
	Range
}

func (*FixedPointExpression) Accept

func (e *FixedPointExpression) Accept(visitor Visitor) Repr

func (*FixedPointExpression) AcceptExp

func (e *FixedPointExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*FixedPointExpression) String

func (e *FixedPointExpression) String() string

type FixedPointExtractor

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

type ForStatement

type ForStatement struct {
	Identifier Identifier
	Value      Expression
	Block      *Block
	StartPos   Position
}

func (*ForStatement) Accept

func (s *ForStatement) Accept(visitor Visitor) Repr

func (*ForStatement) EndPosition

func (s *ForStatement) EndPosition() Position

func (*ForStatement) StartPosition

func (s *ForStatement) StartPosition() Position

type ForceExpression

type ForceExpression struct {
	Expression Expression
	EndPos     Position
}

func (*ForceExpression) Accept

func (e *ForceExpression) Accept(visitor Visitor) Repr

func (*ForceExpression) AcceptExp

func (e *ForceExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*ForceExpression) EndPosition

func (e *ForceExpression) EndPosition() Position

func (*ForceExpression) StartPosition

func (e *ForceExpression) StartPosition() Position

func (*ForceExpression) String

func (e *ForceExpression) String() string

type ForceExtractor

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

type FunctionBlock

type FunctionBlock struct {
	*Block
	PreConditions  *Conditions
	PostConditions *Conditions
}

func (*FunctionBlock) Accept

func (b *FunctionBlock) Accept(visitor Visitor) Repr

type FunctionDeclaration

type FunctionDeclaration struct {
	Access               Access
	Identifier           Identifier
	ParameterList        *ParameterList
	ReturnTypeAnnotation *TypeAnnotation
	FunctionBlock        *FunctionBlock
	StartPos             Position
}

func (*FunctionDeclaration) Accept

func (f *FunctionDeclaration) Accept(visitor Visitor) Repr

func (*FunctionDeclaration) DeclarationAccess

func (f *FunctionDeclaration) DeclarationAccess() Access

func (*FunctionDeclaration) DeclarationIdentifier

func (f *FunctionDeclaration) DeclarationIdentifier() *Identifier

func (*FunctionDeclaration) DeclarationKind

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

func (*FunctionDeclaration) EndPosition

func (f *FunctionDeclaration) EndPosition() Position

func (*FunctionDeclaration) StartPosition

func (f *FunctionDeclaration) StartPosition() Position

func (*FunctionDeclaration) ToExpression

func (f *FunctionDeclaration) ToExpression() *FunctionExpression

type FunctionExpression

type FunctionExpression struct {
	ParameterList        *ParameterList
	ReturnTypeAnnotation *TypeAnnotation
	FunctionBlock        *FunctionBlock
	StartPos             Position
}

func (*FunctionExpression) Accept

func (e *FunctionExpression) Accept(visitor Visitor) Repr

func (*FunctionExpression) AcceptExp

func (e *FunctionExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*FunctionExpression) EndPosition

func (e *FunctionExpression) EndPosition() Position

func (*FunctionExpression) StartPosition

func (e *FunctionExpression) StartPosition() Position

func (*FunctionExpression) String

func (e *FunctionExpression) String() string

type FunctionExtractor

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

type FunctionType

type FunctionType struct {
	ParameterTypeAnnotations []*TypeAnnotation
	ReturnTypeAnnotation     *TypeAnnotation
	Range
}

func (*FunctionType) String

func (t *FunctionType) String() string

type HasImportLocation

type HasImportLocation interface {
	ImportLocation() Location
}

type HasPosition

type HasPosition interface {
	StartPosition() Position
	EndPosition() Position
}

type Identifier

type Identifier struct {
	Identifier string
	Pos        Position
}

func (Identifier) EndPosition

func (i Identifier) EndPosition() Position

func (Identifier) StartPosition

func (i Identifier) StartPosition() Position

func (Identifier) String

func (i Identifier) String() string

type IdentifierExpression

type IdentifierExpression struct {
	Identifier
}

func (*IdentifierExpression) Accept

func (e *IdentifierExpression) Accept(visitor Visitor) Repr

func (*IdentifierExpression) AcceptExp

func (e *IdentifierExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*IdentifierExpression) String

func (e *IdentifierExpression) String() string

type IdentifierExtractor

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

type IfStatement

type IfStatement struct {
	Test     IfStatementTest
	Then     *Block
	Else     *Block
	StartPos Position
}

func (*IfStatement) Accept

func (s *IfStatement) Accept(visitor Visitor) Repr

func (*IfStatement) EndPosition

func (s *IfStatement) EndPosition() Position

func (*IfStatement) StartPosition

func (s *IfStatement) StartPosition() Position

type IfStatementTest

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

type ImportDeclaration

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

func (*ImportDeclaration) Accept

func (v *ImportDeclaration) Accept(visitor Visitor) Repr

func (*ImportDeclaration) DeclarationAccess

func (v *ImportDeclaration) DeclarationAccess() Access

func (*ImportDeclaration) DeclarationIdentifier

func (v *ImportDeclaration) DeclarationIdentifier() *Identifier

func (*ImportDeclaration) DeclarationKind

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

type ImportResolver

type ImportResolver func(location Location) (*Program, error)

type IndexExpression

type IndexExpression struct {
	TargetExpression   Expression
	IndexingExpression Expression
	Range
}

func (*IndexExpression) Accept

func (e *IndexExpression) Accept(visitor Visitor) Repr

func (*IndexExpression) AcceptExp

func (e *IndexExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*IndexExpression) AccessedExpression

func (e *IndexExpression) AccessedExpression() Expression

func (*IndexExpression) String

func (e *IndexExpression) String() string

type IndexExtractor

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

type IntExtractor

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

type IntegerExpression

type IntegerExpression struct {
	Value *big.Int
	Base  int
	Range
}

func (*IntegerExpression) Accept

func (e *IntegerExpression) Accept(visitor Visitor) Repr

func (*IntegerExpression) AcceptExp

func (e *IntegerExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*IntegerExpression) String

func (e *IntegerExpression) String() string

type InterfaceDeclaration

type InterfaceDeclaration struct {
	Access                Access
	CompositeKind         common.CompositeKind
	Identifier            Identifier
	Members               *Members
	CompositeDeclarations []*CompositeDeclaration
	InterfaceDeclarations []*InterfaceDeclaration
	Range
}

func (*InterfaceDeclaration) Accept

func (d *InterfaceDeclaration) Accept(visitor Visitor) Repr

func (*InterfaceDeclaration) DeclarationAccess

func (d *InterfaceDeclaration) DeclarationAccess() Access

func (*InterfaceDeclaration) DeclarationIdentifier

func (d *InterfaceDeclaration) DeclarationIdentifier() *Identifier

func (*InterfaceDeclaration) DeclarationKind

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

type InvocationExpression

type InvocationExpression struct {
	InvokedExpression Expression
	TypeArguments     []*TypeAnnotation
	Arguments         Arguments
	EndPos            Position
}

func (*InvocationExpression) Accept

func (e *InvocationExpression) Accept(visitor Visitor) Repr

func (*InvocationExpression) AcceptExp

func (e *InvocationExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*InvocationExpression) EndPosition

func (e *InvocationExpression) EndPosition() Position

func (*InvocationExpression) StartPosition

func (e *InvocationExpression) StartPosition() Position

func (*InvocationExpression) String

func (e *InvocationExpression) String() string

type InvocationExtractor

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

type Location

type Location interface {
	// ID returns the canonical ID for this import location.
	ID() LocationID
}

Location describes the origin of a Cadence script. This could be a file, a transaction, or a smart contract.

func LocationFromTypeID added in v0.2.0

func LocationFromTypeID(typeID string) Location

type LocationID

type LocationID string

type MemberExpression

type MemberExpression struct {
	Expression Expression
	Optional   bool
	Identifier Identifier
}

func (*MemberExpression) Accept

func (e *MemberExpression) Accept(visitor Visitor) Repr

func (*MemberExpression) AcceptExp

func (e *MemberExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*MemberExpression) AccessedExpression

func (e *MemberExpression) AccessedExpression() Expression

func (*MemberExpression) EndPosition

func (e *MemberExpression) EndPosition() Position

func (*MemberExpression) StartPosition

func (e *MemberExpression) StartPosition() Position

func (*MemberExpression) String

func (e *MemberExpression) String() string

type MemberExtractor

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

type Members

type Members struct {
	Fields []*FieldDeclaration

	// All special functions, such as initializers and destructors.
	// Use `Initializers()` and `Destructors()` to get subsets
	SpecialFunctions []*SpecialFunctionDeclaration

	Functions []*FunctionDeclaration
	// contains filtered or unexported fields
}

func (*Members) Destructor

func (m *Members) Destructor() *SpecialFunctionDeclaration

Destructor returns the first destructor, if any

func (*Members) Destructors

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

func (*Members) FieldPosition

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

func (*Members) FieldsByIdentifier

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

func (*Members) FunctionsByIdentifier

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

func (*Members) Initializers

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

type NilExpression

type NilExpression struct {
	Pos Position
}

func (*NilExpression) Accept

func (e *NilExpression) Accept(visitor Visitor) Repr

func (*NilExpression) AcceptExp

func (e *NilExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*NilExpression) EndPosition

func (e *NilExpression) EndPosition() Position

func (*NilExpression) StartPosition

func (e *NilExpression) StartPosition() Position

func (*NilExpression) String

func (e *NilExpression) String() string

type NilExtractor

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

type NominalType

type NominalType struct {
	Identifier        Identifier
	NestedIdentifiers []Identifier
}

func (*NominalType) EndPosition

func (t *NominalType) EndPosition() Position

func (*NominalType) StartPosition

func (t *NominalType) StartPosition() Position

func (*NominalType) String

func (t *NominalType) String() string

type NotAnElement

type NotAnElement struct{}

func (NotAnElement) Accept

func (NotAnElement) Accept(Visitor) Repr

func (NotAnElement) EndPosition

func (NotAnElement) EndPosition() Position

func (NotAnElement) StartPosition

func (NotAnElement) StartPosition() Position

type Operation

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

func (Operation) String

func (i Operation) String() string

func (Operation) Symbol

func (s Operation) Symbol() string

type OptionalType

type OptionalType struct {
	Type   Type
	EndPos Position
}

func (*OptionalType) EndPosition

func (t *OptionalType) EndPosition() Position

func (*OptionalType) StartPosition

func (t *OptionalType) StartPosition() Position

func (*OptionalType) String

func (t *OptionalType) String() string

type Parameter

type Parameter struct {
	Label          string
	Identifier     Identifier
	TypeAnnotation *TypeAnnotation
	Range
}

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

type ParameterList

type ParameterList struct {
	Parameters []*Parameter

	Range
	// contains filtered or unexported fields
}

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) ParametersByIdentifier

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

type PathExpression

type PathExpression struct {
	StartPos   Position
	Domain     Identifier
	Identifier Identifier
}

func (*PathExpression) Accept

func (e *PathExpression) Accept(visitor Visitor) Repr

func (*PathExpression) AcceptExp

func (e *PathExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*PathExpression) EndPosition

func (e *PathExpression) EndPosition() Position

func (*PathExpression) StartPosition

func (e *PathExpression) StartPosition() Position

func (*PathExpression) String

func (e *PathExpression) String() string

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 EndPosition

func EndPosition(startPosition Position, end int) Position

func (Position) Compare

func (position Position) Compare(other Position) int

func (Position) Hash

func (position Position) Hash() (result uint32)

func (Position) Shifted

func (position Position) Shifted(length int) Position

type Program

type Program struct {
	// all declarations, in the order they are defined
	Declarations []Declaration
	// contains filtered or unexported fields
}

func (*Program) Accept

func (p *Program) Accept(visitor Visitor) Repr

func (*Program) CompositeDeclarations

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

func (*Program) EndPosition

func (p *Program) EndPosition() Position

func (*Program) FunctionDeclarations

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

func (*Program) ImportDeclarations

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

func (*Program) ImportLocations

func (p *Program) ImportLocations() []Location

ImportLocations returns the import locations declared by this program.

func (*Program) ImportedPrograms

func (p *Program) ImportedPrograms() map[LocationID]*Program

ImportedPrograms returns the sub-programs imported by this program, indexed by location ID.

func (*Program) InterfaceDeclarations

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

func (*Program) ResolveImports

func (p *Program) ResolveImports(resolver ImportResolver) error

func (*Program) StartPosition

func (p *Program) StartPosition() Position

func (*Program) TransactionDeclarations

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

type Range

type Range struct {
	StartPos Position
	EndPos   Position
}

func NewRangeFromPositioned

func NewRangeFromPositioned(hasPosition HasPosition) Range

func (*Range) EndPosition

func (e *Range) EndPosition() Position

func (*Range) StartPosition

func (e *Range) StartPosition() Position

type ReferenceExpression

type ReferenceExpression struct {
	Expression Expression
	Type       Type
	StartPos   Position
}

func (*ReferenceExpression) Accept

func (e *ReferenceExpression) Accept(visitor Visitor) Repr

func (*ReferenceExpression) AcceptExp

func (e *ReferenceExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*ReferenceExpression) EndPosition

func (e *ReferenceExpression) EndPosition() Position

func (*ReferenceExpression) StartPosition

func (e *ReferenceExpression) StartPosition() Position

func (*ReferenceExpression) String

func (e *ReferenceExpression) String() string

type ReferenceExtractor

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

type ReferenceType

type ReferenceType struct {
	Authorized bool
	Type       Type
	StartPos   Position
}

func (*ReferenceType) EndPosition

func (t *ReferenceType) EndPosition() Position

func (*ReferenceType) StartPosition

func (t *ReferenceType) StartPosition() Position

func (*ReferenceType) String

func (t *ReferenceType) String() string

type Repr

type Repr interface{}

type RestrictedType

type RestrictedType struct {
	Type         Type
	Restrictions []*NominalType
	Range
}

func (*RestrictedType) String

func (t *RestrictedType) String() string

type ReturnStatement

type ReturnStatement struct {
	Expression Expression
	Range
}

func (*ReturnStatement) Accept

func (s *ReturnStatement) Accept(visitor Visitor) Repr

type SpecialFunctionDeclaration

type SpecialFunctionDeclaration struct {
	DeclarationKind common.DeclarationKind
	*FunctionDeclaration
}

type Statement

type Statement interface {
	Element
	// contains filtered or unexported methods
}

type StatementVisitor

type StatementVisitor interface {
	VisitReturnStatement(*ReturnStatement) Repr
	VisitBreakStatement(*BreakStatement) Repr
	VisitContinueStatement(*ContinueStatement) Repr
	VisitIfStatement(*IfStatement) Repr
	VisitWhileStatement(*WhileStatement) Repr
	VisitForStatement(*ForStatement) Repr
	VisitEmitStatement(*EmitStatement) Repr
	VisitVariableDeclaration(*VariableDeclaration) Repr
	VisitAssignmentStatement(*AssignmentStatement) Repr
	VisitSwapStatement(*SwapStatement) Repr
	VisitExpressionStatement(*ExpressionStatement) Repr
}

type StringExpression

type StringExpression struct {
	Value string
	Range
}

func (*StringExpression) Accept

func (e *StringExpression) Accept(visitor Visitor) Repr

func (*StringExpression) AcceptExp

func (e *StringExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*StringExpression) String

func (e *StringExpression) String() string

type StringExtractor

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

type StringLocation

type StringLocation string

func (StringLocation) ID

func (l StringLocation) ID() LocationID

type SwapStatement

type SwapStatement struct {
	Left  Expression
	Right Expression
}

func (*SwapStatement) Accept

func (s *SwapStatement) Accept(visitor Visitor) Repr

func (*SwapStatement) EndPosition

func (s *SwapStatement) EndPosition() Position

func (*SwapStatement) StartPosition

func (s *SwapStatement) StartPosition() Position

type TargetExpression

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

type TransactionDeclaration

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

func (*TransactionDeclaration) Accept

func (d *TransactionDeclaration) Accept(visitor Visitor) Repr

func (*TransactionDeclaration) DeclarationAccess

func (d *TransactionDeclaration) DeclarationAccess() Access

func (*TransactionDeclaration) DeclarationIdentifier

func (d *TransactionDeclaration) DeclarationIdentifier() *Identifier

func (*TransactionDeclaration) DeclarationKind

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

type Transfer

type Transfer struct {
	Operation TransferOperation
	Pos       Position
}

Transfer represents the operation in variable declarations and assignments

func (Transfer) EndPosition

func (f Transfer) EndPosition() Position

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) Operator

func (k TransferOperation) Operator() string

func (TransferOperation) String

func (i TransferOperation) String() string

type Type

type Type interface {
	HasPosition
	fmt.Stringer
	// 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 {
	IsResource bool
	Type       Type
	StartPos   Position
}

func (*TypeAnnotation) EndPosition

func (e *TypeAnnotation) EndPosition() Position

func (*TypeAnnotation) StartPosition

func (e *TypeAnnotation) StartPosition() Position

func (*TypeAnnotation) String

func (e *TypeAnnotation) String() string

type UnaryExpression

type UnaryExpression struct {
	Operation  Operation
	Expression Expression
	Range
}

func (*UnaryExpression) Accept

func (e *UnaryExpression) Accept(visitor Visitor) Repr

func (*UnaryExpression) AcceptExp

func (e *UnaryExpression) AcceptExp(visitor ExpressionVisitor) Repr

func (*UnaryExpression) String

func (e *UnaryExpression) String() string

type UnaryExtractor

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

type VariableDeclaration

type VariableDeclaration struct {
	Access            Access
	IsConstant        bool
	Identifier        Identifier
	TypeAnnotation    *TypeAnnotation
	Value             Expression
	Transfer          *Transfer
	StartPos          Position
	SecondTransfer    *Transfer
	SecondValue       Expression
	ParentIfStatement *IfStatement
}

func (*VariableDeclaration) Accept

func (d *VariableDeclaration) Accept(visitor Visitor) Repr

func (*VariableDeclaration) DeclarationAccess

func (d *VariableDeclaration) DeclarationAccess() Access

func (*VariableDeclaration) DeclarationIdentifier

func (d *VariableDeclaration) DeclarationIdentifier() *Identifier

func (*VariableDeclaration) DeclarationKind

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

func (*VariableDeclaration) EndPosition

func (d *VariableDeclaration) EndPosition() Position

func (*VariableDeclaration) StartPosition

func (d *VariableDeclaration) StartPosition() Position

type VariableKind

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

func (VariableKind) Keyword

func (k VariableKind) Keyword() string

func (VariableKind) Name

func (k VariableKind) Name() string

func (VariableKind) String

func (i VariableKind) String() string

type VariableSizedType

type VariableSizedType struct {
	Type Type
	Range
}

func (*VariableSizedType) String

func (t *VariableSizedType) String() string

type Visitor

type Visitor interface {
	StatementVisitor
	ExpressionVisitor
	VisitProgram(*Program) Repr
	VisitFunctionDeclaration(*FunctionDeclaration) Repr
	VisitBlock(*Block) Repr
	VisitFunctionBlock(*FunctionBlock) Repr
	VisitCompositeDeclaration(*CompositeDeclaration) Repr
	VisitInterfaceDeclaration(*InterfaceDeclaration) Repr
	VisitFieldDeclaration(*FieldDeclaration) Repr
	VisitCondition(*Condition) Repr
	VisitImportDeclaration(*ImportDeclaration) Repr
	VisitTransactionDeclaration(*TransactionDeclaration) Repr
}

type WhileStatement

type WhileStatement struct {
	Test     Expression
	Block    *Block
	StartPos Position
}

func (*WhileStatement) Accept

func (s *WhileStatement) Accept(visitor Visitor) Repr

func (*WhileStatement) EndPosition

func (s *WhileStatement) EndPosition() Position

func (*WhileStatement) StartPosition

func (s *WhileStatement) StartPosition() Position

Jump to

Keyboard shortcuts

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