ast

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 24 Imported by: 10

Documentation

Overview

Package ast provides an Abstract Syntax Tree (AST) representation for Solidity contracts. The ast package offers a set of data structures and functions to parse Solidity source code and construct an AST that represents the structure and semantics of the contracts.

The package supports the creation of nodes for various Solidity constructs such as contracts, functions, modifiers, variables, statements, expressions, events, errors, enums, structs, and more. It also includes utilities for traversing and inspecting the AST, as well as generating code from the AST.

By utilizing the ast package, developers can programmatically analyze, manipulate, and generate Solidity code. It serves as a foundation for building tools, analyzers, compilers, and other applications that require deep understanding and processing of Solidity contracts.

Note: The ast package is designed to be used in conjunction with a Solidity parser, provided by ANTLR, to generate the initial AST from Solidity source code. It then enriches the AST with additional information and functionality specific to the Solidity language.

Package ast defines data structures and methods for abstract syntax tree nodes used in a specific programming language. The package contains definitions for various AST nodes that represent different elements of the programming language's syntax.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTypedStruct

func NewTypedStruct(m protoreflect.ProtoMessage, protoType string) *v3.TypedStruct

NewTypedStruct creates a new v3.TypedStruct instance based on the provided protoreflect.ProtoMessage and protoType. It marshals the given ProtoMessage into JSON, then unmarshals it into a structpb.Struct, and constructs a TypedStruct with the appropriate type URL and structpb.Value. It returns the created TypedStruct instance or nil in case of errors during marshaling or unmarshaling.

func ToNode added in v0.3.4

func ToNode[T any](node Node[NodeType]) (T, bool)

ToNode takes a value of type T, which implements the Node interface, and returns the value along if casting was ok.

Types

type ASTBuilder

type ASTBuilder struct {
	*parser.BaseSolidityParserListener
	// contains filtered or unexported fields
}

ASTBuilder is a structure that helps in building and manipulating an Abstract Syntax Tree (AST). It contains a reference to a Solidity parser, the source code of the Solidity files, and various nodes of the AST.

func NewAstBuilder

func NewAstBuilder(parser *parser.SolidityParser, sources *solgo.Sources) *ASTBuilder

NewAstBuilder creates a new ASTBuilder with the provided Solidity parser and source code.

func (*ASTBuilder) EnterConstantVariableDeclaration added in v0.3.1

func (b *ASTBuilder) EnterConstantVariableDeclaration(ctx *parser.ConstantVariableDeclarationContext)

func (*ASTBuilder) EnterEnumDefinition added in v0.3.1

func (b *ASTBuilder) EnterEnumDefinition(ctx *parser.EnumDefinitionContext)

There can be global enums that are outside of the contract body, so we need to handle them here.

func (*ASTBuilder) EnterErrorDefinition added in v0.3.1

func (b *ASTBuilder) EnterErrorDefinition(ctx *parser.ErrorDefinitionContext)

There can be global enums that are outside of the contract body, so we need to handle them here.

func (*ASTBuilder) EnterEventDefinition added in v0.3.1

func (b *ASTBuilder) EnterEventDefinition(ctx *parser.EventDefinitionContext)

There can be global enums that are outside of the contract body, so we need to handle them here.

func (*ASTBuilder) EnterEveryRule

func (b *ASTBuilder) EnterEveryRule(ctx antlr.ParserRuleContext)

EnterEveryRule is called when the parser enters any rule in the grammar. It is used to search for licenses and comments in the code. ANTLR parser, by default, has comments disabled to be parsed as tokens. Therefore, we manually search for them using the CommonTokenStream.

func (*ASTBuilder) EnterSourceUnit

func (b *ASTBuilder) EnterSourceUnit(ctx *parser.SourceUnitContext)

EnterSourceUnit is called when the ASTBuilder enters a source unit context. It initializes a new root node and source units based on the context.

func (*ASTBuilder) EnterStateVariableDeclaration added in v0.3.1

func (b *ASTBuilder) EnterStateVariableDeclaration(ctx *parser.StateVariableDeclarationContext)

func (*ASTBuilder) EnterStructDefinition added in v0.3.1

func (b *ASTBuilder) EnterStructDefinition(ctx *parser.StructDefinitionContext)

func (*ASTBuilder) EnterUserDefinedValueTypeDefinition added in v0.3.1

func (b *ASTBuilder) EnterUserDefinedValueTypeDefinition(ctx *parser.UserDefinedValueTypeDefinitionContext)

func (*ASTBuilder) EnterVariableDeclaration added in v0.3.1

func (b *ASTBuilder) EnterVariableDeclaration(ctx *parser.VariableDeclarationContext)

func (*ASTBuilder) ExitSourceUnit

func (b *ASTBuilder) ExitSourceUnit(ctx *parser.SourceUnitContext)

ExitSourceUnit is called when the ASTBuilder exits a source unit context. It appends the source units to the root node.

func (*ASTBuilder) GarbageCollect

func (b *ASTBuilder) GarbageCollect()

GarbageCollect cleans up the ASTBuilder after resolving references.

func (*ASTBuilder) GetImports added in v0.3.5

func (b *ASTBuilder) GetImports() []Node[NodeType]

func (*ASTBuilder) GetNextID

func (b *ASTBuilder) GetNextID() int64

GetNextID generates the next unique identifier for nodes in the abstract syntax tree (AST). It uses an atomic operation to ensure thread safety.

func (*ASTBuilder) GetParser

func (b *ASTBuilder) GetParser() *parser.SolidityParser

GetParser returns the Solidity parser of the ASTBuilder.

func (*ASTBuilder) GetResolver

func (b *ASTBuilder) GetResolver() *Resolver

GetResolver returns the Resolver of the ASTBuilder.

func (*ASTBuilder) GetRoot

func (b *ASTBuilder) GetRoot() *RootNode

GetRoot returns the root node of the AST from the Tree of the ASTBuilder.

func (*ASTBuilder) GetTree

func (b *ASTBuilder) GetTree() *Tree

GetTree returns the Tree of the ASTBuilder.

func (*ASTBuilder) ImportFromJSON added in v0.3.1

func (b *ASTBuilder) ImportFromJSON(ctx context.Context, jsonBytes []byte) (*RootNode, error)

ImportFromJSON imports the AST from a JSON byte array. Note that parser content won't be imported. Only the results for future manipulation.

func (*ASTBuilder) InterfaceToJSON

func (b *ASTBuilder) InterfaceToJSON(data interface{}) ([]byte, error)

InterfaceToJSON converts the provided data to a JSON byte array.

func (*ASTBuilder) ResolveReferences

func (b *ASTBuilder) ResolveReferences() []error

ResolveReferences resolves the references in the AST using the Resolver of the ASTBuilder.

func (*ASTBuilder) ToJSON

func (b *ASTBuilder) ToJSON() ([]byte, error)

ToJSON converts the root node of the AST to a JSON byte array.

func (*ASTBuilder) ToProto

func (b *ASTBuilder) ToProto() *ast_pb.RootSourceUnit

type AndOperation

type AndOperation struct {
	*ASTBuilder

	Id               int64              `json:"id"`
	NodeType         ast_pb.NodeType    `json:"nodeType"`
	Src              SrcNode            `json:"src"`
	Expressions      []Node[NodeType]   `json:"expressions"`
	TypeDescriptions []*TypeDescription `json:"typeDescriptions"`
}

AndOperation represents an 'and' operation in an abstract syntax tree.

func NewAndOperationExpression

func NewAndOperationExpression(b *ASTBuilder) *AndOperation

NewAndOperationExpression creates a new AndOperation instance.

func (*AndOperation) GetExpressions

func (f *AndOperation) GetExpressions() []Node[NodeType]

GetExpressions returns the expressions within the AndOperation.

func (*AndOperation) GetId

func (f *AndOperation) GetId() int64

GetId returns the ID of the AndOperation.

func (*AndOperation) GetNodes

func (f *AndOperation) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the AndOperation.

func (*AndOperation) GetSrc

func (f *AndOperation) GetSrc() SrcNode

GetSrc returns the source information of the AndOperation.

func (*AndOperation) GetType

func (f *AndOperation) GetType() ast_pb.NodeType

GetType returns the NodeType of the AndOperation.

func (*AndOperation) GetTypeDescription

func (f *AndOperation) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the AndOperation.

func (*AndOperation) Parse

func (f *AndOperation) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.AndOperationContext,
) Node[NodeType]

Parse parses the AndOperation node from the parsing context and associates it with other nodes.

func (*AndOperation) SetReferenceDescriptor

func (b *AndOperation) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the AndOperation node. This function always returns false for now.

func (*AndOperation) ToProto

func (f *AndOperation) ToProto() NodeType

ToProto converts the AndOperation to its corresponding protocol buffer representation.

func (*AndOperation) UnmarshalJSON added in v0.3.1

func (f *AndOperation) UnmarshalJSON(data []byte) error

type Assignment

type Assignment struct {
	*ASTBuilder

	Id                    int64            `json:"id"`                              // Unique identifier for the Assignment node.
	NodeType              ast_pb.NodeType  `json:"nodeType"`                        // Type of the AST node.
	Src                   SrcNode          `json:"src"`                             // Source location information.
	Expression            Node[NodeType]   `json:"expression,omitempty"`            // Expression for the assignment (if used).
	Operator              ast_pb.Operator  `json:"operator,omitempty"`              // Operator used in the assignment.
	LeftExpression        Node[NodeType]   `json:"leftExpression,omitempty"`        // Left-hand side expression.
	RightExpression       Node[NodeType]   `json:"rightExpression,omitempty"`       // Right-hand side expression.
	ReferencedDeclaration int64            `json:"referencedDeclaration,omitempty"` // Referenced declaration identifier (if used).
	TypeDescription       *TypeDescription `json:"typeDescription,omitempty"`       // Type description associated with the Assignment node.
	Text                  string           `json:"text,omitempty"`                  // Text of the Assignment node.
}

Assignment represents an assignment statement in the AST.

func NewAssignment

func NewAssignment(b *ASTBuilder) *Assignment

NewAssignment creates a new Assignment node with a given ASTBuilder.

func (*Assignment) GetExpression

func (a *Assignment) GetExpression() Node[NodeType]

GetExpression returns the expression of the Assignment node.

func (*Assignment) GetId

func (a *Assignment) GetId() int64

GetId returns the ID of the Assignment node.

func (*Assignment) GetLeftExpression

func (a *Assignment) GetLeftExpression() Node[NodeType]

GetLeftExpression returns the left expression of the Assignment node.

func (*Assignment) GetNodes

func (a *Assignment) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the Assignment node.

func (*Assignment) GetOperator

func (a *Assignment) GetOperator() ast_pb.Operator

GetOperator returns the operator of the Assignment node.

func (*Assignment) GetReferencedDeclaration

func (a *Assignment) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the Assignment node.

func (*Assignment) GetRightExpression

func (a *Assignment) GetRightExpression() Node[NodeType]

GetRightExpression returns the right expression of the Assignment node.

func (*Assignment) GetSrc

func (a *Assignment) GetSrc() SrcNode

GetSrc returns the SrcNode of the Assignment node.

func (*Assignment) GetType

func (a *Assignment) GetType() ast_pb.NodeType

GetType returns the NodeType of the Assignment node.

func (*Assignment) GetTypeDescription

func (a *Assignment) GetTypeDescription() *TypeDescription

GetTypeDescription returns the TypeDescription of the Assignment node.

func (*Assignment) Parse

func (a *Assignment) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.AssignmentContext,
) Node[NodeType]

Parse parses an assignment context into the Assignment node.

func (*Assignment) ParseStatement

func (a *Assignment) ParseStatement(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	parentNode Node[NodeType],
	eCtx *parser.ExpressionStatementContext,
	parentNodeId int64,
	ctx *parser.AssignmentContext,
)

ParseStatement parses an expression statement context into the Assignment node.

func (*Assignment) SetReferenceDescriptor

func (a *Assignment) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Assignment node.

func (*Assignment) ToProto

func (a *Assignment) ToProto() NodeType

ToProto returns a protobuf representation of the Assignment node.

func (*Assignment) ToString added in v0.3.2

func (a *Assignment) ToString() string

ToString returns the string representation of the Assignment node.

func (*Assignment) UnmarshalJSON added in v0.3.1

func (a *Assignment) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the Assignment node data from the JSON byte array.

type BaseContract

type BaseContract struct {
	// Id is the unique identifier of the base contract.
	Id int64 `json:"id"`
	// NodeType is the type of the node.
	// For a BaseContract, this is always NodeType_BASE_CONTRACT.
	NodeType ast_pb.NodeType `json:"nodeType"`
	// Src contains source information about the node, such as its line and column numbers in the source file.
	Src SrcNode `json:"src"`
	// BaseName is the name of the base contract.
	BaseName *BaseContractName `json:"baseName"`
}

BaseContract represents a base contract in a Solidity source file. A base contract is a contract that is inherited by another contract.

func (*BaseContract) GetBaseName

func (b *BaseContract) GetBaseName() *BaseContractName

GetBaseName returns the name of the base contract.

func (*BaseContract) GetId

func (b *BaseContract) GetId() int64

GetId returns the unique identifier of the base contract.

func (*BaseContract) GetSrc

func (b *BaseContract) GetSrc() SrcNode

GetSrc returns source information about the node, such as its line and column numbers in the source file.

func (*BaseContract) GetType

func (b *BaseContract) GetType() ast_pb.NodeType

GetType returns the type of the node. For a BaseContract, this is always NodeType_BASE_CONTRACT.

func (*BaseContract) ToProto

func (b *BaseContract) ToProto() *ast_pb.BaseContract

ToProto returns the protobuf representation of the base contract.

type BaseContractName

type BaseContractName struct {
	// Id is the unique identifier of the base contract name.
	Id int64 `json:"id"`
	// NodeType is the type of the node.
	// For a BaseContractName, this is always NodeType_BASE_CONTRACT_NAME.
	NodeType ast_pb.NodeType `json:"nodeType"`
	// Src contains source information about the node, such as its line and column numbers in the source file.
	Src SrcNode `json:"src"`
	// Name is the name of the base contract.
	Name string `json:"name"`
	// ReferencedDeclaration is the unique identifier of the source unit declaration that this name references.
	ReferencedDeclaration int64 `json:"referencedDeclaration"`
	// ContractReferencedDeclaration is the unique identifier of the source unit contract declaration that this name references.
	ContractReferencedDeclaration int64 `json:"contractReferencedDeclaration"`
}

BaseContractName represents the name of a base contract in a Solidity source file.

func (*BaseContractName) GetContractReferencedDeclaration added in v0.3.2

func (b *BaseContractName) GetContractReferencedDeclaration() int64

GetContractReferencedDeclaration returns the unique identifier of the source unit contract declaration that this name references.

func (*BaseContractName) GetId

func (b *BaseContractName) GetId() int64

GetId returns the unique identifier of the base contract name.

func (*BaseContractName) GetName

func (b *BaseContractName) GetName() string

GetName returns the name of the base contract name.

func (*BaseContractName) GetReferencedDeclaration

func (b *BaseContractName) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the unique identifier of the source unit contract declaration that this name references.

func (*BaseContractName) GetSrc

func (b *BaseContractName) GetSrc() SrcNode

GetSrc returns source information about the node, such as its line and column numbers in the source file.

func (*BaseContractName) GetType

func (b *BaseContractName) GetType() ast_pb.NodeType

GetType returns the type of the node. For a BaseContractName, this is always NodeType_BASE_CONTRACT_NAME.

func (*BaseContractName) ToProto

ToProto returns the protobuf representation of the base contract name.

type BinaryOperation

type BinaryOperation struct {
	*ASTBuilder // Embedding the ASTBuilder to provide common functionality across all AST nodes.

	// Id is the unique identifier of the binary operation.
	Id int64 `json:"id"`
	// IsConstant indicates whether the binary operation is a constant.
	Constant bool `json:"isConstant"`
	// IsPure indicates whether the binary operation is pure (i.e., it does not read or modify state).
	Pure bool `json:"isPure"`
	// NodeType is the type of the node.
	// For a BinaryOperation, this is always NodeType_BINARY_OPERATION.
	NodeType ast_pb.NodeType `json:"nodeType"`
	// Src contains source information about the node, such as its line and column numbers in the source file.
	Src SrcNode `json:"src"`
	// Operator is the operator of the binary operation.
	Operator ast_pb.Operator `json:"operator"`
	// LeftExpression is the left operand of the binary operation.
	LeftExpression Node[NodeType] `json:"leftExpression"`
	// RightExpression is the right operand of the binary operation.
	RightExpression Node[NodeType] `json:"rightExpression"`
	// TypeDescription is the type description of the binary operation.
	TypeDescription *TypeDescription `json:"typeDescription"`
}

BinaryOperation represents a binary operation in a Solidity source file. A binary operation is an operation that operates on two operands like +, -, *, / etc.

func NewBinaryOperationExpression

func NewBinaryOperationExpression(b *ASTBuilder) *BinaryOperation

NewBinaryOperationExpression is a constructor function that initializes a new BinaryOperation with a unique ID and the NodeType set to NodeType_BINARY_OPERATION.

func (*BinaryOperation) GetId

func (a *BinaryOperation) GetId() int64

GetId is a getter method that returns the unique identifier of the binary operation.

func (*BinaryOperation) GetLeftExpression

func (a *BinaryOperation) GetLeftExpression() Node[NodeType]

GetLeftExpression is a getter method that returns the left operand of the binary operation.

func (*BinaryOperation) GetNodes

func (a *BinaryOperation) GetNodes() []Node[NodeType]

GetNodes is a getter method that returns a slice of the operands of the binary operation.

func (*BinaryOperation) GetOperator

func (a *BinaryOperation) GetOperator() ast_pb.Operator

GetOperator is a getter method that returns the operator of the binary operation.

func (*BinaryOperation) GetRightExpression

func (a *BinaryOperation) GetRightExpression() Node[NodeType]

GetRightExpression is a getter method that returns the right operand of the binary operation.

func (*BinaryOperation) GetSrc

func (a *BinaryOperation) GetSrc() SrcNode

GetSrc is a getter method that returns the source information of the binary operation.

func (*BinaryOperation) GetType

func (a *BinaryOperation) GetType() ast_pb.NodeType

GetType is a getter method that returns the node type of the binary operation.

func (*BinaryOperation) GetTypeDescription

func (a *BinaryOperation) GetTypeDescription() *TypeDescription

GetTypeDescription is a getter method that returns the type description of the left operand of the binary operation.

func (*BinaryOperation) IsConstant

func (a *BinaryOperation) IsConstant() bool

IsConstant is a getter method that returns whether the binary operation is a constant.

func (*BinaryOperation) IsPure

func (a *BinaryOperation) IsPure() bool

IsPure is a getter method that returns whether the binary operation is pure.

func (*BinaryOperation) ParseAddSub

func (a *BinaryOperation) ParseAddSub(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.AddSubOperationContext,
) Node[NodeType]

ParseAddSub is a method that parses addition and subtraction operations.

func (*BinaryOperation) ParseEqualityComparison

func (a *BinaryOperation) ParseEqualityComparison(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.EqualityComparisonContext,
) Node[NodeType]

ParseEqualityComparison is a method that parses equality comparison operations.

func (*BinaryOperation) ParseMulDivMod

func (a *BinaryOperation) ParseMulDivMod(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.MulDivModOperationContext,
) Node[NodeType]

ParseMulDivMod is a method that parses multiplication, division, and modulo operations.

func (*BinaryOperation) ParseOr

func (a *BinaryOperation) ParseOr(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.OrOperationContext,
) Node[NodeType]

ParseOr is a method that parses or comparison operations.

func (*BinaryOperation) ParseOrderComparison

func (a *BinaryOperation) ParseOrderComparison(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.OrderComparisonContext,
) Node[NodeType]

ParseOrderComparison is a method that parses order comparison operations.

func (*BinaryOperation) SetReferenceDescriptor

func (a *BinaryOperation) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the BinaryOperation node.

func (*BinaryOperation) ToProto

func (a *BinaryOperation) ToProto() NodeType

ToProto is a method that returns the protobuf representation of the binary operation.

func (*BinaryOperation) UnmarshalJSON added in v0.3.1

func (a *BinaryOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the BinaryOperation node data from the JSON byte array.

type BitAndOperation added in v0.3.1

type BitAndOperation struct {
	*ASTBuilder

	Id               int64              `json:"id"`
	NodeType         ast_pb.NodeType    `json:"nodeType"`
	Src              SrcNode            `json:"src"`
	Expressions      []Node[NodeType]   `json:"expressions"`
	TypeDescriptions []*TypeDescription `json:"typeDescriptions"`
}

BitAndOperation represents an 'bit and' operation in an abstract syntax tree.

func NewBitAndOperationExpression added in v0.3.1

func NewBitAndOperationExpression(b *ASTBuilder) *BitAndOperation

NewBitAndOperationExpression creates a new BitAndOperation instance.

func (*BitAndOperation) GetExpressions added in v0.3.1

func (f *BitAndOperation) GetExpressions() []Node[NodeType]

GetExpressions returns the expressions within the BitAndOperation.

func (*BitAndOperation) GetId added in v0.3.1

func (f *BitAndOperation) GetId() int64

GetId returns the ID of the BitAndOperation.

func (*BitAndOperation) GetNodes added in v0.3.1

func (f *BitAndOperation) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the BitAndOperation.

func (*BitAndOperation) GetSrc added in v0.3.1

func (f *BitAndOperation) GetSrc() SrcNode

GetSrc returns the source information of the BitAndOperation.

func (*BitAndOperation) GetType added in v0.3.1

func (f *BitAndOperation) GetType() ast_pb.NodeType

GetType returns the NodeType of the BitAndOperation.

func (*BitAndOperation) GetTypeDescription added in v0.3.1

func (f *BitAndOperation) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the BitAndOperation.

func (*BitAndOperation) Parse added in v0.3.1

func (f *BitAndOperation) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.BitAndOperationContext,
) Node[NodeType]

Parse parses the BitAndOperation node from the parsing context and associates it with other nodes.

func (*BitAndOperation) SetReferenceDescriptor added in v0.3.1

func (b *BitAndOperation) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the BitAndOperation node. This function always returns false for now.

func (*BitAndOperation) ToProto added in v0.3.1

func (f *BitAndOperation) ToProto() NodeType

ToProto converts the BitAndOperation to its corresponding protocol buffer representation.

func (*BitAndOperation) UnmarshalJSON added in v0.3.1

func (b *BitAndOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the BitAndOperation object from the serialized JSON.

type BitOrOperation added in v0.3.1

type BitOrOperation struct {
	*ASTBuilder

	Id               int64              `json:"id"`
	NodeType         ast_pb.NodeType    `json:"nodeType"`
	Src              SrcNode            `json:"src"`
	Expressions      []Node[NodeType]   `json:"expressions"`
	TypeDescriptions []*TypeDescription `json:"typeDescriptions"`
}

BitOrOperation represents an 'bit and' operation in an abstract syntax tree.

func NewBitOrOperationExpression added in v0.3.1

func NewBitOrOperationExpression(b *ASTBuilder) *BitOrOperation

NewBitOrOperationExpression creates a new BitOrOperation instance.

func (*BitOrOperation) GetExpressions added in v0.3.1

func (f *BitOrOperation) GetExpressions() []Node[NodeType]

GetExpressions returns the expressions within the BitOrOperation.

func (*BitOrOperation) GetId added in v0.3.1

func (f *BitOrOperation) GetId() int64

GetId returns the ID of the BitOrOperation.

func (*BitOrOperation) GetNodes added in v0.3.1

func (f *BitOrOperation) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the BitOrOperation.

func (*BitOrOperation) GetSrc added in v0.3.1

func (f *BitOrOperation) GetSrc() SrcNode

GetSrc returns the source information of the BitOrOperation.

func (*BitOrOperation) GetType added in v0.3.1

func (f *BitOrOperation) GetType() ast_pb.NodeType

GetType returns the NodeType of the BitOrOperation.

func (*BitOrOperation) GetTypeDescription added in v0.3.1

func (f *BitOrOperation) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the BitOrOperation.

func (*BitOrOperation) Parse added in v0.3.1

func (f *BitOrOperation) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.BitOrOperationContext,
) Node[NodeType]

Parse parses the BitOrOperation node from the parsing context and associates it with other nodes.

func (*BitOrOperation) SetReferenceDescriptor added in v0.3.1

func (b *BitOrOperation) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the BitOrOperation node. This function always returns false for now.

func (*BitOrOperation) ToProto added in v0.3.1

func (f *BitOrOperation) ToProto() NodeType

ToProto converts the BitOrOperation to its corresponding protocol buffer representation.

func (*BitOrOperation) UnmarshalJSON added in v0.3.1

func (b *BitOrOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the BitOrOperation object from the serialized JSON.

type BitXorOperation added in v0.3.1

type BitXorOperation struct {
	*ASTBuilder

	Id               int64              `json:"id"`
	NodeType         ast_pb.NodeType    `json:"nodeType"`
	Src              SrcNode            `json:"src"`
	Expressions      []Node[NodeType]   `json:"expressions"`
	TypeDescriptions []*TypeDescription `json:"typeDescriptions"`
	TypeDescription  *TypeDescription   `json:"typeDescription"`
}

BitXorOperation represents an 'bit and' operation in an abstract syntax tree.

func NewBitXorOperationExpression added in v0.3.1

func NewBitXorOperationExpression(b *ASTBuilder) *BitXorOperation

NewBitXorOperationExpression creates a new BitXorOperation instance.

func (*BitXorOperation) GetExpressions added in v0.3.1

func (f *BitXorOperation) GetExpressions() []Node[NodeType]

GetExpressions returns the expressions within the BitXorOperation.

func (*BitXorOperation) GetId added in v0.3.1

func (f *BitXorOperation) GetId() int64

GetId returns the ID of the BitXorOperation.

func (*BitXorOperation) GetNodes added in v0.3.1

func (f *BitXorOperation) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the BitXorOperation.

func (*BitXorOperation) GetSrc added in v0.3.1

func (f *BitXorOperation) GetSrc() SrcNode

GetSrc returns the source information of the BitXorOperation.

func (*BitXorOperation) GetType added in v0.3.1

func (f *BitXorOperation) GetType() ast_pb.NodeType

GetType returns the NodeType of the BitXorOperation.

func (*BitXorOperation) GetTypeDescription added in v0.3.1

func (f *BitXorOperation) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the BitXorOperation.

func (*BitXorOperation) Parse added in v0.3.1

func (f *BitXorOperation) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.BitXorOperationContext,
) Node[NodeType]

Parse parses the BitXorOperation node from the parsing context and associates it with other nodes.

func (*BitXorOperation) SetReferenceDescriptor added in v0.3.1

func (f *BitXorOperation) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the BitXorOperation node. This function always returns false for now.

func (*BitXorOperation) ToProto added in v0.3.1

func (f *BitXorOperation) ToProto() NodeType

ToProto converts the BitXorOperation to its corresponding protocol buffer representation.

func (*BitXorOperation) UnmarshalJSON added in v0.3.1

func (b *BitXorOperation) UnmarshalJSON(data []byte) error

MarshalJSON marshals the BitXorOperation node into a JSON byte slice.

type BodyNode

type BodyNode struct {
	*ASTBuilder

	Id          int64            `json:"id"`          // Id is the unique identifier of the body node.
	NodeType    ast_pb.NodeType  `json:"nodeType"`    // NodeType is the type of the AST node.
	Kind        ast_pb.NodeType  `json:"kind"`        // Kind is the kind of the AST node.
	Src         SrcNode          `json:"src"`         // Src is the source code location.
	Implemented bool             `json:"implemented"` // Implemented indicates whether the function is implemented.
	Statements  []Node[NodeType] `json:"statements"`  // Statements is the list of AST nodes in the body.
	TypedProto  bool             `json:"-"`           // TypedProto indicates whether the node should use TypedStruct as proto descriptor.
}

BodyNode represents a body node in the abstract syntax tree. It includes various attributes like id, node type, kind, source node, implemented status, and statements.

func NewBodyNode

func NewBodyNode(b *ASTBuilder, tp bool) *BodyNode

NewBodyNode creates a new BodyNode with the provided ASTBuilder. It returns a pointer to the created BodyNode.

func (*BodyNode) GetId

func (b *BodyNode) GetId() int64

GetId returns the unique identifier of the body node.

func (*BodyNode) GetKind

func (b *BodyNode) GetKind() ast_pb.NodeType

GetKind returns the kind of the body node.

func (*BodyNode) GetNodes

func (b *BodyNode) GetNodes() []Node[NodeType]

GetNodes returns the nodes associated with the body node.

func (*BodyNode) GetSrc

func (b *BodyNode) GetSrc() SrcNode

GetSrc returns the source code location of the body node.

func (*BodyNode) GetStatements

func (b *BodyNode) GetStatements() []Node[NodeType]

GetStatements returns the statements associated with the body node.

func (*BodyNode) GetType

func (b *BodyNode) GetType() ast_pb.NodeType

GetType returns the type of the body node.

func (*BodyNode) GetTypeDescription

func (b *BodyNode) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the body node. As BodyNode does not have a type description, it returns nil.

func (*BodyNode) IsImplemented

func (b *BodyNode) IsImplemented() bool

IsImplemented returns the implemented status of the body node.

func (*BodyNode) ParseBlock

func (b *BodyNode) ParseBlock(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	parentNode Node[NodeType],
	bodyCtx parser.IBlockContext,
) Node[NodeType]

ParseBlock is a method of the BodyNode struct. It parses a block context. It takes a source unit, a contract node, a function node, and a block context as arguments. It sets the source node of the BodyNode and checks if the function is implemented by checking if there are any children in the block context. It then iterates over all the statements in the block context and parses each one by calling the parseStatements helper function. It finally returns the BodyNode itself.

func (*BodyNode) ParseDefinitions

func (b *BodyNode) ParseDefinitions(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	bodyCtx parser.IContractBodyElementContext,
) Node[NodeType]

ParseDefinitions is a method of the BodyNode struct. It parses the definitions of a contract body element context. It takes a source unit, a contract node, and a contract body element context as arguments. It iterates over the children of the body context, and based on the type of each child, it creates a new node of the corresponding type and parses it. It then returns the newly created and parsed node. If the type of the child context is unknown, it panics and prints an error message. Panic is here so we are forced to implement missing functionality. After parsing all the children, it sets the source node of the BodyNode and returns the BodyNode itself.

func (*BodyNode) ParseUncheckedBlock

func (b *BodyNode) ParseUncheckedBlock(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyCtx parser.IUncheckedBlockContext,
) Node[NodeType]

ParseUncheckedBlock is a method of the BodyNode struct. It parses an unchecked block context. It takes a source unit, a contract node, a function node, and an unchecked block context as arguments. It sets the node type of the BodyNode to UNCHECKED_BLOCK and sets its source node. It then iterates over all the statements in the block context and parses each one by calling the parseStatements helper function. It finally returns the BodyNode itself.

func (*BodyNode) SetReferenceDescriptor

func (b *BodyNode) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the BodyNode node.

func (*BodyNode) ToProto

func (b *BodyNode) ToProto() NodeType

ToProto converts the BodyNode to a protocol buffer representation.

func (*BodyNode) ToString added in v0.3.2

func (b *BodyNode) ToString() string

func (*BodyNode) UnmarshalJSON added in v0.3.1

func (b *BodyNode) UnmarshalJSON(data []byte) error

UnmarshalJSON is a method of the BodyNode struct that implements the json.Unmarshaler interface.

type BreakStatement

type BreakStatement struct {
	*ASTBuilder // Embedding ASTBuilder for building the AST.

	Id       int64           `json:"id"`       // Unique identifier for the break statement.
	NodeType ast_pb.NodeType `json:"nodeType"` // Type of the node, which is 'BREAK' for a break statement.
	Src      SrcNode         `json:"src"`      // Source information about the node, such as its line and column numbers in the source file.
}

BreakStatement represents a 'break' statement in Solidity.

func NewBreakStatement

func NewBreakStatement(b *ASTBuilder) *BreakStatement

NewBreakStatement creates a new BreakStatement instance.

func (*BreakStatement) GetId

func (b *BreakStatement) GetId() int64

GetId returns the unique identifier of the break statement.

func (*BreakStatement) GetNodes

func (b *BreakStatement) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the break statement. As the break statement doesn't have any child nodes, it returns nil.

func (*BreakStatement) GetSrc

func (b *BreakStatement) GetSrc() SrcNode

GetSrc returns the source information about the node, such as its line and column numbers in the source file.

func (*BreakStatement) GetType

func (b *BreakStatement) GetType() ast_pb.NodeType

GetType returns the type of the node, which is 'BREAK' for a break statement.

func (*BreakStatement) GetTypeDescription

func (b *BreakStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the break statement. As the break statement doesn't have a type description, it returns nil.

func (*BreakStatement) Parse

func (b *BreakStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.BreakStatementContext,
) Node[NodeType]

Parse populates the BreakStatement fields using the provided parser context.

func (*BreakStatement) SetReferenceDescriptor

func (b *BreakStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the BreakStatement node.

func (*BreakStatement) ToProto

func (b *BreakStatement) ToProto() NodeType

ToProto returns the protobuf representation of the break statement.

type CatchStatement

type CatchStatement struct {
	// Embedding the ASTBuilder to provide common functionality
	*ASTBuilder

	// The unique identifier for the 'catch' clause
	Id int64 `json:"id"`

	// The name of the exception variable in the 'catch' clause, if any
	Name string `json:"name,omitempty"`

	// The type of the node, which is 'TRY_CATCH_CLAUSE' for a 'catch' clause
	NodeType ast_pb.NodeType `json:"nodeType"`

	// The kind of the node, which is 'CATCH' for a 'catch' clause
	Kind ast_pb.NodeType `json:"kind"`

	// The source information about the 'catch' clause, such as its line and column numbers in the source file
	Src SrcNode `json:"src"`

	// The body of the 'catch' clause, which is a block of statements
	Body *BodyNode `json:"body"`

	// The parameters of the 'catch' clause, if any
	Parameters *ParameterList `json:"parameters"`
}

The CatchStatement struct represents a 'catch' clause in a 'try-catch' statement in Solidity.

func NewCatchClauseStatement

func NewCatchClauseStatement(b *ASTBuilder) *CatchStatement

NewCatchClauseStatement creates a new CatchStatement instance.

func (*CatchStatement) GetBody

func (t *CatchStatement) GetBody() *BodyNode

GetBody returns the body of the 'catch' clause.

func (*CatchStatement) GetId

func (t *CatchStatement) GetId() int64

GetId returns the unique identifier of the 'catch' clause.

func (*CatchStatement) GetKind

func (t *CatchStatement) GetKind() ast_pb.NodeType

GetKind returns the kind of the node, which is 'CATCH' for a 'catch' clause.

func (*CatchStatement) GetName

func (t *CatchStatement) GetName() string

GetName returns the name of the exception variable in the 'catch' clause, if any.

func (*CatchStatement) GetNodes

func (t *CatchStatement) GetNodes() []Node[NodeType]

GetNodes returns the statements in the body of the 'catch' clause.

func (*CatchStatement) GetParameters

func (t *CatchStatement) GetParameters() *ParameterList

GetParameters returns the parameters of the 'catch' clause.

func (*CatchStatement) GetSrc

func (t *CatchStatement) GetSrc() SrcNode

GetSrc returns the source information about the 'catch' clause.

func (*CatchStatement) GetType

func (t *CatchStatement) GetType() ast_pb.NodeType

GetType returns the type of the node, which is 'TRY_CATCH_CLAUSE' for a 'catch' clause.

func (*CatchStatement) GetTypeDescription

func (t *CatchStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the 'catch' clause, which is nil as 'catch' clauses do not have a type description.

func (*CatchStatement) Parse

func (t *CatchStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	tryNode *TryStatement,
	ctx *parser.CatchClauseContext,
) Node[NodeType]

Parse parses a 'catch' clause from the provided parser.CatchClauseContext and returns the corresponding CatchStatement.

func (*CatchStatement) SetReferenceDescriptor

func (t *CatchStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the CatchStatement node.

func (*CatchStatement) ToProto

func (t *CatchStatement) ToProto() NodeType

ToProto returns the protobuf representation of the 'catch' clause.

func (*CatchStatement) UnmarshalJSON added in v0.3.1

func (t *CatchStatement) UnmarshalJSON(data []byte) error

MarshalJSON marshals the CatchStatement node into a JSON byte slice.

type Comment

type Comment struct {
	Id       int64           `json:"id"`
	Src      SrcNode         `json:"src"`
	NodeType ast_pb.NodeType `json:"nodeType"`
	Text     string          `json:"text"`
}

Comment represents a comment in an abstract syntax tree.

func (*Comment) GetId

func (c *Comment) GetId() int64

GetId returns the ID of the Comment.

func (*Comment) GetSrc

func (c *Comment) GetSrc() SrcNode

GetSrc returns the source information of the Comment.

func (*Comment) GetText

func (c *Comment) GetText() string

GetText returns the text value of the Comment.

func (*Comment) GetType

func (c *Comment) GetType() ast_pb.NodeType

GetType returns the NodeType of the Comment.

func (*Comment) ToProto

func (c *Comment) ToProto() *ast_pb.Comment

ToProto converts the Comment to its corresponding protocol buffer representation.

type Conditional

type Conditional struct {
	*ASTBuilder

	Id               int64              `json:"id"`
	NodeType         ast_pb.NodeType    `json:"nodeType"`
	Src              SrcNode            `json:"src"`
	Expressions      []Node[NodeType]   `json:"expressions"`
	TypeDescriptions []*TypeDescription `json:"typeDescriptions"`
	TypeDescription  *TypeDescription   `json:"typeDescription"`
}

Conditional represents a conditional expression in an abstract syntax tree.

func NewConditionalExpression

func NewConditionalExpression(b *ASTBuilder) *Conditional

NewConditionalExpression creates a new Conditional instance.

func (*Conditional) GetExpressions

func (f *Conditional) GetExpressions() []Node[NodeType]

GetExpressions returns the right expressions within the Conditional.

func (*Conditional) GetId

func (f *Conditional) GetId() int64

GetId returns the ID of the Conditional.

func (*Conditional) GetNodes

func (f *Conditional) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the Conditional.

func (*Conditional) GetSrc

func (f *Conditional) GetSrc() SrcNode

GetSrc returns the source information of the Conditional.

func (*Conditional) GetType

func (f *Conditional) GetType() ast_pb.NodeType

GetType returns the NodeType of the Conditional.

func (*Conditional) GetTypeDescription

func (f *Conditional) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the Conditional. TODO: Perhaps attaching at the end type descriptions to the conditional?

func (*Conditional) Parse

func (f *Conditional) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	ctx *parser.ConditionalContext,
) Node[NodeType]

Parse parses the Conditional node from the parsing context and associates it with other nodes.

func (*Conditional) SetReferenceDescriptor

func (b *Conditional) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Conditional node. This function always returns false for now.

func (*Conditional) ToProto

func (f *Conditional) ToProto() NodeType

ToProto converts the Conditional to its corresponding protocol buffer representation.

func (*Conditional) UnmarshalJSON added in v0.3.1

func (f *Conditional) UnmarshalJSON(data []byte) error

MarshalJSON marshals the Conditional node into a JSON byte slice.

type Constructor

type Constructor struct {
	// Embedding the ASTBuilder to provide common functionality
	*ASTBuilder

	// The unique identifier for the constructor
	Id int64 `json:"id"`

	// The type of the node, which is 'FUNCTION_DEFINITION' for a constructor
	NodeType ast_pb.NodeType `json:"nodeType"`

	// The source information about the constructor, such as its line and column numbers in the source file
	Src SrcNode `json:"src"`

	// The kind of the node, which is 'CONSTRUCTOR' for a constructor
	Kind ast_pb.NodeType `json:"kind"`

	// The state mutability of the constructor, which is 'NONPAYABLE' by default
	StateMutability ast_pb.Mutability `json:"stateMutability"`

	// The visibility of the constructor
	Visibility ast_pb.Visibility `json:"visibility"`

	// Whether the constructor is implemented or not
	Implemented bool `json:"implemented"`

	// The modifiers of the constructor
	Modifiers []*ModifierInvocation `json:"modifiers"`

	// The parameters of the constructor
	Parameters *ParameterList `json:"parameters"`

	// The return parameters of the constructor, which are always empty for a constructor
	ReturnParameters *ParameterList `json:"returnParameters"`

	// The scope of the constructor, which is the id of the contract that the constructor belongs to
	Scope int64 `json:"scope"`

	// The body of the constructor, which is a block of statements
	Body *BodyNode `json:"body"`
}

The Constructor struct represents a constructor function in a Solidity contract.

func NewConstructor

func NewConstructor(b *ASTBuilder) *Constructor

NewConstructor creates a new Constructor instance.

func (*Constructor) GetBody

func (c *Constructor) GetBody() *BodyNode

GetBody returns the body of the constructor.

func (*Constructor) GetId

func (c *Constructor) GetId() int64

GetId returns the unique identifier of the constructor.

func (*Constructor) GetKind

func (c *Constructor) GetKind() ast_pb.NodeType

GetKind returns the kind of the node, which is 'CONSTRUCTOR' for a constructor.

func (*Constructor) GetModifiers

func (c *Constructor) GetModifiers() []*ModifierInvocation

func (*Constructor) GetNodes

func (c *Constructor) GetNodes() []Node[NodeType]

GetNodes returns the statements in the body of the constructor.

func (*Constructor) GetParameters

func (c *Constructor) GetParameters() *ParameterList

GetParameters returns the parameters of the constructor.

func (*Constructor) GetReturnParameters

func (c *Constructor) GetReturnParameters() *ParameterList

GetReturnParameters returns the return parameters of the constructor, which are always empty for a constructor.

func (*Constructor) GetScope

func (c *Constructor) GetScope() int64

GetScope returns the scope of the constructor, which is the id of the contract that the constructor belongs to.

func (*Constructor) GetSrc

func (c *Constructor) GetSrc() SrcNode

GetSrc returns the source information about the constructor.

func (*Constructor) GetStateMutability

func (c *Constructor) GetStateMutability() ast_pb.Mutability

GetStateMutability returns the state mutability of the constructor.

func (*Constructor) GetType

func (c *Constructor) GetType() ast_pb.NodeType

GetType returns the type of the node, which is 'FUNCTION_DEFINITION' for a constructor.

func (*Constructor) GetTypeDescription

func (c *Constructor) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the constructor, which is nil as constructors do not have a type description.

func (*Constructor) GetVisibility

func (c *Constructor) GetVisibility() ast_pb.Visibility

GetVisibility returns the visibility of the constructor.

func (*Constructor) IsImplemented

func (c *Constructor) IsImplemented() bool

IsImplemented returns whether the constructor is implemented or not.

func (*Constructor) Parse

Parse parses a constructor from the provided parser.ConstructorDefinitionContext and returns the corresponding Constructor.

func (*Constructor) SetReferenceDescriptor

func (c *Constructor) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Constructor node.

func (*Constructor) ToProto

func (c *Constructor) ToProto() NodeType

ToProto returns the protobuf representation of the constructor.

func (*Constructor) UnmarshalJSON added in v0.3.1

func (c *Constructor) UnmarshalJSON(data []byte) error

type ContinueStatement

type ContinueStatement struct {
	*ASTBuilder

	Id       int64           `json:"id"`
	NodeType ast_pb.NodeType `json:"nodeType"`
	Src      SrcNode         `json:"src"`
}

ContinueStatement represents a 'continue' statement in the abstract syntax tree.

func NewContinueStatement

func NewContinueStatement(b *ASTBuilder) *ContinueStatement

NewContinueStatement creates a new instance of ContinueStatement.

func (*ContinueStatement) GetId

func (b *ContinueStatement) GetId() int64

GetId returns the ID of the ContinueStatement.

func (*ContinueStatement) GetNodes

func (b *ContinueStatement) GetNodes() []Node[NodeType]

GetNodes returns an empty list of child nodes for the ContinueStatement.

func (*ContinueStatement) GetSrc

func (b *ContinueStatement) GetSrc() SrcNode

GetSrc returns the source information of the ContinueStatement.

func (*ContinueStatement) GetType

func (b *ContinueStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the ContinueStatement.

func (*ContinueStatement) GetTypeDescription

func (b *ContinueStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the ContinueStatement.

func (*ContinueStatement) Parse

func (b *ContinueStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.ContinueStatementContext,
) Node[NodeType]

Parse parses the ContinueStatement node from the parsing context and associates it with other nodes.

func (*ContinueStatement) SetReferenceDescriptor

func (b *ContinueStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the ContinueStatement node. This function always returns false for now.

func (*ContinueStatement) ToProto

func (b *ContinueStatement) ToProto() NodeType

ToProto converts the ContinueStatement to its corresponding protocol buffer representation.

type Contract

type Contract struct {
	*ASTBuilder

	Id                      int64            `json:"id"`
	Name                    string           `json:"name"`
	NodeType                ast_pb.NodeType  `json:"nodeType"`
	Src                     SrcNode          `json:"src"`
	NameLocation            SrcNode          `json:"nameLocation"`
	Abstract                bool             `json:"abstract"`
	Kind                    ast_pb.NodeType  `json:"kind"`
	FullyImplemented        bool             `json:"fullyImplemented"`
	Nodes                   []Node[NodeType] `json:"nodes"`
	LinearizedBaseContracts []int64          `json:"linearizedBaseContracts"`
	BaseContracts           []*BaseContract  `json:"baseContracts"`
	ContractDependencies    []int64          `json:"contractDependencies"`
}

Contract represents a Solidity contract in the abstract syntax tree.

func NewContractDefinition

func NewContractDefinition(b *ASTBuilder) *Contract

NewContractDefinition creates a new instance of Contract.

func (*Contract) GetBaseContracts

func (c *Contract) GetBaseContracts() []*BaseContract

GetBaseContracts returns the base contracts of the Contract.

func (*Contract) GetConstructor

func (s *Contract) GetConstructor() *Constructor

GetConstructor returns the constructor definition of the Contract.

func (*Contract) GetContractDependencies

func (c *Contract) GetContractDependencies() []int64

GetContractDependencies returns the contract dependencies of the Contract.

func (*Contract) GetEnums

func (s *Contract) GetEnums() []*EnumDefinition

GetEnums returns the enum definitions defined in the Contract.

func (*Contract) GetErrors

func (s *Contract) GetErrors() []*ErrorDefinition

GetErrors returns the error definitions defined in the Contract.

func (*Contract) GetEvents

func (s *Contract) GetEvents() []*EventDefinition

GetEvents returns the event definitions defined in the Contract.

func (*Contract) GetFallback

func (s *Contract) GetFallback() *Fallback

GetFallback returns the fallback definition of the Contract.

func (*Contract) GetFunctions

func (s *Contract) GetFunctions() []*Function

GetFunctions returns the function definitions defined in the Contract.

func (*Contract) GetId

func (c *Contract) GetId() int64

GetId returns the ID of the Contract.

func (*Contract) GetKind

func (c *Contract) GetKind() ast_pb.NodeType

GetKind returns the kind of the Contract.

func (*Contract) GetLinearizedBaseContracts

func (c *Contract) GetLinearizedBaseContracts() []int64

GetLinearizedBaseContracts returns the linearized base contracts of the Contract.

func (*Contract) GetName

func (c *Contract) GetName() string

GetName returns the name of the Contract.

func (*Contract) GetNameLocation

func (c *Contract) GetNameLocation() SrcNode

GetNameLocation returns the source information of the name of the Contract.

func (*Contract) GetNodes

func (c *Contract) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the Contract.

func (*Contract) GetReceive

func (s *Contract) GetReceive() *Receive

GetReceive returns the receive definition of the Contract.

func (*Contract) GetSrc

func (c *Contract) GetSrc() SrcNode

GetSrc returns the source information of the Contract.

func (*Contract) GetStateVariables

func (s *Contract) GetStateVariables() []*StateVariableDeclaration

GetStateVariables returns the state variables defined in the Contract.

func (*Contract) GetStructs

func (s *Contract) GetStructs() []*StructDefinition

GetStructs returns the struct definitions defined in the Contract.

func (*Contract) GetType

func (c *Contract) GetType() ast_pb.NodeType

GetType returns the NodeType of the Contract.

func (*Contract) GetTypeDescription

func (c *Contract) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the Contract.

func (*Contract) IsAbstract

func (c *Contract) IsAbstract() bool

IsAbstract returns whether the Contract is abstract.

func (*Contract) IsFullyImplemented

func (c *Contract) IsFullyImplemented() bool

IsFullyImplemented returns whether the Contract is fully implemented.

func (*Contract) Parse

Parse parses the Contract node from the parsing context and associates it with other nodes.

func (*Contract) SetReferenceDescriptor

func (c *Contract) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Contract node. This function always returns false for now.

func (*Contract) ToProto

func (c *Contract) ToProto() NodeType

ToProto converts the Contract to its corresponding protocol buffer representation.

func (*Contract) UnmarshalJSON added in v0.3.1

func (s *Contract) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the JSON-encoded data and stores the result in the Contract.

type Declaration

type Declaration struct {
	*ASTBuilder

	Id              int64                  `json:"id"`
	StateMutability ast_pb.Mutability      `json:"stateMutability"`
	Name            string                 `json:"name"`
	NodeType        ast_pb.NodeType        `json:"nodeType"`
	Scope           int64                  `json:"scope"`
	Src             SrcNode                `json:"src"`
	NameLocation    SrcNode                `json:"nameLocation"`
	IsStateVariable bool                   `json:"isStateVariable"`
	StorageLocation ast_pb.StorageLocation `json:"storageLocation"`
	TypeName        *TypeName              `json:"typeName"`
	Visibility      ast_pb.Visibility      `json:"visibility"`
}

Declaration is a struct that contains information about a variable declaration in the AST.

func NewDeclaration

func NewDeclaration(b *ASTBuilder) *Declaration

NewDeclaration creates a new Declaration instance.

func (*Declaration) GetId

func (d *Declaration) GetId() int64

GetId returns the ID of the Declaration.

func (*Declaration) GetIsStateVariable

func (d *Declaration) GetIsStateVariable() bool

GetIsStateVariable returns whether or not the Declaration is a state variable.

func (*Declaration) GetName

func (d *Declaration) GetName() string

GetName returns the name of the Declaration.

func (*Declaration) GetNameLocation

func (d *Declaration) GetNameLocation() SrcNode

GetNameLocation returns the name location of the Declaration.

func (*Declaration) GetNodes

func (d *Declaration) GetNodes() []Node[NodeType]

GetNodes returns the nodes associated with the Declaration.

func (*Declaration) GetScope

func (d *Declaration) GetScope() int64

GetScope returns the scope of the Declaration.

func (*Declaration) GetSrc

func (d *Declaration) GetSrc() SrcNode

GetSrc returns the SrcNode of the Declaration.

func (*Declaration) GetStateMutability

func (d *Declaration) GetStateMutability() ast_pb.Mutability

GetStateMutability returns the state mutability of the Declaration.

func (*Declaration) GetStorageLocation

func (d *Declaration) GetStorageLocation() ast_pb.StorageLocation

GetStorageLocation returns the storage location of the Declaration.

func (*Declaration) GetType

func (d *Declaration) GetType() ast_pb.NodeType

GetType returns the NodeType of the Declaration.

func (*Declaration) GetTypeDescription

func (d *Declaration) GetTypeDescription() *TypeDescription

GetTypeDescription returns the TypeDescription of the Declaration.

func (*Declaration) GetTypeName

func (d *Declaration) GetTypeName() *TypeName

GetTypeName returns the TypeName of the Declaration.

func (*Declaration) GetVisibility

func (d *Declaration) GetVisibility() ast_pb.Visibility

GetVisibility returns the visibility of the Declaration.

func (*Declaration) ParseVariableDeclaration

func (d *Declaration) ParseVariableDeclaration(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	ctx parser.IVariableDeclarationContext,
)

ParseVariableDeclaration parses a VariableDeclaration and stores the relevant information in the Declaration.

func (*Declaration) SetReferenceDescriptor

func (v *Declaration) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the VariableDeclaration node.

func (*Declaration) ToProto

func (d *Declaration) ToProto() NodeType

ToProto converts the Declaration to its corresponding protocol buffer representation.

type DoWhileStatement

type DoWhileStatement struct {
	*ASTBuilder                 // Embedded ASTBuilder for building the AST.
	Id          int64           `json:"id"`        // Unique identifier for the DoWhileStatement node.
	NodeType    ast_pb.NodeType `json:"nodeType"`  // Type of the AST node.
	Src         SrcNode         `json:"src"`       // Source location information.
	Condition   Node[NodeType]  `json:"condition"` // Condition expression for the do-while loop.
	Body        *BodyNode       `json:"body"`      // Body of the do-while loop.
}

DoWhileStatement represents a do-while loop statement node in the abstract syntax tree (AST). It encapsulates information about the condition and body of the loop.

func NewDoWhileStatement

func NewDoWhileStatement(b *ASTBuilder) *DoWhileStatement

NewDoWhileStatement creates a new DoWhileStatement node with default values and returns it.

func (*DoWhileStatement) GetBody

func (d *DoWhileStatement) GetBody() *BodyNode

GetBody returns the body of the do-while loop.

func (*DoWhileStatement) GetCondition

func (d *DoWhileStatement) GetCondition() Node[NodeType]

GetCondition returns the condition expression of the do-while loop.

func (*DoWhileStatement) GetId

func (d *DoWhileStatement) GetId() int64

GetId returns the unique identifier of the DoWhileStatement node.

func (*DoWhileStatement) GetNodes

func (d *DoWhileStatement) GetNodes() []Node[NodeType]

GetNodes returns a slice of child nodes within the do-while loop.

func (*DoWhileStatement) GetSrc

func (d *DoWhileStatement) GetSrc() SrcNode

GetSrc returns the source location information of the DoWhileStatement node.

func (*DoWhileStatement) GetType

func (d *DoWhileStatement) GetType() ast_pb.NodeType

GetType returns the type of the AST node, which is NodeType_DO_WHILE_STATEMENT for a do-while loop.

func (*DoWhileStatement) GetTypeDescription

func (d *DoWhileStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the DoWhileStatement node.

func (*DoWhileStatement) Parse

func (d *DoWhileStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.DoWhileStatementContext,
) Node[NodeType]

Parse is responsible for parsing the do-while loop statement from the context and populating the DoWhileStatement node.

func (*DoWhileStatement) SetReferenceDescriptor

func (d *DoWhileStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the DoWhileStatement node. This function currently returns false, as no reference description updates are performed.

func (*DoWhileStatement) ToProto

func (d *DoWhileStatement) ToProto() NodeType

ToProto converts the DoWhileStatement node to its corresponding protocol buffer representation.

func (*DoWhileStatement) UnmarshalJSON added in v0.3.1

func (d *DoWhileStatement) UnmarshalJSON(data []byte) error

MarshalJSON marshals the DoWhileStatement node into a JSON-encoded byte slice.

type Emit

type Emit struct {
	*ASTBuilder

	Id         int64            `json:"id"`         // Unique identifier of the emit statement node.
	NodeType   ast_pb.NodeType  `json:"nodeType"`   // Type of the node.
	Src        SrcNode          `json:"src"`        // Source location information.
	Arguments  []Node[NodeType] `json:"arguments"`  // List of arguments for the emit statement.
	Expression Node[NodeType]   `json:"expression"` // Expression node associated with the emit statement.
}

Emit represents an emit statement node in the abstract syntax tree.

func NewEmitStatement

func NewEmitStatement(b *ASTBuilder) *Emit

NewEmitStatement creates a new instance of Emit with the provided ASTBuilder.

func (*Emit) GetArguments

func (e *Emit) GetArguments() []Node[NodeType]

GetArguments returns the list of arguments associated with the emit statement.

func (*Emit) GetExpression

func (e *Emit) GetExpression() Node[NodeType]

GetExpression returns the expression node associated with the emit statement.

func (*Emit) GetId

func (e *Emit) GetId() int64

GetId returns the unique identifier of the emit statement node.

func (*Emit) GetNodes

func (e *Emit) GetNodes() []Node[NodeType]

GetNodes returns a list of nodes associated with the emit statement (arguments and expression).

func (*Emit) GetSrc

func (e *Emit) GetSrc() SrcNode

GetSrc returns the source location information of the emit statement node.

func (*Emit) GetType

func (e *Emit) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*Emit) GetTypeDescription

func (e *Emit) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the emit statement.

func (*Emit) Parse

func (e *Emit) Parse(unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.EmitStatementContext,
) Node[NodeType]

Parse parses the emit statement context and populates the Emit fields.

func (*Emit) SetReferenceDescriptor

func (e *Emit) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptors of the Emit node.

func (*Emit) ToProto

func (e *Emit) ToProto() NodeType

ToProto converts the Emit node to its corresponding protobuf representation.

func (*Emit) UnmarshalJSON added in v0.3.1

func (e *Emit) UnmarshalJSON(data []byte) error

type EnumDefinition

type EnumDefinition struct {
	*ASTBuilder                      // Embedding the ASTBuilder for common functionality
	SourceUnitName  string           `json:"-"`
	Id              int64            `json:"id"`              // Unique identifier for the enumeration definition
	NodeType        ast_pb.NodeType  `json:"nodeType"`        // Type of the node (ENUM_DEFINITION for enumeration definition)
	Src             SrcNode          `json:"src"`             // Source information about the enumeration definition
	NameLocation    SrcNode          `json:"nameLocation"`    // Source information about the name of the enumeration
	Name            string           `json:"name"`            // Name of the enumeration
	CanonicalName   string           `json:"canonicalName"`   // Canonical name of the enumeration
	TypeDescription *TypeDescription `json:"typeDescription"` // Type description of the enumeration
	Members         []Node[NodeType] `json:"members"`         // Members of the enumeration
}

EnumDefinition represents an enumeration definition in the Solidity abstract syntax tree (AST).

func NewEnumDefinition

func NewEnumDefinition(b *ASTBuilder) *EnumDefinition

NewEnumDefinition creates a new EnumDefinition instance.

func (*EnumDefinition) GetCanonicalName

func (e *EnumDefinition) GetCanonicalName() string

GetCanonicalName returns the canonical name of the enumeration.

func (*EnumDefinition) GetId

func (e *EnumDefinition) GetId() int64

GetId returns the unique identifier of the enumeration definition.

func (*EnumDefinition) GetMembers

func (e *EnumDefinition) GetMembers() []*Parameter

GetMembers returns the members of the enumeration.

func (*EnumDefinition) GetName

func (e *EnumDefinition) GetName() string

GetName returns the name of the enumeration.

func (*EnumDefinition) GetNameLocation

func (e *EnumDefinition) GetNameLocation() SrcNode

GetNameLocation returns the source information about the name of the enumeration.

func (*EnumDefinition) GetNodes

func (e *EnumDefinition) GetNodes() []Node[NodeType]

GetNodes returns the members of the enumeration.

func (*EnumDefinition) GetSourceUnitName

func (e *EnumDefinition) GetSourceUnitName() string

GetSourceUnitName returns the name of the source unit containing the enumeration.

func (*EnumDefinition) GetSrc

func (e *EnumDefinition) GetSrc() SrcNode

GetSrc returns the source information about the enumeration definition.

func (*EnumDefinition) GetType

func (e *EnumDefinition) GetType() ast_pb.NodeType

GetType returns the type of the node, which is 'ENUM_DEFINITION' for an enumeration definition.

func (*EnumDefinition) GetTypeDescription

func (e *EnumDefinition) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the enumeration.

func (*EnumDefinition) Parse

Parse parses an enumeration definition from the provided parser.EnumDefinitionContext and updates the current instance.

func (*EnumDefinition) ParseGlobal added in v0.3.1

func (e *EnumDefinition) ParseGlobal(
	ctx *parser.EnumDefinitionContext,
) Node[NodeType]

ParseGlobal parses an global enumeration definition from the provided parser.EnumDefinitionContext and updates the current instance.

func (*EnumDefinition) SetReferenceDescriptor

func (e *EnumDefinition) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the EnumDefinition node. We don't need to do any reference description updates here, at least for now...

func (*EnumDefinition) ToProto

func (e *EnumDefinition) ToProto() NodeType

ToProto returns the protobuf representation of the enumeration definition.

func (*EnumDefinition) UnmarshalJSON added in v0.3.1

func (e *EnumDefinition) UnmarshalJSON(data []byte) error

type ErrorDefinition

type ErrorDefinition struct {
	*ASTBuilder
	SourceUnitName  string           `json:"-"`               // Source unit name.
	Id              int64            `json:"id"`              // Unique identifier of the error definition node.
	NodeType        ast_pb.NodeType  `json:"nodeType"`        // Type of the node.
	Src             SrcNode          `json:"src"`             // Source location information.
	Name            string           `json:"name"`            // Name of the error definition.
	NameLocation    SrcNode          `json:"nameLocation"`    // Source location information of the name.
	Parameters      *ParameterList   `json:"parameters"`      // List of error parameters.
	TypeDescription *TypeDescription `json:"typeDescription"` // Type description of the error definition.
}

ErrorDefinition represents an error definition node in the abstract syntax tree.

func NewErrorDefinition

func NewErrorDefinition(b *ASTBuilder) *ErrorDefinition

NewErrorDefinition creates a new instance of ErrorDefinition with the provided ASTBuilder.

func (*ErrorDefinition) GetId

func (e *ErrorDefinition) GetId() int64

GetId returns the unique identifier of the error definition node.

func (*ErrorDefinition) GetName

func (e *ErrorDefinition) GetName() string

GetName returns the name of the error definition.

func (*ErrorDefinition) GetNameLocation

func (e *ErrorDefinition) GetNameLocation() SrcNode

GetNameLocation returns the source location information of the name of the error definition.

func (*ErrorDefinition) GetNodes

func (e *ErrorDefinition) GetNodes() []Node[NodeType]

GetNodes returns an empty slice of nodes associated with the error definition.

func (*ErrorDefinition) GetParameters

func (e *ErrorDefinition) GetParameters() *ParameterList

GetParameters returns the list of error parameters.

func (*ErrorDefinition) GetSourceUnitName

func (e *ErrorDefinition) GetSourceUnitName() string

GetSourceUnitName returns the source unit name associated with the error definition.

func (*ErrorDefinition) GetSrc

func (e *ErrorDefinition) GetSrc() SrcNode

GetSrc returns the source location information of the error definition node.

func (*ErrorDefinition) GetType

func (e *ErrorDefinition) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*ErrorDefinition) GetTypeDescription

func (e *ErrorDefinition) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the error definition.

func (*ErrorDefinition) Parse

Parse parses the error definition context and populates the ErrorDefinition fields.

func (*ErrorDefinition) ParseGlobal added in v0.3.1

ParseGlobal parses the error definition context and populates the ErrorDefinition fields.

func (*ErrorDefinition) SetReferenceDescriptor

func (e *ErrorDefinition) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptors of the ErrorDefinition node.

func (*ErrorDefinition) ToProto

func (e *ErrorDefinition) ToProto() NodeType

ToProto converts the ErrorDefinition node to its corresponding protobuf representation.

type EventDefinition

type EventDefinition struct {
	*ASTBuilder                      // Embedding the ASTBuilder for common functionality
	SourceUnitName  string           `json:"-"`
	Id              int64            `json:"id"`              // Unique identifier for the event definition
	NodeType        ast_pb.NodeType  `json:"nodeType"`        // Type of the node (EVENT_DEFINITION for event definition)
	Src             SrcNode          `json:"src"`             // Source information about the event definition
	Parameters      *ParameterList   `json:"parameters"`      // Parameters of the event
	Name            string           `json:"name"`            // Name of the event
	Anonymous       bool             `json:"anonymous"`       // Indicates if the event is anonymous
	TypeDescription *TypeDescription `json:"typeDescription"` // Type description of the event
}

EventDefinition represents an event definition in the Solidity abstract syntax tree (AST).

func NewEventDefinition

func NewEventDefinition(b *ASTBuilder) *EventDefinition

NewEventDefinition creates a new EventDefinition instance.

func (*EventDefinition) GetId

func (e *EventDefinition) GetId() int64

GetId returns the unique identifier of the event definition.

func (*EventDefinition) GetName

func (e *EventDefinition) GetName() string

GetName returns the name of the event.

func (*EventDefinition) GetNodes

func (e *EventDefinition) GetNodes() []Node[NodeType]

GetNodes returns the nodes representing the parameters of the event.

func (*EventDefinition) GetParameters

func (e *EventDefinition) GetParameters() *ParameterList

GetParameters returns the parameters of the event.

func (*EventDefinition) GetSrc

func (e *EventDefinition) GetSrc() SrcNode

GetSrc returns the source information about the event definition.

func (*EventDefinition) GetType

func (e *EventDefinition) GetType() ast_pb.NodeType

GetType returns the type of the node, which is 'EVENT_DEFINITION' for an event definition.

func (*EventDefinition) GetTypeDescription

func (e *EventDefinition) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the event.

func (*EventDefinition) IsAnonymous

func (e *EventDefinition) IsAnonymous() bool

IsAnonymous returns whether the event is anonymous.

func (*EventDefinition) Parse

Parse parses an event definition from the provided parser.EventDefinitionContext and updates the current instance.

func (*EventDefinition) ParseGlobal added in v0.3.1

func (e *EventDefinition) ParseGlobal(
	ctx *parser.EventDefinitionContext,
) Node[NodeType]

ParseGlobal parses an event definition from the provided parser.EventDefinitionContext and updates the current instance.

func (*EventDefinition) SetReferenceDescriptor

func (e *EventDefinition) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the EventDefinition node. We don't need to do any reference description updates here, at least for now...

func (*EventDefinition) ToProto

func (e *EventDefinition) ToProto() NodeType

ToProto returns the protobuf representation of the event definition.

type ExprOperation

type ExprOperation struct {
	*ASTBuilder

	Id               int64              `json:"id"`               // Unique identifier for the expression operation
	NodeType         ast_pb.NodeType    `json:"nodeType"`         // Type of the node (EXPRESSION_OPERATION for expression operation)
	Src              SrcNode            `json:"src"`              // Source information about the expression operation
	LeftExpression   Node[NodeType]     `json:"leftExpression"`   // Left expression in the operation
	RightExpression  Node[NodeType]     `json:"rightExpression"`  // Right expression in the operation
	TypeDescriptions []*TypeDescription `json:"typeDescriptions"` // Type descriptions of the expressions
}

ExprOperation represents an expression operation in the Solidity abstract syntax tree (AST).

func NewExprOperationExpression

func NewExprOperationExpression(b *ASTBuilder) *ExprOperation

NewExprOperationExpression creates a new ExprOperation instance.

func (*ExprOperation) GetId

func (f *ExprOperation) GetId() int64

GetId returns the unique identifier of the expression operation.

func (*ExprOperation) GetLeftExpression

func (f *ExprOperation) GetLeftExpression() Node[NodeType]

GetLeftExpression returns the left expression in the operation.

func (*ExprOperation) GetNodes

func (f *ExprOperation) GetNodes() []Node[NodeType]

GetNodes returns the nodes representing the left and right expressions of the operation.

func (*ExprOperation) GetRightExpression

func (f *ExprOperation) GetRightExpression() Node[NodeType]

GetRightExpression returns the right expression in the operation.

func (*ExprOperation) GetSrc

func (f *ExprOperation) GetSrc() SrcNode

GetSrc returns the source information about the expression operation.

func (*ExprOperation) GetType

func (f *ExprOperation) GetType() ast_pb.NodeType

GetType returns the type of the node, which is 'EXPRESSION_OPERATION' for an expression operation.

func (*ExprOperation) GetTypeDescription

func (f *ExprOperation) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the expression operation.

func (*ExprOperation) Parse

func (f *ExprOperation) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	ctx *parser.ExpOperationContext,
) Node[NodeType]

Parse parses an expression operation from the provided parser.ExpOperationContext and updates the current instance.

func (*ExprOperation) SetReferenceDescriptor

func (b *ExprOperation) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the ExprOperation node.

func (*ExprOperation) ToProto

func (f *ExprOperation) ToProto() NodeType

ToProto returns the protobuf representation of the expression operation.

func (*ExprOperation) UnmarshalJSON added in v0.3.1

func (f *ExprOperation) UnmarshalJSON(data []byte) error

type Expression

type Expression struct {
	*ASTBuilder
}

Expression represents an AST node for an expression in Solidity.

func NewExpression

func NewExpression(b *ASTBuilder) *Expression

NewExpression creates a new Expression instance with the provided ASTBuilder. The ASTBuilder is used to facilitate the construction of the AST.

func (*Expression) Parse

func (e *Expression) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDecar *VariableDeclaration,
	parentNode Node[NodeType],
	parentNodeId int64,
	ctx parser.IExpressionContext,
) Node[NodeType]

Parse analyzes the provided parser.IExpressionContext and constructs the corresponding AST node. It supports various types of expressions in Solidity such as binary operations, assignments, function calls, member accesses, etc. If the expression type is not supported, a warning is logged.

Parameters: - unit: The source unit node. - contractNode: The contract node within the source. - fnNode: The function node within the contract. - bodyNode: The body node of the function. - vDecar: The variable declaration node. - parentNode: The parent expression node. - ctx: The context representing the expression to be parsed.

Returns:

  • Node[NodeType]: The constructed AST node for the parsed expression. If the expression type is not supported, it returns nil.

func (*Expression) ParseInterface added in v0.3.1

func (e *Expression) ParseInterface(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	fnNode Node[NodeType],
	parentNodeId int64,
	ctx any,
) Node[NodeType]

type ExpressionContext added in v0.3.4

type ExpressionContext struct {
	*ASTBuilder

	Id              int64            `json:"id"`
	NodeType        ast_pb.NodeType  `json:"nodeType"`
	Src             SrcNode          `json:"src"`
	Value           string           `json:"value"`
	TypeDescription *TypeDescription `json:"typeDescription"`
}

ExpressionContext represents an AST node for an expression context in Solidity.

func NewExpressionContext added in v0.3.4

func NewExpressionContext(b *ASTBuilder) *ExpressionContext

NewExpressionContext creates a new ExpressionContext instance with the provided ASTBuilder. The ASTBuilder is used to facilitate the construction of the AST.

func (*ExpressionContext) GetId added in v0.3.4

func (f *ExpressionContext) GetId() int64

GetId returns the ID of the ExpressionContext.

func (*ExpressionContext) GetNodes added in v0.3.4

func (f *ExpressionContext) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the ExpressionContext.

func (*ExpressionContext) GetSrc added in v0.3.4

func (f *ExpressionContext) GetSrc() SrcNode

GetSrc returns the source information of the ExpressionContext.

func (*ExpressionContext) GetType added in v0.3.4

func (f *ExpressionContext) GetType() ast_pb.NodeType

GetType returns the NodeType of the ExpressionContext.

func (*ExpressionContext) GetTypeDescription added in v0.3.4

func (f *ExpressionContext) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the ExpressionContext.

func (*ExpressionContext) Parse added in v0.3.4

func (f *ExpressionContext) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.ExpressionContext,
) Node[NodeType]

Parse parses the ExpressionContext node from the parsing context and associates it with other nodes.

func (*ExpressionContext) SetReferenceDescriptor added in v0.3.4

func (f *ExpressionContext) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the ExpressionContext node. This function always returns false for now.

func (*ExpressionContext) ToProto added in v0.3.4

func (f *ExpressionContext) ToProto() NodeType

ToProto converts the ExpressionContext to its corresponding protocol buffer representation.

type Fallback

type Fallback struct {
	*ASTBuilder                            // Embedded ASTBuilder for building the AST.
	Id               int64                 `json:"id"`               // Unique identifier for the Fallback node.
	NodeType         ast_pb.NodeType       `json:"nodeType"`         // Type of the AST node.
	Kind             ast_pb.NodeType       `json:"kind"`             // Kind of the fallback function.
	Src              SrcNode               `json:"src"`              // Source location information.
	Implemented      bool                  `json:"implemented"`      // Indicates whether the function is implemented.
	Visibility       ast_pb.Visibility     `json:"visibility"`       // Visibility of the fallback function.
	StateMutability  ast_pb.Mutability     `json:"stateMutability"`  // State mutability of the fallback function.
	Modifiers        []*ModifierInvocation `json:"modifiers"`        // List of modifier invocations applied to the fallback function.
	Overrides        []*OverrideSpecifier  `json:"overrides"`        // List of override specifiers for the fallback function.
	Parameters       *ParameterList        `json:"parameters"`       // List of parameters for the fallback function.
	ReturnParameters *ParameterList        `json:"returnParameters"` // List of return parameters for the fallback function.
	Body             *BodyNode             `json:"body"`             // Body of the fallback function.
	Virtual          bool                  `json:"virtual"`          // Indicates whether the function is virtual.
}

Fallback represents a fallback function definition node in the abstract syntax tree (AST). It encapsulates information about the characteristics and properties of a fallback function within a contract.

func NewFallbackDefinition

func NewFallbackDefinition(b *ASTBuilder) *Fallback

NewFallbackDefinition creates a new Fallback node with default values and returns it.

func (*Fallback) GetBody

func (f *Fallback) GetBody() *BodyNode

GetBody returns the body of the Fallback node.

func (*Fallback) GetId

func (f *Fallback) GetId() int64

GetId returns the unique identifier of the Fallback node.

func (*Fallback) GetKind

func (f *Fallback) GetKind() ast_pb.NodeType

GetKind returns the kind of the Fallback node, which is NodeType_FALLBACK.

func (*Fallback) GetModifiers

func (f *Fallback) GetModifiers() []*ModifierInvocation

GetModifiers returns a list of modifier invocations applied to the Fallback node.

func (*Fallback) GetNodes

func (f *Fallback) GetNodes() []Node[NodeType]

GetNodes returns a slice of child nodes within the body of the fallback function.

func (*Fallback) GetOverrides

func (f *Fallback) GetOverrides() []*OverrideSpecifier

GetOverrides returns a list of override specifiers for the Fallback node.

func (*Fallback) GetParameters

func (f *Fallback) GetParameters() *ParameterList

GetParameters returns the list of parameters for the Fallback node.

func (*Fallback) GetReturnParameters

func (f *Fallback) GetReturnParameters() *ParameterList

GetReturnParameters returns the list of return parameters for the Fallback node.

func (*Fallback) GetSrc

func (f *Fallback) GetSrc() SrcNode

GetSrc returns the source location information of the Fallback node.

func (*Fallback) GetStateMutability

func (f *Fallback) GetStateMutability() ast_pb.Mutability

GetStateMutability returns the state mutability of the Fallback function.

func (*Fallback) GetType

func (f *Fallback) GetType() ast_pb.NodeType

GetType returns the type of the AST node, which is NodeType_FUNCTION_DEFINITION for a fallback function.

func (*Fallback) GetTypeDescription

func (f *Fallback) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the Fallback node.

func (*Fallback) GetVisibility

func (f *Fallback) GetVisibility() ast_pb.Visibility

GetVisibility returns the visibility of the Fallback function.

func (*Fallback) IsImplemented

func (f *Fallback) IsImplemented() bool

IsImplemented returns true if the Fallback function is implemented, false otherwise.

func (*Fallback) IsVirtual

func (f *Fallback) IsVirtual() bool

IsVirtual returns true if the Fallback function is virtual, false otherwise.

func (*Fallback) Parse

Parse populates the properties of the Fallback node by parsing the corresponding context and information. It returns the populated Fallback node.

func (*Fallback) SetReferenceDescriptor

func (f *Fallback) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Fallback node. This function currently returns false, as no reference description updates are performed.

func (*Fallback) ToProto

func (f *Fallback) ToProto() NodeType

ToProto converts the Fallback node to its corresponding protocol buffer representation.

type ForStatement

type ForStatement struct {
	*ASTBuilder

	Id          int64           `json:"id"`          // Unique identifier for the ForStatement node.
	NodeType    ast_pb.NodeType `json:"nodeType"`    // Type of the AST node.
	Src         SrcNode         `json:"src"`         // Source location information.
	Initialiser Node[NodeType]  `json:"initialiser"` // Initialiser expression.
	Condition   Node[NodeType]  `json:"condition"`   // Condition expression.
	Closure     Node[NodeType]  `json:"closure"`     // Closure expression.
	Body        *BodyNode       `json:"body"`        // Body of the for loop.
}

ForStatement represents a for loop statement in the AST.

func NewForStatement

func NewForStatement(b *ASTBuilder) *ForStatement

NewForStatement creates a new ForStatement node with a given ASTBuilder.

func (*ForStatement) GetBody

func (f *ForStatement) GetBody() *BodyNode

GetBody returns the body of the for loop.

func (*ForStatement) GetClosure

func (f *ForStatement) GetClosure() Node[NodeType]

GetClosure returns the closure expression.

func (*ForStatement) GetCondition

func (f *ForStatement) GetCondition() Node[NodeType]

GetCondition returns the condition expression.

func (*ForStatement) GetId

func (f *ForStatement) GetId() int64

GetId returns the ID of the ForStatement node.

func (*ForStatement) GetInitialiser

func (f *ForStatement) GetInitialiser() Node[NodeType]

GetInitialiser returns the initialiser expression.

func (*ForStatement) GetNodes

func (f *ForStatement) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the ForStatement node.

func (*ForStatement) GetSrc

func (f *ForStatement) GetSrc() SrcNode

GetSrc returns the SrcNode of the ForStatement node.

func (*ForStatement) GetType

func (f *ForStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the ForStatement node.

func (*ForStatement) GetTypeDescription

func (f *ForStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the TypeDescription of the ForStatement node.

func (*ForStatement) Parse

func (f *ForStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.ForStatementContext,
) Node[NodeType]

Parse parses a for loop statement context into the ForStatement node. Documentation: https://docs.soliditylang.org/en/v0.8.19/grammar.html#a4.SolidityParser.forStatement

func (*ForStatement) SetReferenceDescriptor

func (f *ForStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the ForStatement node. We don't need to do any reference description updates here, at least for now...

func (*ForStatement) ToProto

func (f *ForStatement) ToProto() NodeType

ToProto returns a protobuf representation of the ForStatement node.

func (*ForStatement) UnmarshalJSON added in v0.3.1

func (f *ForStatement) UnmarshalJSON(data []byte) error

MarshalJSON marshals the ForStatement node into a JSON byte slice.

type Function

type Function struct {
	*ASTBuilder // Embedded ASTBuilder for creating the AST.

	// Core properties of a function node.
	Id                    int64                 `json:"id"`
	Name                  string                `json:"name"`
	NodeType              ast_pb.NodeType       `json:"nodeType"`
	Kind                  ast_pb.NodeType       `json:"kind"`
	Src                   SrcNode               `json:"src"`
	NameLocation          SrcNode               `json:"nameLocation"`
	Body                  *BodyNode             `json:"body"`
	Implemented           bool                  `json:"implemented"`
	Visibility            ast_pb.Visibility     `json:"visibility"`
	StateMutability       ast_pb.Mutability     `json:"stateMutability"`
	Virtual               bool                  `json:"virtual"`
	Modifiers             []*ModifierInvocation `json:"modifiers"`
	Overrides             []*OverrideSpecifier  `json:"overrides"`
	Parameters            *ParameterList        `json:"parameters"`
	ReturnParameters      *ParameterList        `json:"returnParameters"`
	SignatureRaw          string                `json:"signatureRaw"`
	SignatureBytes        []byte                `json:"-"`
	Signature             string                `json:"signature"`
	Scope                 int64                 `json:"scope"`
	ReferencedDeclaration int64                 `json:"referencedDeclaration,omitempty"`
	TypeDescription       *TypeDescription      `json:"typeDescription"`
	Text                  string                `json:"text,omitempty"`
}

Function represents a Solidity function definition within an abstract syntax tree.

func NewFunction

func NewFunction(b *ASTBuilder) *Function

NewFunction creates and initializes a new Function node.

func (*Function) ComputeSignature added in v0.3.1

func (f *Function) ComputeSignature()

ComputeSignature computes the signature of the Function node.

func (*Function) GetBody

func (f *Function) GetBody() *BodyNode

GetBody returns the body of the Function node.

func (*Function) GetId

func (f *Function) GetId() int64

GetId returns the unique identifier of the Function node.

func (*Function) GetKind

func (f *Function) GetKind() ast_pb.NodeType

GetKind returns the kind of the Function node.

func (*Function) GetModifiers

func (f *Function) GetModifiers() []*ModifierInvocation

GetModifiers returns the list of modifier invocations applied to the Function node.

func (*Function) GetName

func (f *Function) GetName() string

GetName returns the name of the Function node.

func (*Function) GetNameLocation

func (f *Function) GetNameLocation() SrcNode

GetNameLocation returns the source location information of the name of the Function node.

func (*Function) GetNodes

func (f *Function) GetNodes() []Node[NodeType]

GetNodes returns a list of child nodes within the Function node.

func (*Function) GetOverrides

func (f *Function) GetOverrides() []*OverrideSpecifier

GetOverrides returns the list of override specifiers associated with the Function node.

func (*Function) GetParameters

func (f *Function) GetParameters() *ParameterList

GetParameters returns the list of parameters of the Function node.

func (*Function) GetReferencedDeclaration

func (f *Function) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration identifier associated with the Function node.

func (*Function) GetReturnParameters

func (f *Function) GetReturnParameters() *ParameterList

GetReturnParameters returns the list of return parameters of the Function node.

func (*Function) GetScope

func (f *Function) GetScope() int64

GetScope returns the scope of the Function node.

func (*Function) GetSignature added in v0.3.1

func (f *Function) GetSignature() string

GetSignature computes the keccak signature of the Function node.

func (*Function) GetSignatureBytes added in v0.3.1

func (f *Function) GetSignatureBytes() []byte

GetSignatureBytes returns the keccak signature full bytes of the Function node.

func (*Function) GetSignatureRaw added in v0.3.1

func (f *Function) GetSignatureRaw() string

GetSignatureRaw returns the raw signature of the Function node.

func (*Function) GetSrc

func (f *Function) GetSrc() SrcNode

GetSrc returns the source location information of the Function node.

func (*Function) GetStateMutability

func (f *Function) GetStateMutability() ast_pb.Mutability

GetStateMutability returns the state mutability of the Function node.

func (*Function) GetType

func (f *Function) GetType() ast_pb.NodeType

GetType returns the type of the Function node.

func (*Function) GetTypeDescription

func (f *Function) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the Function node.

func (*Function) GetVisibility

func (f *Function) GetVisibility() ast_pb.Visibility

GetVisibility returns the visibility of the Function node.

func (*Function) IsImplemented

func (f *Function) IsImplemented() bool

IsImplemented returns true if the Function node is implemented, false otherwise.

func (*Function) IsVirtual

func (f *Function) IsVirtual() bool

IsVirtual returns true if the Function node is declared as virtual, false otherwise.

func (*Function) Parse

Parse parses the source code and constructs the Function node.

func (*Function) ParseTypeName added in v0.3.1

func (f *Function) ParseTypeName(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	parentNodeId int64,
	ctx *parser.FunctionTypeNameContext,
) Node[NodeType]

ParseTypeName parses the source code and constructs the Function node for TypeName.

func (*Function) SetReferenceDescriptor

func (f *Function) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Function node.

func (*Function) ToProto

func (f *Function) ToProto() NodeType

ToProto converts the Function node to its corresponding protobuf representation.

func (*Function) ToString added in v0.3.2

func (f *Function) ToString() string

func (*Function) UnmarshalJSON added in v0.3.1

func (f *Function) UnmarshalJSON(data []byte) error

type FunctionCall

type FunctionCall struct {
	*ASTBuilder

	Id                    int64              `json:"id"`                              // Unique identifier for the node.
	NodeType              ast_pb.NodeType    `json:"nodeType"`                        // Type of the node.
	Kind                  ast_pb.NodeType    `json:"kind"`                            // Kind of the node.
	Src                   SrcNode            `json:"src"`                             // Source location of the node.
	ArgumentTypes         []*TypeDescription `json:"argumentTypes"`                   // Types of the arguments.
	Arguments             []Node[NodeType]   `json:"arguments"`                       // Arguments of the function call.
	Expression            Node[NodeType]     `json:"expression"`                      // Expression of the function call.
	ReferencedDeclaration int64              `json:"referencedDeclaration,omitempty"` // Referenced declaration of the function call.
	TypeDescription       *TypeDescription   `json:"typeDescription"`                 // Type description of the function call.
}

FunctionCall represents a function call node in the AST.

func NewFunctionCall

func NewFunctionCall(b *ASTBuilder) *FunctionCall

NewFunctionCall creates a new FunctionCall node with a given ASTBuilder. It initializes the Arguments slice and sets the NodeType and Kind to FUNCTION_CALL.

func (*FunctionCall) GetArgumentTypes

func (f *FunctionCall) GetArgumentTypes() []*TypeDescription

GetArgumentTypes returns the types of the arguments of the FunctionCall node.

func (*FunctionCall) GetArguments

func (f *FunctionCall) GetArguments() []Node[NodeType]

GetArguments returns the arguments of the FunctionCall node.

func (*FunctionCall) GetExpression

func (f *FunctionCall) GetExpression() Node[NodeType]

GetExpression returns the expression of the FunctionCall node.

func (*FunctionCall) GetId

func (f *FunctionCall) GetId() int64

GetId returns the unique identifier of the FunctionCall node.

func (*FunctionCall) GetKind

func (f *FunctionCall) GetKind() ast_pb.NodeType

GetKind returns the kind of the FunctionCall node.

func (*FunctionCall) GetNodes

func (f *FunctionCall) GetNodes() []Node[NodeType]

GetNodes returns a slice of nodes that includes the expression of the FunctionCall node.

func (*FunctionCall) GetReferenceDeclaration

func (f *FunctionCall) GetReferenceDeclaration() int64

GetReferenceDeclaration returns the referenced declaration of the FunctionCall node.

func (*FunctionCall) GetSrc

func (f *FunctionCall) GetSrc() SrcNode

GetSrc returns the source location of the FunctionCall node.

func (*FunctionCall) GetType

func (f *FunctionCall) GetType() ast_pb.NodeType

GetType returns the type of the FunctionCall node.

func (*FunctionCall) GetTypeDescription

func (f *FunctionCall) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the FunctionCall node. Currently, it returns nil and needs to be implemented.

func (*FunctionCall) Parse

func (f *FunctionCall) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	ctx *parser.FunctionCallContext,
) Node[NodeType]

Parse takes a parser.FunctionCallContext and parses it into a FunctionCall node. It sets the Id, Src, Arguments, ArgumentTypes, and Expression of the FunctionCall node. It returns the created FunctionCall node.

func (*FunctionCall) RebuildDescriptions added in v0.3.1

func (f *FunctionCall) RebuildDescriptions()

RebuildDescriptions rebuilds the type descriptions of the FunctionCall node. It is called after the AST is built.

func (*FunctionCall) SetReferenceDescriptor

func (f *FunctionCall) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the FunctionCall node.

func (*FunctionCall) ToProto

func (f *FunctionCall) ToProto() NodeType

ToProto returns a protobuf representation of the FunctionCall node. Currently, it returns an empty Statement and needs to be implemented.

func (*FunctionCall) UnmarshalJSON added in v0.3.1

func (f *FunctionCall) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a FunctionCall node.

type FunctionCallOption

type FunctionCallOption struct {
	*ASTBuilder

	Id                    int64            `json:"id"`                              // Unique identifier for the node.
	NodeType              ast_pb.NodeType  `json:"nodeType"`                        // Type of the node.
	Kind                  ast_pb.NodeType  `json:"kind"`                            // Kind of the node.
	Src                   SrcNode          `json:"src"`                             // Source location of the node.
	Expression            Node[NodeType]   `json:"expression"`                      // Expression of the function call.
	ReferencedDeclaration int64            `json:"referencedDeclaration,omitempty"` // Referenced declaration of the function call.
	TypeDescription       *TypeDescription `json:"typeDescription"`                 // Type description of the function call.
}

FunctionCallOption represents a function call node in the AST.

func NewFunctionCallOption

func NewFunctionCallOption(b *ASTBuilder) *FunctionCallOption

NewFunctionCall creates a new FunctionCallOption node with a given ASTBuilder. It initializes the Arguments slice and sets the NodeType and Kind to FUNCTION_CALL.

func (*FunctionCallOption) GetExpression

func (f *FunctionCallOption) GetExpression() Node[NodeType]

GetExpression returns the expression of the FunctionCallOption node.

func (*FunctionCallOption) GetId

func (f *FunctionCallOption) GetId() int64

GetId returns the unique identifier of the FunctionCallOption node.

func (*FunctionCallOption) GetKind

func (f *FunctionCallOption) GetKind() ast_pb.NodeType

GetKind returns the kind of the FunctionCallOption node.

func (*FunctionCallOption) GetNodes

func (f *FunctionCallOption) GetNodes() []Node[NodeType]

GetNodes returns a slice of nodes that includes the expression of the FunctionCallOption node.

func (*FunctionCallOption) GetReferenceDeclaration

func (f *FunctionCallOption) GetReferenceDeclaration() int64

GetReferenceDeclaration returns the referenced declaration of the FunctionCallOption node.

func (*FunctionCallOption) GetSrc

func (f *FunctionCallOption) GetSrc() SrcNode

GetSrc returns the source location of the FunctionCallOption node.

func (*FunctionCallOption) GetType

func (f *FunctionCallOption) GetType() ast_pb.NodeType

GetType returns the type of the FunctionCallOption node.

func (*FunctionCallOption) GetTypeDescription

func (f *FunctionCallOption) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the FunctionCallOption node. Currently, it returns nil and needs to be implemented.

func (*FunctionCallOption) Parse

func (f *FunctionCallOption) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	ctx *parser.FunctionCallOptionsContext,
) Node[NodeType]

Parse takes a parser.FunctionCallOptionsContext and parses it into a FunctionCallOption node. It sets the Id, Src, Expression, and TypeDescription of the FunctionCallOption node. It returns the created FunctionCallOption node.

func (*FunctionCallOption) SetReferenceDescriptor

func (f *FunctionCallOption) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the FunctionCallOption node.

func (*FunctionCallOption) ToProto

func (f *FunctionCallOption) ToProto() NodeType

ToProto returns a protobuf representation of the FunctionCallOption node. Currently, it returns an empty Statement and needs to be implemented.

func (*FunctionCallOption) UnmarshalJSON added in v0.3.1

func (f *FunctionCallOption) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a FunctionCallOption node.

type IfStatement

type IfStatement struct {
	*ASTBuilder

	Id        int64           `json:"id"`        // Unique identifier of the if statement node.
	NodeType  ast_pb.NodeType `json:"nodeType"`  // Type of the node.
	Src       SrcNode         `json:"src"`       // Source location information.
	Condition Node[NodeType]  `json:"condition"` // Condition node.
	Body      Node[NodeType]  `json:"body"`      // Body node.
}

IfStatement represents an if statement node in the abstract syntax tree.

func NewIfStatement

func NewIfStatement(b *ASTBuilder) *IfStatement

NewIfStatement creates a new instance of IfStatement with the provided ASTBuilder.

func (*IfStatement) GetBody

func (i *IfStatement) GetBody() Node[NodeType]

GetBody returns the body node of the if statement.

func (*IfStatement) GetCondition

func (i *IfStatement) GetCondition() Node[NodeType]

GetCondition returns the condition node of the if statement.

func (*IfStatement) GetId

func (i *IfStatement) GetId() int64

GetId returns the unique identifier of the if statement node.

func (*IfStatement) GetNodes

func (i *IfStatement) GetNodes() []Node[NodeType]

GetNodes returns a list of nodes associated with the if statement (condition and body).

func (*IfStatement) GetSrc

func (i *IfStatement) GetSrc() SrcNode

GetSrc returns the source location information of the if statement node.

func (*IfStatement) GetType

func (i *IfStatement) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*IfStatement) GetTypeDescription

func (i *IfStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the if statement.

func (*IfStatement) Parse

func (i *IfStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.IfStatementContext,
) Node[NodeType]

Parse parses the if statement context and populates the IfStatement fields.

func (*IfStatement) SetReferenceDescriptor

func (i *IfStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptors of the IfStatement node.

func (*IfStatement) ToProto

func (i *IfStatement) ToProto() NodeType

ToProto converts the IfStatement node to its corresponding protobuf representation.

func (*IfStatement) UnmarshalJSON added in v0.3.1

func (i *IfStatement) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the JSON data into a IfStatement.

type Import

type Import struct {
	Id           int64           `json:"id"`                     // Unique identifier of the import node.
	NodeType     ast_pb.NodeType `json:"nodeType"`               // Type of the node.
	Src          SrcNode         `json:"src"`                    // Source location information.
	NameLocation *SrcNode        `json:"nameLocation,omitempty"` // Source location information of the name.
	AbsolutePath string          `json:"absolutePath"`           // Absolute path of the imported file.
	File         string          `json:"file"`                   // Filepath of the import statement.
	Scope        int64           `json:"scope"`                  // Scope of the import.
	UnitAlias    string          `json:"unitAlias"`              // Alias of the imported unit.
	As           string          `json:"as"`                     // Alias of the imported unit.
	UnitAliases  []string        `json:"unitAliases"`            // Alias of the imported unit.
	SourceUnit   int64           `json:"sourceUnit"`             // Source unit identifier.
}

Import represents an import node in the abstract syntax tree.

func (*Import) GetAbsolutePath

func (i *Import) GetAbsolutePath() string

GetAbsolutePath returns the absolute path of the imported file.

func (*Import) GetAs added in v0.3.1

func (i *Import) GetAs() string

GetAs returns the alias of the imported unit.

func (*Import) GetFile

func (i *Import) GetFile() string

GetFile returns the filepath of the import statement.

func (*Import) GetId

func (i *Import) GetId() int64

GetId returns the unique identifier of the import node.

func (*Import) GetName

func (i *Import) GetName() string

GetName returns the name of the imported file (excluding extension).

func (*Import) GetNameLocation

func (i *Import) GetNameLocation() *SrcNode

GetNameLocation returns the source location information of the name of the import node.

func (*Import) GetNodes

func (i *Import) GetNodes() []Node[NodeType]

GetNodes returns an empty slice of nodes associated with the import.

func (*Import) GetScope

func (i *Import) GetScope() int64

GetScope returns the scope of the import.

func (*Import) GetSourceUnit

func (i *Import) GetSourceUnit() int64

GetSourceUnit returns the source unit identifier of the import.

func (*Import) GetSrc

func (i *Import) GetSrc() SrcNode

GetSrc returns the source location information of the import node.

func (*Import) GetType

func (i *Import) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*Import) GetTypeDescription

func (i *Import) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the import node.

func (*Import) GetUnitAlias

func (i *Import) GetUnitAlias() string

GetUnitAlias returns the alias of the imported unit.

func (*Import) GetUnitAliases added in v0.3.1

func (i *Import) GetUnitAliases() []string

GetUnitAliases returns the aliases of the imported unit.

func (*Import) SetReferenceDescriptor

func (i *Import) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Import node.

func (*Import) ToProto

func (i *Import) ToProto() NodeType

ToProto converts the Import node to its corresponding protobuf representation.

type IndexAccess

type IndexAccess struct {
	*ASTBuilder

	Id                    int64              `json:"id"`                              // Unique identifier for the IndexAccess node.
	NodeType              ast_pb.NodeType    `json:"nodeType"`                        // Type of the AST node.
	Src                   SrcNode            `json:"src"`                             // Source location information.
	IndexExpression       Node[NodeType]     `json:"indexExpression"`                 // Index expression.
	BaseExpression        Node[NodeType]     `json:"baseExpression"`                  // Base expression.
	TypeDescriptions      []*TypeDescription `json:"typeDescriptions"`                // Type descriptions.
	ReferencedDeclaration int64              `json:"referencedDeclaration,omitempty"` // Referenced declaration.
	TypeDescription       *TypeDescription   `json:"typeDescription"`                 // Type description.
}

IndexAccess represents an index access expression in the AST.

func NewIndexAccess

func NewIndexAccess(b *ASTBuilder) *IndexAccess

NewIndexAccess creates a new IndexAccess node with a given ASTBuilder.

func (*IndexAccess) GetBaseExpression

func (i *IndexAccess) GetBaseExpression() Node[NodeType]

GetBaseExpression returns the base expression.

func (*IndexAccess) GetId

func (i *IndexAccess) GetId() int64

GetId returns the ID of the IndexAccess node.

func (*IndexAccess) GetIndexExpression

func (i *IndexAccess) GetIndexExpression() Node[NodeType]

GetIndexExpression returns the index expression.

func (*IndexAccess) GetName

func (i *IndexAccess) GetName() string

GetName returns the name of the IndexAccess node.

func (*IndexAccess) GetNodes

func (i *IndexAccess) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the IndexAccess node.

func (*IndexAccess) GetReferencedDeclaration

func (i *IndexAccess) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration.

func (*IndexAccess) GetSrc

func (i *IndexAccess) GetSrc() SrcNode

GetSrc returns the SrcNode of the IndexAccess node.

func (*IndexAccess) GetType

func (i *IndexAccess) GetType() ast_pb.NodeType

GetType returns the NodeType of the IndexAccess node.

func (*IndexAccess) GetTypeDescription

func (i *IndexAccess) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description.

func (*IndexAccess) GetTypeDescriptions

func (i *IndexAccess) GetTypeDescriptions() []*TypeDescription

GetTypeDescriptions returns the list of type descriptions.

func (*IndexAccess) Parse

func (i *IndexAccess) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	ctx *parser.IndexAccessContext,
) Node[NodeType]

Parse parses an index access context into the IndexAccess node.

func (*IndexAccess) SetReferenceDescriptor

func (i *IndexAccess) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the IndexAccess node. Here we are going to just do some magic stuff in order to figure out descriptions across the board...

func (*IndexAccess) ToProto

func (i *IndexAccess) ToProto() NodeType

ToProto returns a protobuf representation of the IndexAccess node.

func (*IndexAccess) UnmarshalJSON added in v0.3.1

func (i *IndexAccess) UnmarshalJSON(data []byte) error

UnmarshalJSON sets the IndexAccess node data from its JSON representation.

type IndexRange

type IndexRange struct {
	*ASTBuilder

	Id               int64              `json:"id"`
	NodeType         ast_pb.NodeType    `json:"nodeType"`
	Src              SrcNode            `json:"src"`
	LeftExpression   Node[NodeType]     `json:"leftExpression"`
	RightExpression  Node[NodeType]     `json:"rightExpression"`
	TypeDescriptions []*TypeDescription `json:"typeDescriptions"`
}

IndexRange represents an Index Range expression in the AST.

func NewIndexRangeAccessExpression

func NewIndexRangeAccessExpression(b *ASTBuilder) *IndexRange

NewIndexRange creates a new instance of IndexRange with initialized values.

func (*IndexRange) GetId

func (f *IndexRange) GetId() int64

GetId returns the unique identifier of the IndexRange node.

func (*IndexRange) GetLeftExpression

func (f *IndexRange) GetLeftExpression() Node[NodeType]

GetLeftExpression returns the left expression of the IndexRange.

func (*IndexRange) GetNodes

func (f *IndexRange) GetNodes() []Node[NodeType]

GetNodes returns the list of nodes within the IndexRange.

func (*IndexRange) GetRightExpression

func (f *IndexRange) GetRightExpression() Node[NodeType]

GetRightExpression returns the right expression of the IndexRange.

func (*IndexRange) GetSrc

func (f *IndexRange) GetSrc() SrcNode

GetSrc returns the source information of the IndexRange node.

func (*IndexRange) GetType

func (f *IndexRange) GetType() ast_pb.NodeType

GetType returns the node type of the IndexRange.

func (*IndexRange) GetTypeDescription

func (f *IndexRange) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the IndexRange.

func (*IndexRange) Parse

func (f *IndexRange) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	ctx *parser.IndexRangeAccessContext,
) Node[NodeType]

Parse parses the IndexRange expression from the provided context and constructs the IndexRange node.

func (*IndexRange) SetReferenceDescriptor

func (b *IndexRange) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor is used to set reference descriptions for the IndexRange node. However, this function always returns false.

func (*IndexRange) ToProto

func (f *IndexRange) ToProto() NodeType

ToProto converts the IndexRange node to its Protocol Buffers representation.

func (*IndexRange) UnmarshalJSON added in v0.3.1

func (f *IndexRange) UnmarshalJSON(data []byte) error

type InlineArray added in v0.3.1

type InlineArray struct {
	*ASTBuilder

	Id               int64              `json:"id"`               // Unique identifier for the InlineArray node.
	NodeType         ast_pb.NodeType    `json:"nodeType"`         // Type of the AST node.
	Src              SrcNode            `json:"src"`              // Source location information.
	TypeDescriptions []*TypeDescription `json:"typeDescriptions"` // Type descriptions of the InlineArray node.
	Expressions      []Node[NodeType]   `json:"expressions"`      // List of expressions in the InlineArray node.
	Empty            bool               `json:"empty"`            // Indicates whether the InlineArray node is empty.
	TypeDescription  *TypeDescription   `json:"typeDescription"`  // Type description of the InlineArray node.
}

InlineArray represents a for loop statement in the AST.

func NewInlineArrayExpression added in v0.3.1

func NewInlineArrayExpression(b *ASTBuilder) *InlineArray

NewInlineArrayExpression creates a new InlineArray node with a given ASTBuilder.

func (*InlineArray) GetExpressions added in v0.3.1

func (f *InlineArray) GetExpressions() []Node[NodeType]

GetExpressions returns the list of associated expressions.

func (*InlineArray) GetId added in v0.3.1

func (f *InlineArray) GetId() int64

GetId returns the ID of the InlineArray node.

func (*InlineArray) GetNodes added in v0.3.1

func (f *InlineArray) GetNodes() []Node[NodeType]

func (*InlineArray) GetSrc added in v0.3.1

func (f *InlineArray) GetSrc() SrcNode

GetSrc returns the SrcNode of the InlineArray node.

func (*InlineArray) GetType added in v0.3.1

func (f *InlineArray) GetType() ast_pb.NodeType

GetType returns the NodeType of the InlineArray node.

func (*InlineArray) GetTypeDescription added in v0.3.1

func (f *InlineArray) GetTypeDescription() *TypeDescription

func (*InlineArray) GetTypeDescriptions added in v0.3.1

func (f *InlineArray) GetTypeDescriptions() []*TypeDescription

func (*InlineArray) IsEmpty added in v0.3.1

func (f *InlineArray) IsEmpty() bool

IsEmpty returns true if the InlineArray node is empty.

func (*InlineArray) Parse added in v0.3.1

func (f *InlineArray) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	ctx *parser.InlineArrayContext,
) Node[NodeType]

func (*InlineArray) SetReferenceDescriptor added in v0.3.1

func (f *InlineArray) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the InlineArray node. We don't need to do any reference description updates here, at least for now...

func (*InlineArray) ToProto added in v0.3.1

func (f *InlineArray) ToProto() NodeType

func (*InlineArray) UnmarshalJSON added in v0.3.1

func (f *InlineArray) UnmarshalJSON(data []byte) error

type Interface

type Interface struct {
	*ASTBuilder                              // Embedded ASTBuilder for building the AST.
	Id                      int64            `json:"id"`                      // Unique identifier for the Interface node.
	Name                    string           `json:"name"`                    // Name of the interface.
	NodeType                ast_pb.NodeType  `json:"nodeType"`                // Type of the AST node.
	Src                     SrcNode          `json:"src"`                     // Source location information.
	NameLocation            SrcNode          `json:"nameLocation"`            // Location of the interface name.
	Abstract                bool             `json:"abstract"`                // Indicates whether the interface is abstract.
	Kind                    ast_pb.NodeType  `json:"kind"`                    // Kind of the interface.
	FullyImplemented        bool             `json:"fullyImplemented"`        // Indicates whether the interface is fully implemented.
	Nodes                   []Node[NodeType] `json:"nodes"`                   // List of child nodes within the interface.
	LinearizedBaseContracts []int64          `json:"linearizedBaseContracts"` // List of linearized base contract identifiers.
	BaseContracts           []*BaseContract  `json:"baseContracts"`           // List of base contracts.
	ContractDependencies    []int64          `json:"contractDependencies"`    // List of contract dependency identifiers.
}

Interface represents an interface definition node in the abstract syntax tree (AST). It encapsulates information about the characteristics and properties of an interface within the contract.

func NewInterfaceDefinition

func NewInterfaceDefinition(b *ASTBuilder) *Interface

NewInterfaceDefinition creates a new Interface node with default values and returns it.

func (*Interface) GetBaseContracts

func (l *Interface) GetBaseContracts() []*BaseContract

GetBaseContracts returns a list of base contracts associated with the Interface.

func (*Interface) GetConstructor

func (l *Interface) GetConstructor() *Constructor

GetConstructor returns the constructor node within the Interface, if present.

func (*Interface) GetContractDependencies

func (l *Interface) GetContractDependencies() []int64

GetContractDependencies returns a list of contract dependency identifiers for the Interface.

func (*Interface) GetEnums

func (l *Interface) GetEnums() []*EnumDefinition

GetEnums returns a list of enum definitions within the Interface.

func (*Interface) GetErrors

func (l *Interface) GetErrors() []*ErrorDefinition

GetErrors returns a list of error definitions within the Interface.

func (*Interface) GetEvents

func (l *Interface) GetEvents() []*EventDefinition

GetEvents returns a list of event definitions within the Interface.

func (*Interface) GetFallback

func (l *Interface) GetFallback() *Fallback

GetFallback returns the fallback function node within the Interface, if present.

func (*Interface) GetFunctions

func (l *Interface) GetFunctions() []*Function

GetFunctions returns a list of function definitions within the Interface.

func (*Interface) GetId

func (l *Interface) GetId() int64

GetId returns the unique identifier of the Interface node.

func (*Interface) GetKind

func (l *Interface) GetKind() ast_pb.NodeType

GetKind returns the kind of the Interface node.

func (*Interface) GetLinearizedBaseContracts

func (l *Interface) GetLinearizedBaseContracts() []int64

GetLinearizedBaseContracts returns a list of linearized base contract identifiers for the Interface.

func (*Interface) GetName

func (l *Interface) GetName() string

GetName returns the name of the interface.

func (*Interface) GetNameLocation

func (l *Interface) GetNameLocation() SrcNode

GetNameLocation returns the location of the interface name.

func (*Interface) GetNodes

func (l *Interface) GetNodes() []Node[NodeType]

GetNodes returns a slice of child nodes within the interface.

func (*Interface) GetReceive

func (l *Interface) GetReceive() *Receive

GetReceive returns the receive function node within the Interface, if present.

func (*Interface) GetSrc

func (l *Interface) GetSrc() SrcNode

GetSrc returns the source location information of the Interface node.

func (*Interface) GetStateVariables

func (l *Interface) GetStateVariables() []*StateVariableDeclaration

GetStateVariables returns a list of state variable declarations within the Interface.

func (*Interface) GetStructs

func (l *Interface) GetStructs() []*StructDefinition

GetStructs returns a list of struct definitions within the Interface.

func (*Interface) GetType

func (l *Interface) GetType() ast_pb.NodeType

GetType returns the type of the AST node, which is NodeType_CONTRACT_DEFINITION for an interface.

func (*Interface) GetTypeDescription

func (l *Interface) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the Interface node.

func (*Interface) IsAbstract

func (l *Interface) IsAbstract() bool

IsAbstract returns true if the Interface is abstract, false otherwise.

func (*Interface) IsFullyImplemented

func (l *Interface) IsFullyImplemented() bool

IsFullyImplemented returns true if the Interface is fully implemented, false otherwise.

func (*Interface) Parse

Parse is responsible for parsing the interface definition from the source unit context and populating the Interface node.

func (*Interface) SetReferenceDescriptor

func (l *Interface) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Interface node. This function currently returns false, as no reference description updates are performed.

func (*Interface) ToProto

func (l *Interface) ToProto() NodeType

ToProto converts the Interface node to its corresponding protocol buffer representation.

func (*Interface) UnmarshalJSON added in v0.3.1

func (l *Interface) UnmarshalJSON(data []byte) error

type Library

type Library struct {
	*ASTBuilder

	Id                      int64            `json:"id"`                      // Id is the unique identifier of the library node.
	Name                    string           `json:"name"`                    // Name is the name of the library.
	NodeType                ast_pb.NodeType  `json:"nodeType"`                // NodeType is the type of the node.
	Src                     SrcNode          `json:"src"`                     // Src is the source node associated with the library node.
	NameLocation            SrcNode          `json:"nameLocation"`            // NameLocation is the source node associated with the name of the library node.
	Abstract                bool             `json:"abstract"`                // Abstract indicates if the library is abstract.
	Kind                    ast_pb.NodeType  `json:"kind"`                    // Kind is the kind of the node.
	FullyImplemented        bool             `json:"fullyImplemented"`        // FullyImplemented indicates if the library is fully implemented.
	Nodes                   []Node[NodeType] `json:"nodes"`                   // Nodes are the nodes associated with the library.
	LinearizedBaseContracts []int64          `json:"linearizedBaseContracts"` // LinearizedBaseContracts are the linearized base contracts of the library.
	BaseContracts           []*BaseContract  `json:"baseContracts"`           // BaseContracts are the base contracts of the library.
	ContractDependencies    []int64          `json:"contractDependencies"`    // ContractDependencies are the contract dependencies of the library.
}

Library represents a library node in the abstract syntax tree. It includes various attributes like id, name, type, source node, abstract status, kind, implementation status, nodes, base contracts, contract dependencies and scope.

func NewLibraryDefinition

func NewLibraryDefinition(b *ASTBuilder) *Library

NewLibraryDefinition creates a new Library with the provided ASTBuilder. It returns a pointer to the created Library.

func (*Library) GetBaseContracts

func (l *Library) GetBaseContracts() []*BaseContract

GetBaseContracts returns the base contracts of the library.

func (*Library) GetConstructor

func (l *Library) GetConstructor() *Constructor

GetConstructor returns the constructor definition in the library.

func (*Library) GetContractDependencies

func (l *Library) GetContractDependencies() []int64

GetContractDependencies returns the contract dependencies of the library.

func (*Library) GetEnums

func (l *Library) GetEnums() []*EnumDefinition

GetEnums returns an array of enum definitions in the library.

func (*Library) GetErrors

func (l *Library) GetErrors() []*ErrorDefinition

GetErrors returns an array of error definitions in the library.

func (*Library) GetEvents

func (l *Library) GetEvents() []*EventDefinition

GetEvents returns an array of event definitions in the library.

func (*Library) GetFallback

func (l *Library) GetFallback() *Fallback

GetFallback returns the fallback function definition in the library.

func (*Library) GetFunctions

func (l *Library) GetFunctions() []*Function

GetFunctions returns an array of function definitions in the library.

func (*Library) GetId

func (l *Library) GetId() int64

GetId returns the unique identifier of the library node.

func (*Library) GetKind

func (l *Library) GetKind() ast_pb.NodeType

GetKind returns the kind of the library node.

func (*Library) GetLinearizedBaseContracts

func (l *Library) GetLinearizedBaseContracts() []int64

GetLinearizedBaseContracts returns the linearized base contracts of the library.

func (*Library) GetName

func (l *Library) GetName() string

GetName returns the name of the library.

func (*Library) GetNameLocation

func (l *Library) GetNameLocation() SrcNode

GetNameLocation returns the source node associated with the name of the library node.

func (*Library) GetNodes

func (l *Library) GetNodes() []Node[NodeType]

GetNodes returns the nodes associated with the library.

func (*Library) GetReceive

func (l *Library) GetReceive() *Receive

GetReceive returns the receive function definition in the library.

func (*Library) GetSrc

func (l *Library) GetSrc() SrcNode

GetSrc returns the source node associated with the library node.

func (*Library) GetStateVariables

func (l *Library) GetStateVariables() []*StateVariableDeclaration

GetStateVariables returns an array of state variable declarations in the library.

func (*Library) GetStructs

func (l *Library) GetStructs() []*StructDefinition

GetStructs returns an array of struct definitions in the library.

func (*Library) GetType

func (l *Library) GetType() ast_pb.NodeType

GetType returns the type of the library node.

func (*Library) GetTypeDescription

func (l *Library) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the library node. Currently, it returns nil and needs to be implemented.

func (*Library) IsAbstract

func (l *Library) IsAbstract() bool

IsAbstract returns a boolean indicating whether the library is abstract.

func (*Library) IsFullyImplemented

func (l *Library) IsFullyImplemented() bool

IsFullyImplemented returns a boolean indicating whether the library is fully implemented.

func (*Library) Parse

Parse parses the source unit context and library definition context to populate the library node. It takes a SourceUnitContext, a LibraryDefinitionContext, a RootNode and a SourceUnit as arguments. It does not return anything.

func (*Library) SetReferenceDescriptor

func (l *Library) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Library node.

func (*Library) ToProto

func (l *Library) ToProto() NodeType

ToProto converts the Library to a protocol buffer representation. Currently, it returns an empty Contract and needs to be implemented.

func (*Library) UnmarshalJSON added in v0.3.1

func (l *Library) UnmarshalJSON(data []byte) error

type LibraryName

type LibraryName struct {
	*ASTBuilder

	Id                    int64           `json:"id"`
	NodeType              ast_pb.NodeType `json:"nodeType"`
	Src                   SrcNode         `json:"src"`
	Name                  string          `json:"name"`
	ReferencedDeclaration int64           `json:"referencedDeclaration"`
}

LibraryName represents the name of an external library referenced in a using directive.

func (*LibraryName) ToProto

func (ln *LibraryName) ToProto() *ast_pb.LibraryName

ToProto converts the LibraryName instance to its corresponding protocol buffer representation.

type MemberAccessExpression

type MemberAccessExpression struct {
	*ASTBuilder

	Id                    int64              `json:"id"`
	Constant              bool               `json:"isConstant"`
	LValue                bool               `json:"isLValue"`
	Pure                  bool               `json:"isPure"`
	LValueRequested       bool               `json:"lValueRequested"`
	NodeType              ast_pb.NodeType    `json:"nodeType"`
	Src                   SrcNode            `json:"src"`
	MemberLocation        SrcNode            `json:"memberLocation"`
	Expression            Node[NodeType]     `json:"expression"`
	MemberName            string             `json:"memberName"`
	ArgumentTypes         []*TypeDescription `json:"argumentTypes"`
	ReferencedDeclaration int64              `json:"referencedDeclaration,omitempty"`
	TypeDescription       *TypeDescription   `json:"typeDescription"`
	Text                  string             `json:"text"`
}

MemberAccessExpression represents a member access expression node in the AST. It contains information about the accessed member, expression, type description, and related metadata.

func NewMemberAccessExpression

func NewMemberAccessExpression(b *ASTBuilder) *MemberAccessExpression

NewMemberAccessExpression creates a new MemberAccessExpression instance with initial values.

func (*MemberAccessExpression) GetArgumentTypes

func (m *MemberAccessExpression) GetArgumentTypes() []*TypeDescription

GetArgumentTypes returns the type descriptions of arguments in case of function call member access.

func (*MemberAccessExpression) GetExpression

func (m *MemberAccessExpression) GetExpression() Node[NodeType]

GetExpression returns the expression being accessed in the member access.

func (*MemberAccessExpression) GetId

func (m *MemberAccessExpression) GetId() int64

GetId returns the ID of the MemberAccessExpression node.

func (*MemberAccessExpression) GetMemberLocation

func (m *MemberAccessExpression) GetMemberLocation() SrcNode

GetMemberLocation returns the source information of the accessed member.

func (*MemberAccessExpression) GetMemberName

func (m *MemberAccessExpression) GetMemberName() string

GetMemberName returns the name of the accessed member.

func (*MemberAccessExpression) GetNodes

func (m *MemberAccessExpression) GetNodes() []Node[NodeType]

GetNodes returns the list of child nodes of the MemberAccessExpression node.

func (*MemberAccessExpression) GetReferencedDeclaration

func (m *MemberAccessExpression) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the ID of the referenced declaration in the context of member access.

func (*MemberAccessExpression) GetSrc

func (m *MemberAccessExpression) GetSrc() SrcNode

GetSrc returns the source information of the MemberAccessExpression node.

func (*MemberAccessExpression) GetType

func (m *MemberAccessExpression) GetType() ast_pb.NodeType

GetType returns the NodeType of the MemberAccessExpression node.

func (*MemberAccessExpression) GetTypeDescription

func (m *MemberAccessExpression) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the member access.

func (*MemberAccessExpression) IsConstant

func (m *MemberAccessExpression) IsConstant() bool

IsConstant returns whether the member access is constant.

func (*MemberAccessExpression) IsLValue

func (m *MemberAccessExpression) IsLValue() bool

IsLValue returns whether the member access is an l-value.

func (*MemberAccessExpression) IsLValueRequested

func (m *MemberAccessExpression) IsLValueRequested() bool

IsLValueRequested returns whether an l-value is requested in the context of member access.

func (*MemberAccessExpression) IsPure

func (m *MemberAccessExpression) IsPure() bool

IsPure returns whether the member access is pure.

func (*MemberAccessExpression) Parse

func (m *MemberAccessExpression) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	ctx *parser.MemberAccessContext,
) Node[NodeType]

Parse populates the MemberAccessExpression node based on the provided context and other information.

func (*MemberAccessExpression) SetReferenceDescriptor

func (m *MemberAccessExpression) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the MemberAccessExpression node.

func (*MemberAccessExpression) ToProto

func (m *MemberAccessExpression) ToProto() NodeType

ToProto converts the MemberAccessExpression node to its corresponding protobuf representation.

func (*MemberAccessExpression) ToText added in v0.3.2

func (m *MemberAccessExpression) ToText() string

func (*MemberAccessExpression) UnmarshalJSON added in v0.3.1

func (m *MemberAccessExpression) UnmarshalJSON(data []byte) error

type MetaType

type MetaType struct {
	*ASTBuilder

	Id                    int64            `json:"id"`                              // Unique identifier of the meta-type node.
	NodeType              ast_pb.NodeType  `json:"nodeType"`                        // Type of the node.
	Name                  string           `json:"name"`                            // Name of the meta-type.
	Src                   SrcNode          `json:"src"`                             // Source location information.
	ReferencedDeclaration int64            `json:"referencedDeclaration,omitempty"` // Referenced declaration identifier.
	TypeDescription       *TypeDescription `json:"typeDescription"`                 // Type description of the meta-type.
}

MetaType represents a meta-type node in the abstract syntax tree.

func NewMetaTypeExpression

func NewMetaTypeExpression(b *ASTBuilder) *MetaType

NewMetaTypeExpression creates a new instance of MetaType with the provided ASTBuilder.

func (*MetaType) GetId

func (m *MetaType) GetId() int64

GetId returns the unique identifier of the meta-type node.

func (*MetaType) GetName

func (m *MetaType) GetName() string

GetName returns the name of the meta-type.

func (*MetaType) GetNodes

func (m *MetaType) GetNodes() []Node[NodeType]

GetNodes returns a slice of nodes associated with the meta-type.

func (*MetaType) GetReferencedDeclaration

func (m *MetaType) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration identifier of the meta-type.

func (*MetaType) GetSrc

func (m *MetaType) GetSrc() SrcNode

GetSrc returns the source location information of the meta-type node.

func (*MetaType) GetType

func (m *MetaType) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*MetaType) GetTypeDescription

func (m *MetaType) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the meta-type.

func (*MetaType) Parse

func (m *MetaType) Parse(unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	exprNode Node[NodeType],
	ctx *parser.MetaTypeContext,
) Node[NodeType]

Parse parses the meta-type context and populates the MetaType fields.

func (*MetaType) SetReferenceDescriptor

func (m *MetaType) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptors of the MetaType node.

func (*MetaType) ToProto

func (m *MetaType) ToProto() NodeType

ToProto converts the MetaType node to its corresponding protobuf representation.

type ModifierDefinition

type ModifierDefinition struct {
	*ASTBuilder

	Id           int64             `json:"id"`           // Unique identifier of the modifier definition node.
	Name         string            `json:"name"`         // Name of the modifier.
	NodeType     ast_pb.NodeType   `json:"nodeType"`     // Type of the node.
	Src          SrcNode           `json:"src"`          // Source location information.
	NameLocation SrcNode           `json:"nameLocation"` // Source location information of the name.
	Visibility   ast_pb.Visibility `json:"visibility"`   // Visibility of the modifier.
	Virtual      bool              `json:"virtual"`      // Indicates if the modifier is virtual.
	Parameters   *ParameterList    `json:"parameters"`   // List of parameters for the modifier.
	Body         *BodyNode         `json:"body"`         // Body node of the modifier.
}

ModifierDefinition represents a modifier definition node in the abstract syntax tree.

func NewModifierDefinition

func NewModifierDefinition(b *ASTBuilder) *ModifierDefinition

NewModifierDefinition creates a new instance of ModifierDefinition with the provided ASTBuilder.

func (*ModifierDefinition) GetBody

func (m *ModifierDefinition) GetBody() *BodyNode

GetBody returns the body node of the modifier.

func (*ModifierDefinition) GetId

func (m *ModifierDefinition) GetId() int64

GetId returns the unique identifier of the modifier definition node.

func (*ModifierDefinition) GetName

func (m *ModifierDefinition) GetName() string

GetName returns the name of the modifier.

func (*ModifierDefinition) GetNameLocation

func (m *ModifierDefinition) GetNameLocation() SrcNode

GetNameLocation returns the source location information of the name of the modifier definition.

func (*ModifierDefinition) GetNodes

func (m *ModifierDefinition) GetNodes() []Node[NodeType]

GetNodes returns a list of nodes associated with the modifier definition (body statements).

func (*ModifierDefinition) GetParameters

func (m *ModifierDefinition) GetParameters() *ParameterList

GetParameters returns the parameter list of the modifier.

func (*ModifierDefinition) GetSrc

func (m *ModifierDefinition) GetSrc() SrcNode

GetSrc returns the source location information of the modifier definition node.

func (*ModifierDefinition) GetType

func (m *ModifierDefinition) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*ModifierDefinition) GetTypeDescription

func (m *ModifierDefinition) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the modifier definition.

func (*ModifierDefinition) GetVisibility

func (m *ModifierDefinition) GetVisibility() ast_pb.Visibility

GetVisibility returns the visibility of the modifier.

func (*ModifierDefinition) IsVirtual

func (m *ModifierDefinition) IsVirtual() bool

IsVirtual returns true if the modifier is virtual.

func (*ModifierDefinition) ParseDefinition

ParseDefinition parses the modifier definition context and populates the ModifierDefinition fields.

func (*ModifierDefinition) SetReferenceDescriptor

func (m *ModifierDefinition) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptors of the ModifierDefinition node.

func (*ModifierDefinition) ToProto

func (m *ModifierDefinition) ToProto() NodeType

ToProto converts the ModifierDefinition node to its corresponding protobuf representation.

func (*ModifierDefinition) UnmarshalJSON added in v0.3.1

func (m *ModifierDefinition) UnmarshalJSON(data []byte) error

type ModifierInvocation

type ModifierInvocation struct {
	*ASTBuilder

	Id            int64              `json:"id"`                     // Unique identifier of the modifier invocation node.
	Name          string             `json:"name"`                   // Name of the modifier invocation.
	NodeType      ast_pb.NodeType    `json:"nodeType"`               // Type of the node.
	Kind          ast_pb.NodeType    `json:"kind"`                   // Kind of the modifier invocation.
	Src           SrcNode            `json:"src"`                    // Source location information.
	ArgumentTypes []*TypeDescription `json:"argumentTypes"`          // Types of the arguments.
	Arguments     []Node[NodeType]   `json:"arguments"`              // Argument nodes.
	ModifierName  *ModifierName      `json:"modifierName,omitempty"` // Modifier name node.
}

ModifierInvocation represents a modifier invocation node in the abstract syntax tree.

func NewModifierInvocation

func NewModifierInvocation(b *ASTBuilder) *ModifierInvocation

NewModifierInvocation creates a new instance of ModifierInvocation with the provided ASTBuilder.

func (*ModifierInvocation) GetArgumentTypes

func (m *ModifierInvocation) GetArgumentTypes() []*TypeDescription

GetArgumentTypes returns a slice of argument types of the modifier invocation.

func (*ModifierInvocation) GetArguments

func (m *ModifierInvocation) GetArguments() []Node[NodeType]

GetArguments returns a slice of argument nodes of the modifier invocation.

func (*ModifierInvocation) GetId

func (m *ModifierInvocation) GetId() int64

GetId returns the unique identifier of the modifier invocation node.

func (*ModifierInvocation) GetKind

func (m *ModifierInvocation) GetKind() ast_pb.NodeType

GetKind returns the kind of the modifier invocation.

func (*ModifierInvocation) GetName

func (m *ModifierInvocation) GetName() string

GetName returns the name of the modifier invocation.

func (*ModifierInvocation) GetNodes

func (m *ModifierInvocation) GetNodes() []Node[NodeType]

GetNodes returns a slice of nodes associated with the modifier invocation (arguments).

func (*ModifierInvocation) GetSrc

func (m *ModifierInvocation) GetSrc() SrcNode

GetSrc returns the source location information of the modifier invocation node.

func (*ModifierInvocation) GetType

func (m *ModifierInvocation) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*ModifierInvocation) GetTypeDescription

func (m *ModifierInvocation) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the modifier invocation (returns nil).

func (*ModifierInvocation) Parse

func (m *ModifierInvocation) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx parser.IModifierInvocationContext,
)

Parse parses the modifier invocation context and populates the ModifierInvocation fields.

func (*ModifierInvocation) SetReferenceDescriptor

func (m *ModifierInvocation) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptors of the ModifierInvocation node.

func (*ModifierInvocation) ToProto

func (m *ModifierInvocation) ToProto() NodeType

ToProto converts the ModifierInvocation node to its corresponding protobuf representation.

func (*ModifierInvocation) UnmarshalJSON added in v0.3.1

func (m *ModifierInvocation) UnmarshalJSON(data []byte) error

type ModifierName

type ModifierName struct {
	Id       int64           `json:"id"`       // Unique identifier of the modifier name node.
	Name     string          `json:"name"`     // Name of the modifier.
	NodeType ast_pb.NodeType `json:"nodeType"` // Type of the node.
	Src      SrcNode         `json:"src"`      // Source location information.
}

ModifierName represents the name of a modifier in the abstract syntax tree.

func (*ModifierName) ToProto

func (m *ModifierName) ToProto() *ast_pb.ModifierName

ToProto converts the ModifierName node to its corresponding protobuf representation.

type NewExpr

type NewExpr struct {
	*ASTBuilder

	Id                    int64              `json:"id"`
	NodeType              ast_pb.NodeType    `json:"nodeType"`
	Src                   SrcNode            `json:"src"`
	ArgumentTypes         []*TypeDescription `json:"argumentTypes"`
	TypeName              *TypeName          `json:"typeName"`
	ReferencedDeclaration int64              `json:"referencedDeclaration,omitempty"`
	TypeDescription       *TypeDescription   `json:"typeDescription"`
}

NewExpr represents a new expression node in the AST. It contains information about the type being instantiated, type description, and related metadata.

func NewExprExpression

func NewExprExpression(b *ASTBuilder) *NewExpr

NewExprExpression creates a new NewExpr instance with initial values.

func (*NewExpr) GetArgumentTypes

func (n *NewExpr) GetArgumentTypes() []*TypeDescription

GetArgumentTypes returns the type descriptions of arguments in the new expression.

func (*NewExpr) GetId

func (n *NewExpr) GetId() int64

GetId returns the ID of the NewExpr node.

func (*NewExpr) GetNodes

func (n *NewExpr) GetNodes() []Node[NodeType]

GetNodes returns the list of child nodes of the NewExpr node.

func (*NewExpr) GetReferencedDeclaration

func (n *NewExpr) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the ID of the referenced declaration in the context of new expression.

func (*NewExpr) GetSrc

func (n *NewExpr) GetSrc() SrcNode

GetSrc returns the source information of the NewExpr node.

func (*NewExpr) GetType

func (n *NewExpr) GetType() ast_pb.NodeType

GetType returns the NodeType of the NewExpr node.

func (*NewExpr) GetTypeDescription

func (n *NewExpr) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the new expression.

func (*NewExpr) GetTypeName

func (n *NewExpr) GetTypeName() *TypeName

GetTypeName returns the type name associated with the new expression.

func (*NewExpr) Parse

func (n *NewExpr) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	exprNode Node[NodeType],
	ctx *parser.NewExprContext,
) Node[NodeType]

Parse populates the NewExpr node based on the provided context and other information.

func (*NewExpr) SetReferenceDescriptor

func (n *NewExpr) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the NewExpr node.

func (*NewExpr) ToProto

func (n *NewExpr) ToProto() NodeType

ToProto converts the NewExpr node to its corresponding protobuf representation.

type Node

type Node[T NodeType] interface {
	GetId() int64
	GetType() ast_pb.NodeType
	GetSrc() SrcNode
	GetTypeDescription() *TypeDescription
	GetNodes() []Node[NodeType]
	ToProto() T
	SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool
}

Node is an interface that defines methods common to all AST nodes.

func ParseYulExpression added in v0.3.1

func ParseYulExpression(
	b *ASTBuilder,
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	assignmentNode *parser.YulAssignmentContext,
	variableNode *parser.YulVariableDeclarationContext,
	parentNode Node[NodeType],
	ctx parser.IYulExpressionContext,
) Node[NodeType]

ParseYulExpression parses a YUL expression statement.

type NodeVisitor added in v0.3.2

type NodeVisitor struct {
	// Visit defines a generic function to visit nodes of any type.
	// It should return true to continue traversal, false to stop.
	Visit func(node Node[NodeType]) bool
	// TypeVisit maps node types to slices of functions that visit nodes of that specific type.
	// Each function should return a boolean indicating whether to continue traversal, and an error if one occurred.
	TypeVisit map[ast_pb.NodeType][]func(node Node[NodeType]) (bool, error)
}

NodeVisitor defines a structure for visiting nodes within an AST. It supports both a generic visit function and type-specific visit functions.

func (*NodeVisitor) RegisterTypeVisit added in v0.3.2

func (nv *NodeVisitor) RegisterTypeVisit(nodeType ast_pb.NodeType, visitFunc func(node Node[NodeType]) (bool, error))

RegisterTypeVisit allows registering one or more visitation functions for a specific node type. These functions are called when a node of the specified type is encountered during traversal.

type OverridePath added in v0.3.1

type OverridePath struct {
	Id                    int64            `json:"id"`                    // Unique identifier of the modifier name node.
	Name                  string           `json:"name"`                  // Name of the modifier.
	NodeType              ast_pb.NodeType  `json:"nodeType"`              // Type of the node.
	Src                   SrcNode          `json:"src"`                   // Source location information.
	ReferencedDeclaration int64            `json:"referencedDeclaration"` // Referenced declaration identifier.
	TypeDescription       *TypeDescription `json:"typeDescription"`       // Type description of the override specifier.
}

OverridePath represents an override path node in the abstract syntax tree.

func (*OverridePath) GetId added in v0.3.1

func (m *OverridePath) GetId() int64

GetId returns the unique identifier of the override path node.

func (*OverridePath) GetName added in v0.3.1

func (m *OverridePath) GetName() string

GetName returns the name of the override path node.

func (*OverridePath) GetNodes added in v0.3.1

func (m *OverridePath) GetNodes() []Node[NodeType]

GetNodes returns an empty slice of nodes associated with the override path.

func (*OverridePath) GetReferencedDeclaration added in v0.3.1

func (m *OverridePath) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration identifier of the override path.

func (*OverridePath) GetSrc added in v0.3.1

func (m *OverridePath) GetSrc() SrcNode

GetSrc returns the source location information of the override path node.

func (*OverridePath) GetType added in v0.3.1

func (m *OverridePath) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*OverridePath) GetTypeDescription added in v0.3.1

func (m *OverridePath) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the override path.

func (*OverridePath) SetReferenceDescriptor added in v0.3.1

func (op *OverridePath) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptor of the OverridePath.

func (*OverridePath) ToProto added in v0.3.1

func (m *OverridePath) ToProto() *ast_pb.OverridePath

ToProto converts the OverridePath node to its corresponding protobuf representation.

type OverrideSpecifier

type OverrideSpecifier struct {
	*ASTBuilder

	Id                    int64            `json:"id"`                    // Unique identifier of the override specifier node.
	NodeType              ast_pb.NodeType  `json:"nodeType"`              // Type of the node.
	Src                   SrcNode          `json:"src"`                   // Source location information.
	Overrides             []*OverridePath  `json:"overrides"`             // List of override paths.
	ReferencedDeclaration int64            `json:"referencedDeclaration"` // Referenced declaration identifier.
	TypeDescription       *TypeDescription `json:"typeDescriptions"`      // Type description of the override specifier.
}

OverrideSpecifier represents an override specifier node in the abstract syntax tree.

func NewOverrideSpecifier

func NewOverrideSpecifier(b *ASTBuilder) *OverrideSpecifier

NewOverrideSpecifier creates a new instance of OverrideSpecifier with the provided ASTBuilder.

func (*OverrideSpecifier) GetId

func (o *OverrideSpecifier) GetId() int64

GetId returns the unique identifier of the override specifier node.

func (*OverrideSpecifier) GetNodes

func (o *OverrideSpecifier) GetNodes() []Node[NodeType]

GetNodes returns an empty slice of nodes associated with the override specifier.

func (*OverrideSpecifier) GetOverrides added in v0.3.1

func (o *OverrideSpecifier) GetOverrides() []*OverridePath

GetOverrides returns the list of override paths.

func (*OverrideSpecifier) GetReferencedDeclaration

func (o *OverrideSpecifier) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration identifier of the override specifier.

func (*OverrideSpecifier) GetSrc

func (o *OverrideSpecifier) GetSrc() SrcNode

GetSrc returns the source location information of the override specifier node.

func (*OverrideSpecifier) GetType

func (o *OverrideSpecifier) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*OverrideSpecifier) GetTypeDescription

func (o *OverrideSpecifier) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the override specifier.

func (*OverrideSpecifier) Parse

Parse parses the override specifier context and populates the OverrideSpecifier fields.

func (*OverrideSpecifier) SetReferenceDescriptor

func (o *OverrideSpecifier) SetReferenceDescriptor(refId int64, refType *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptor of the OverrideSpecifier.

func (*OverrideSpecifier) ToProto

func (o *OverrideSpecifier) ToProto() NodeType

ToProto converts the OverrideSpecifier node to its corresponding protobuf representation.

type Parameter

type Parameter struct {
	*ASTBuilder

	Id              int64                  `json:"id"`                        // Unique identifier of the parameter node.
	NodeType        ast_pb.NodeType        `json:"nodeType"`                  // Type of the node.
	Src             SrcNode                `json:"src"`                       // Source location information.
	NameLocation    *SrcNode               `json:"nameLocation,omitempty"`    // Source location information of the name.
	Scope           int64                  `json:"scope,omitempty"`           // Scope of the parameter.
	Name            string                 `json:"name"`                      // Name of the parameter.
	TypeName        *TypeName              `json:"typeName,omitempty"`        // Type name of the parameter.
	StorageLocation ast_pb.StorageLocation `json:"storageLocation,omitempty"` // Storage location of the parameter.
	Visibility      ast_pb.Visibility      `json:"visibility,omitempty"`      // Visibility of the parameter.
	StateMutability ast_pb.Mutability      `json:"stateMutability,omitempty"` // State mutability of the parameter.
	Constant        bool                   `json:"constant,omitempty"`        // Whether the parameter is constant.
	StateVariable   bool                   `json:"stateVariable,omitempty"`   // Whether the parameter is a state variable.
	TypeDescription *TypeDescription       `json:"typeDescription,omitempty"` // Type description of the parameter.
	Indexed         bool                   `json:"indexed,omitempty"`         // Whether the parameter is indexed.
}

Parameter represents a parameter node in the abstract syntax tree.

func NewParameter

func NewParameter(b *ASTBuilder) *Parameter

NewParameter creates a new instance of Parameter with the provided ASTBuilder.

func (*Parameter) GetId

func (p *Parameter) GetId() int64

GetId returns the unique identifier of the parameter node.

func (*Parameter) GetName

func (p *Parameter) GetName() string

GetName returns the name of the parameter.

func (*Parameter) GetNameLocation

func (p *Parameter) GetNameLocation() *SrcNode

GetNameLocation returns the source location information of the name of the parameter.

func (*Parameter) GetNodes

func (p *Parameter) GetNodes() []Node[NodeType]

GetNodes returns a slice of nodes associated with the parameter.

func (*Parameter) GetScope

func (p *Parameter) GetScope() int64

GetScope returns the scope of the parameter.

func (*Parameter) GetSrc

func (p *Parameter) GetSrc() SrcNode

GetSrc returns the source location information of the parameter node.

func (*Parameter) GetStateMutability

func (p *Parameter) GetStateMutability() ast_pb.Mutability

GetStateMutability returns the state mutability of the parameter.

func (*Parameter) GetStorageLocation

func (p *Parameter) GetStorageLocation() ast_pb.StorageLocation

GetStorageLocation returns the storage location of the parameter.

func (*Parameter) GetType

func (p *Parameter) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*Parameter) GetTypeDescription

func (p *Parameter) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the parameter.

func (*Parameter) GetTypeName

func (p *Parameter) GetTypeName() *TypeName

GetTypeName returns the type name of the parameter.

func (*Parameter) GetVisibility

func (p *Parameter) GetVisibility() ast_pb.Visibility

GetVisibility returns the visibility of the parameter.

func (*Parameter) IsConstant

func (p *Parameter) IsConstant() bool

IsConstant returns whether the parameter is constant.

func (*Parameter) IsIndexed

func (p *Parameter) IsIndexed() bool

IsIndexed returns whether the parameter is indexed.

func (*Parameter) IsStateVariable

func (p *Parameter) IsStateVariable() bool

IsStateVariable returns whether the parameter is a state variable.

func (*Parameter) Parse

Parse parses the parameter declaration context and populates the Parameter fields.

func (*Parameter) ParseErrorParameter

func (p *Parameter) ParseErrorParameter(unit *SourceUnit[Node[ast_pb.SourceUnit]], fnNode Node[NodeType], plNode Node[*ast_pb.ParameterList], ctx parser.IErrorParameterContext)

ParseErrorParameter parses the error parameter context and populates the Parameter fields for error definitions.

func (*Parameter) ParseEventParameter

func (p *Parameter) ParseEventParameter(unit *SourceUnit[Node[ast_pb.SourceUnit]], fnNode Node[NodeType], plNode Node[*ast_pb.ParameterList], ctx parser.IEventParameterContext)

ParseEventParameter parses the event parameter context and populates the Parameter fields for event parameters.

func (*Parameter) ParseStructParameter

func (p *Parameter) ParseStructParameter(unit *SourceUnit[Node[ast_pb.SourceUnit]], contractNode Node[NodeType], structNode *StructDefinition, ctx parser.IStructMemberContext)

ParseStructParameter parses the struct parameter context and populates the Parameter fields for struct members.

func (*Parameter) SetReferenceDescriptor

func (p *Parameter) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptors of the Parameter node.

func (*Parameter) ToProto

func (p *Parameter) ToProto() NodeType

ToProto converts the Parameter node to its corresponding protobuf representation.

func (*Parameter) UnmarshalJSON added in v0.3.1

func (p *Parameter) UnmarshalJSON(data []byte) error

type ParameterList

type ParameterList struct {
	*ASTBuilder

	Id             int64              `json:"id"`
	NodeType       ast_pb.NodeType    `json:"nodeType"`
	Src            SrcNode            `json:"src"`
	Parameters     []*Parameter       `json:"parameters"`
	ParameterTypes []*TypeDescription `json:"parameterTypes"`
}

ParameterList represents a list of function or event parameters in the AST.

func NewParameterList

func NewParameterList(b *ASTBuilder) *ParameterList

NewParameterList creates a new instance of ParameterList using the provided ASTBuilder.

func (*ParameterList) GetId

func (p *ParameterList) GetId() int64

GetId returns the ID of the ParameterList node.

func (*ParameterList) GetNodes

func (p *ParameterList) GetNodes() []Node[NodeType]

GetNodes returns a list of child nodes contained in the ParameterList.

func (*ParameterList) GetParameterTypes

func (p *ParameterList) GetParameterTypes() []*TypeDescription

GetParameterTypes returns the list of parameter types in the ParameterList.

func (*ParameterList) GetParameters

func (p *ParameterList) GetParameters() []*Parameter

GetParameters returns the list of parameters in the ParameterList.

func (*ParameterList) GetSrc

func (p *ParameterList) GetSrc() SrcNode

GetSrc returns the source information of the ParameterList node.

func (*ParameterList) GetType

func (p *ParameterList) GetType() ast_pb.NodeType

GetType returns the NodeType of the ParameterList node.

func (*ParameterList) GetTypeDescription

func (p *ParameterList) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the ParameterList node.

func (*ParameterList) Parse

Parse parses the ParameterList node from the provided context.

func (*ParameterList) ParseErrorParameters

func (p *ParameterList) ParseErrorParameters(unit *SourceUnit[Node[ast_pb.SourceUnit]], eNode Node[NodeType], ctx []parser.IErrorParameterContext)

ParseErrorParameters parses error parameters from the provided context.

func (*ParameterList) ParseEventParameters

func (p *ParameterList) ParseEventParameters(unit *SourceUnit[Node[ast_pb.SourceUnit]], eNode Node[NodeType], ctx []parser.IEventParameterContext)

ParseEventParameters parses event parameters from the provided context.

func (*ParameterList) SetReferenceDescriptor

func (p *ParameterList) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the ParameterList node.

func (*ParameterList) ToProto

func (p *ParameterList) ToProto() *ast_pb.ParameterList

ToProto converts the ParameterList into its corresponding Protocol Buffers representation. TODO: Proto ParameterTypes...

func (*ParameterList) UnmarshalJSON added in v0.3.1

func (p *ParameterList) UnmarshalJSON(data []byte) error

type PathNode

type PathNode struct {
	Id                    int64            `json:"id"`
	Name                  string           `json:"name"`
	NodeType              ast_pb.NodeType  `json:"nodeType"`
	ReferencedDeclaration int64            `json:"referencedDeclaration"`
	Src                   SrcNode          `json:"src"`
	NameLocation          *SrcNode         `json:"nameLocation,omitempty"`
	TypeDescription       *TypeDescription `json:"typeDescription,omitempty"`
}

PathNode represents a path node within a TypeName.

func (*PathNode) GetId added in v0.3.1

func (pn *PathNode) GetId() int64

GetId returns the unique identifier of the PathNode.

func (*PathNode) GetName added in v0.3.1

func (pn *PathNode) GetName() string

GetName returns the name of the PathNode.

func (*PathNode) GetNameLocation added in v0.3.1

func (pn *PathNode) GetNameLocation() *SrcNode

GetNameLocation returns the name location of the PathNode.

func (*PathNode) GetNodes added in v0.3.1

func (pn *PathNode) GetNodes() []Node[NodeType]

GetNodes returns a list of child nodes for traversal within the PathNode.

func (*PathNode) GetReferencedDeclaration added in v0.3.1

func (pn *PathNode) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the PathNode.

func (*PathNode) GetSrc added in v0.3.1

func (pn *PathNode) GetSrc() SrcNode

GetSrc returns the source location information of the PathNode.

func (*PathNode) GetType added in v0.3.1

func (pn *PathNode) GetType() ast_pb.NodeType

GetType returns the node type of the PathNode.

func (*PathNode) GetTypeDescription added in v0.3.1

func (pn *PathNode) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the PathNode.

func (*PathNode) SetReferenceDescriptor added in v0.3.1

func (pn *PathNode) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the PathNode node.

func (*PathNode) ToProto

func (pn *PathNode) ToProto() NodeType

ToProto converts the PathNode instance to its corresponding protocol buffer representation.

type PayableConversion

type PayableConversion struct {
	*ASTBuilder

	Id                    int64              `json:"id"`
	NodeType              ast_pb.NodeType    `json:"nodeType"`
	Src                   SrcNode            `json:"src"`
	Arguments             []Node[NodeType]   `json:"arguments"`
	ArgumentTypes         []*TypeDescription `json:"argumentTypes"`
	ReferencedDeclaration int64              `json:"referencedDeclaration,omitempty"`
	TypeDescription       *TypeDescription   `json:"typeDescription"`
	Payable               bool               `json:"payable"`
}

PayableConversion represents a payable conversion expression in the AST.

func NewPayableConversionExpression

func NewPayableConversionExpression(b *ASTBuilder) *PayableConversion

NewPayableConversionExpression creates a new instance of PayableConversion using the provided ASTBuilder.

func (*PayableConversion) GetArgumentTypes

func (p *PayableConversion) GetArgumentTypes() []*TypeDescription

GetArgumentTypes returns the list of argument types in the PayableConversion node.

func (*PayableConversion) GetArguments

func (p *PayableConversion) GetArguments() []Node[NodeType]

GetArguments returns the list of arguments in the PayableConversion node.

func (*PayableConversion) GetId

func (p *PayableConversion) GetId() int64

GetId returns the ID of the PayableConversion node.

func (*PayableConversion) GetNodes

func (p *PayableConversion) GetNodes() []Node[NodeType]

GetNodes returns a list of child nodes contained in the PayableConversion.

func (*PayableConversion) GetReferencedDeclaration

func (p *PayableConversion) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the ID of the referenced declaration.

func (*PayableConversion) GetSrc

func (p *PayableConversion) GetSrc() SrcNode

GetSrc returns the source information of the PayableConversion node.

func (*PayableConversion) GetType

func (p *PayableConversion) GetType() ast_pb.NodeType

GetType returns the NodeType of the PayableConversion node.

func (*PayableConversion) GetTypeDescription

func (p *PayableConversion) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the PayableConversion node.

func (*PayableConversion) IsPayable

func (p *PayableConversion) IsPayable() bool

IsPayable returns whether the PayableConversion is marked as payable.

func (*PayableConversion) Parse

func (p *PayableConversion) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	exprNode Node[NodeType],
	ctx *parser.PayableConversionContext,
) Node[NodeType]

Parse parses the PayableConversion node from the provided context.

func (*PayableConversion) RebuildDescriptions added in v0.3.2

func (p *PayableConversion) RebuildDescriptions()

RebuildDescriptions rebuilds the type descriptions of the FunctionCall node. It is called after the AST is built.

func (*PayableConversion) SetReferenceDescriptor

func (p *PayableConversion) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the PayableConversion node.

func (*PayableConversion) ToProto

func (p *PayableConversion) ToProto() NodeType

ToProto converts the PayableConversion into its corresponding Protocol Buffers representation.

func (*PayableConversion) UnmarshalJSON added in v0.3.1

func (p *PayableConversion) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a PayableConversion node.

type Pragma

type Pragma struct {
	// Id is the unique identifier of the pragma directive.
	Id int64 `json:"id"`
	// NodeType is the type of the node.
	// For a Pragma, this is always NodeType_PRAGMA_DIRECTIVE.
	NodeType ast_pb.NodeType `json:"nodeType"`
	// SrcNode contains source information about the node, such as its line and column numbers in the source file.
	Src SrcNode `json:"src"`
	// Literals is a slice of strings that represent the literals of the pragma directive.
	// For example, for the pragma directive "pragma solidity ^0.5.0;", the literals would
	// be ["solidity", "^", "0", ".", "5", ".", "0"].
	Literals []string `json:"literals"`
	// Text is the text of the pragma directive.
	Text string `json:"text"`
}

Pragma represents a pragma directive in a Solidity source file. A pragma directive provides instructions to the compiler about how to treat the source code (e.g., compiler version).

func CreatePragmaFromCtx

func CreatePragmaFromCtx(b *ASTBuilder, unit *SourceUnit[Node[ast_pb.SourceUnit]], pragmaCtx *parser.PragmaDirectiveContext) *Pragma

CreatePragmaFromCtx creates a new Pragma from the provided pragma context. It sets the ID of the new node to the next available ID from the provided ASTBuilder, and sets the source information of the node based on the provided pragma context. The NodeType of the new node is set to NodeType_PRAGMA_DIRECTIVE, and the literals of the node are set to the literals of the pragma context.

The function takes the following parameters:

  • b: The ASTBuilder from which to get the next available ID.
  • unit: The SourceUnit to which the new node will belong. The ID of the unit is set as the ParentIndex of the new node.
  • pragmaCtx: The pragma context from which to create the new node. The source information and literals of the new node are set based on this context.

The function returns a pointer to the newly created Pragma.

func (*Pragma) GetId

func (p *Pragma) GetId() int64

GetId returns the unique identifier of the pragma directive.

func (*Pragma) GetLiterals

func (p *Pragma) GetLiterals() []string

GetLiterals returns a slice of strings that represent the literals of the pragma directive.

func (*Pragma) GetNodes

func (p *Pragma) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the node. For a Pragma, this is always nil.

func (*Pragma) GetSrc

func (p *Pragma) GetSrc() SrcNode

GetSrc returns the source information about the node, such as its line and column numbers in the source file.

func (*Pragma) GetText

func (p *Pragma) GetText() string

GetText returns the text of the pragma directive.

func (*Pragma) GetType

func (p *Pragma) GetType() ast_pb.NodeType

GetType returns the type of the node. For a Pragma, this is always NodeType_PRAGMA_DIRECTIVE.

func (*Pragma) GetTypeDescription

func (p *Pragma) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the node. For a Pragma, this is always nil.

func (*Pragma) SetReferenceDescriptor

func (p *Pragma) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Pragma node.

func (*Pragma) ToProto

func (p *Pragma) ToProto() NodeType

ToProto returns the protobuf representation of the node.

type PrimaryExpression

type PrimaryExpression struct {
	*ASTBuilder

	Id                     int64              `json:"id"`                        // Unique identifier for the node.
	NodeType               ast_pb.NodeType    `json:"nodeType"`                  // Type of the node.
	Kind                   ast_pb.NodeType    `json:"kind,omitempty"`            // Kind of the node.
	Value                  string             `json:"value,omitempty"`           // Value of the node.
	HexValue               string             `json:"hexValue,omitempty"`        // Hexadecimal value of the node.
	Src                    SrcNode            `json:"src"`                       // Source location of the node.
	Name                   string             `json:"name,omitempty"`            // Name of the node.
	TypeName               *TypeName          `json:"typeName,omitempty"`        // Type name of the node.
	TypeDescription        *TypeDescription   `json:"typeDescription,omitempty"` // Type description of the node.
	OverloadedDeclarations []int64            `json:"overloadedDeclarations"`    // Overloaded declarations of the node.
	ReferencedDeclaration  int64              `json:"referencedDeclaration"`     // Referenced declaration of the node.
	Pure                   bool               `json:"isPure"`                    // Indicates if the node is pure.
	ArgumentTypes          []*TypeDescription `json:"argumentTypes,omitempty"`   // Argument types of the node.
	Text                   string             `json:"text,omitempty"`            // Text of the node.
}

PrimaryExpression represents a primary expression node in the AST.

func NewPrimaryExpression

func NewPrimaryExpression(b *ASTBuilder) *PrimaryExpression

NewPrimaryExpression creates a new PrimaryExpression node with a given ASTBuilder. It initializes the OverloadedDeclarations slice and sets the NodeType to IDENTIFIER.

func (*PrimaryExpression) GetArgumentTypes

func (p *PrimaryExpression) GetArgumentTypes() []*TypeDescription

GetArgumentTypes returns the argument types of the PrimaryExpression node.

func (*PrimaryExpression) GetHexValue

func (p *PrimaryExpression) GetHexValue() string

GetHexValue returns the hexadecimal value of the PrimaryExpression node.

func (*PrimaryExpression) GetId

func (p *PrimaryExpression) GetId() int64

GetId returns the unique identifier of the PrimaryExpression node.

func (*PrimaryExpression) GetKind

func (p *PrimaryExpression) GetKind() ast_pb.NodeType

GetKind returns the kind of the PrimaryExpression node.

func (*PrimaryExpression) GetName

func (p *PrimaryExpression) GetName() string

GetName returns the name of the PrimaryExpression node.

func (*PrimaryExpression) GetNodes

func (p *PrimaryExpression) GetNodes() []Node[NodeType]

GetNodes returns a slice of nodes that includes the expression of the PrimaryExpression node.

func (*PrimaryExpression) GetOverloadedDeclarations

func (p *PrimaryExpression) GetOverloadedDeclarations() []int64

GetOverloadedDeclarations returns the overloaded declarations of the PrimaryExpression node.

func (*PrimaryExpression) GetReferencedDeclaration

func (p *PrimaryExpression) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the PrimaryExpression node.

func (*PrimaryExpression) GetSrc

func (p *PrimaryExpression) GetSrc() SrcNode

GetSrc returns the source location of the PrimaryExpression node.

func (*PrimaryExpression) GetType

func (p *PrimaryExpression) GetType() ast_pb.NodeType

GetType returns the type of the PrimaryExpression node.

func (*PrimaryExpression) GetTypeDescription

func (p *PrimaryExpression) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the PrimaryExpression node.

func (*PrimaryExpression) GetTypeName

func (p *PrimaryExpression) GetTypeName() *TypeName

GetTypeName returns the type name of the PrimaryExpression node.

func (*PrimaryExpression) GetValue

func (p *PrimaryExpression) GetValue() string

GetValue returns the value of the PrimaryExpression node.

func (*PrimaryExpression) IsPure

func (p *PrimaryExpression) IsPure() bool

IsPure returns true if the PrimaryExpression node is pure.

func (*PrimaryExpression) Parse

func (p *PrimaryExpression) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.PrimaryExpressionContext,
) Node[NodeType]

Parse takes a parser.PrimaryExpressionContext and parses it into a PrimaryExpression node. It sets the Src, Name, NodeType, Kind, Value, HexValue, TypeDescription, and other properties of the PrimaryExpression node. It returns the created PrimaryExpression node.

func (*PrimaryExpression) Rebuild added in v0.3.1

func (p *PrimaryExpression) Rebuild()

Rebuild rebuilds the PrimaryExpression node after referenced declaration is set.

func (*PrimaryExpression) SetReferenceDescriptor

func (p *PrimaryExpression) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the PrimaryExpression node.

func (*PrimaryExpression) ToProto

func (p *PrimaryExpression) ToProto() NodeType

ToProto returns a protobuf representation of the PrimaryExpression node. Currently, it returns an empty PrimaryExpression and needs to be implemented.

type Receive

type Receive struct {
	*ASTBuilder                            // Embedded ASTBuilder for building the AST.
	Id               int64                 `json:"id"`               // Unique identifier for the Receive node.
	NodeType         ast_pb.NodeType       `json:"nodeType"`         // Type of the AST node.
	Kind             ast_pb.NodeType       `json:"kind"`             // Kind of the receive function.
	Src              SrcNode               `json:"src"`              // Source location information.
	Implemented      bool                  `json:"implemented"`      // Indicates whether the function is implemented.
	Visibility       ast_pb.Visibility     `json:"visibility"`       // Visibility of the receive function.
	StateMutability  ast_pb.Mutability     `json:"stateMutability"`  // State mutability of the receive function.
	Modifiers        []*ModifierInvocation `json:"modifiers"`        // List of modifier invocations applied to the receive function.
	Overrides        []*OverrideSpecifier  `json:"overrides"`        // List of override specifiers for the receive function.
	Parameters       *ParameterList        `json:"parameters"`       // List of parameters for the receive function.
	ReturnParameters *ParameterList        `json:"returnParameters"` // List of return parameters for the receive function.
	Body             *BodyNode             `json:"body"`             // Body of the receive function.
	Virtual          bool                  `json:"virtual"`          // Indicates whether the function is virtual.
	Payable          bool                  `json:"payable"`          // Indicates whether the function is payable.
}

Receive represents a receive function definition node in the abstract syntax tree (AST). It encapsulates information about the characteristics and properties of a receive function within a contract.

func NewReceiveDefinition

func NewReceiveDefinition(b *ASTBuilder) *Receive

NewReceiveDefinition creates a new Receive node with default values and returns it.

func (*Receive) GetBody

func (f *Receive) GetBody() *BodyNode

GetBody returns the body of the Receive node.

func (*Receive) GetId

func (f *Receive) GetId() int64

GetId returns the unique identifier of the Receive node.

func (*Receive) GetKind

func (f *Receive) GetKind() ast_pb.NodeType

GetKind returns the kind of the Receive node, which is NodeType_RECEIVE.

func (*Receive) GetModifiers

func (f *Receive) GetModifiers() []*ModifierInvocation

GetModifiers returns a list of modifier invocations applied to the Receive node.

func (*Receive) GetNodes

func (f *Receive) GetNodes() []Node[NodeType]

GetNodes returns a slice of child nodes within the body of the receive function.

func (*Receive) GetOverrides

func (f *Receive) GetOverrides() []*OverrideSpecifier

GetOverrides returns a list of override specifiers for the Receive node.

func (*Receive) GetParameters

func (f *Receive) GetParameters() *ParameterList

GetParameters returns the list of parameters for the Receive node.

func (*Receive) GetReturnParameters

func (f *Receive) GetReturnParameters() *ParameterList

GetReturnParameters returns the list of return parameters for the Receive node.

func (*Receive) GetSrc

func (f *Receive) GetSrc() SrcNode

GetSrc returns the source location information of the Receive node.

func (*Receive) GetStateMutability

func (f *Receive) GetStateMutability() ast_pb.Mutability

GetStateMutability returns the state mutability of the Receive function.

func (*Receive) GetType

func (f *Receive) GetType() ast_pb.NodeType

GetType returns the type of the AST node, which is NodeType_FUNCTION_DEFINITION for a receive function.

func (*Receive) GetTypeDescription

func (f *Receive) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the Receive node (currently returns nil).

func (*Receive) GetVisibility

func (f *Receive) GetVisibility() ast_pb.Visibility

GetVisibility returns the visibility of the Receive function.

func (*Receive) IsImplemented

func (f *Receive) IsImplemented() bool

IsImplemented returns true if the Receive function is implemented, false otherwise.

func (*Receive) IsVirtual

func (f *Receive) IsVirtual() bool

IsVirtual returns true if the Receive function is virtual, false otherwise.

func (*Receive) Parse

Parse populates the properties of the Receive node by parsing the corresponding context and information. It returns the populated Receive node.

func (*Receive) SetReferenceDescriptor

func (f *Receive) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the Receive node. This function is not yet implemented and returns false.

func (*Receive) ToProto

func (f *Receive) ToProto() NodeType

ToProto converts the Receive node to its corresponding protocol buffer representation.

func (*Receive) UnmarshalJSON added in v0.3.1

func (f *Receive) UnmarshalJSON(data []byte) error

type Resolver

type Resolver struct {
	*ASTBuilder

	// Nodes that could not be processed while parsing AST.
	// This will resolve issues with forward referencing...
	UnprocessedNodes map[int64]UnprocessedNode
	// contains filtered or unexported fields
}

Resolver is a structure that helps in resolving the nodes of an Abstract Syntax Tree (AST). It contains a reference to an ASTBuilder and a map of UnprocessedNodes.

func NewResolver

func NewResolver(builder *ASTBuilder) *Resolver

NewResolver creates a new Resolver with the provided ASTBuilder and initializes the UnprocessedNodes map.

func (*Resolver) GetUnprocessedCount

func (r *Resolver) GetUnprocessedCount() int

GetUnprocessedCount returns the number of UnprocessedNodes in the Resolver.

func (*Resolver) GetUnprocessedNodes

func (r *Resolver) GetUnprocessedNodes() map[int64]UnprocessedNode

GetUnprocessedNodes returns the map of UnprocessedNodes in the Resolver.

func (*Resolver) Resolve

func (r *Resolver) Resolve() []error

Resolve attempts to resolve all UnprocessedNodes in the Resolver and sets the entry source unit for the AST. It updates the node references in the AST and removes the nodes from the UnprocessedNodes map once they are resolved. If a node cannot be resolved, it is left in the UnprocessedNodes map for future resolution.

func (*Resolver) ResolveByNode

func (r *Resolver) ResolveByNode(node Node[NodeType], name string) (int64, *TypeDescription)

ResolveByNode attempts to resolve a node by its name and returns the resolved Node and its TypeDescription. If the node cannot be found, it is added to the UnprocessedNodes map for future resolution.

type ReturnStatement

type ReturnStatement struct {
	*ASTBuilder

	Id                       int64           `json:"id"`
	NodeType                 ast_pb.NodeType `json:"nodeType"`
	Src                      SrcNode         `json:"src"`
	FunctionReturnParameters int64           `json:"functionReturnParameters"`
	Expression               Node[NodeType]  `json:"expression"`
}

ReturnStatement represents a return statement in the AST.

func NewReturnStatement

func NewReturnStatement(b *ASTBuilder) *ReturnStatement

NewReturnStatement creates a new instance of ReturnStatement using the provided ASTBuilder.

func (*ReturnStatement) GetExpression

func (r *ReturnStatement) GetExpression() Node[NodeType]

GetExpression returns the expression associated with the ReturnStatement node.

func (*ReturnStatement) GetFunctionReturnParameters

func (r *ReturnStatement) GetFunctionReturnParameters() int64

GetFunctionReturnParameters returns the ID of the function's return parameters.

func (*ReturnStatement) GetId

func (r *ReturnStatement) GetId() int64

GetId returns the ID of the ReturnStatement node.

func (*ReturnStatement) GetNodes

func (r *ReturnStatement) GetNodes() []Node[NodeType]

GetNodes returns a list of child nodes contained in the ReturnStatement.

func (*ReturnStatement) GetSrc

func (r *ReturnStatement) GetSrc() SrcNode

GetSrc returns the source information of the ReturnStatement node.

func (*ReturnStatement) GetType

func (r *ReturnStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the ReturnStatement node.

func (*ReturnStatement) GetTypeDescription

func (r *ReturnStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the ReturnStatement's expression.

func (*ReturnStatement) Parse

func (r *ReturnStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.ReturnStatementContext,
) Node[NodeType]

Parse parses the ReturnStatement node from the provided context.

func (*ReturnStatement) SetReferenceDescriptor

func (r *ReturnStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the ReturnStatement node.

func (*ReturnStatement) ToProto

func (r *ReturnStatement) ToProto() NodeType

ToProto converts the ReturnStatement into its corresponding Protocol Buffers representation.

func (*ReturnStatement) UnmarshalJSON added in v0.3.1

func (r *ReturnStatement) UnmarshalJSON(data []byte) error

type RevertStatement

type RevertStatement struct {
	*ASTBuilder

	Id         int64            `json:"id"`         // Unique identifier for the RevertStatement node.
	NodeType   ast_pb.NodeType  `json:"nodeType"`   // Type of the AST node.
	Src        SrcNode          `json:"src"`        // Source location information.
	Arguments  []Node[NodeType] `json:"arguments"`  // List of argument expressions.
	Expression Node[NodeType]   `json:"expression"` // Expression within the revert statement.
}

RevertStatement represents a revert statement in the AST.

func NewRevertStatement

func NewRevertStatement(b *ASTBuilder) *RevertStatement

NewRevertStatement creates a new RevertStatement node with a given ASTBuilder.

func (*RevertStatement) GetArguments

func (r *RevertStatement) GetArguments() []Node[NodeType]

GetArguments returns the list of argument expressions.

func (*RevertStatement) GetExpression

func (r *RevertStatement) GetExpression() Node[NodeType]

GetExpression returns the expression within the revert statement.

func (*RevertStatement) GetId

func (r *RevertStatement) GetId() int64

GetId returns the ID of the RevertStatement node.

func (*RevertStatement) GetNodes

func (r *RevertStatement) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the RevertStatement node.

func (*RevertStatement) GetSrc

func (r *RevertStatement) GetSrc() SrcNode

GetSrc returns the SrcNode of the RevertStatement node.

func (*RevertStatement) GetType

func (r *RevertStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the RevertStatement node.

func (*RevertStatement) GetTypeDescription

func (r *RevertStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the TypeDescription of the RevertStatement node.

func (*RevertStatement) Parse

func (r *RevertStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.RevertStatementContext,
) Node[NodeType]

Parse parses a revert statement context into the RevertStatement node.

func (*RevertStatement) SetReferenceDescriptor

func (r *RevertStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the RevertStatement node.

func (*RevertStatement) ToProto

func (r *RevertStatement) ToProto() NodeType

ToProto returns a protobuf representation of the RevertStatement node.

func (*RevertStatement) UnmarshalJSON added in v0.3.1

func (r *RevertStatement) UnmarshalJSON(data []byte) error

MarshalJSON marshals the RevertStatement node into a JSON byte slice.

type RootNode

type RootNode struct {
	// Id is the unique identifier of the root node.
	Id int64 `json:"id"`

	// NodeType is the type of the AST node.
	NodeType ast_pb.NodeType `json:"nodeType"`

	// EntrySourceUnit is the entry source unit of the root node.
	EntrySourceUnit int64 `json:"entrySourceUnit"`

	// Globals is the list of global nodes.
	Globals []Node[NodeType] `json:"globals"`

	// SourceUnits is the list of source units.
	SourceUnits []*SourceUnit[Node[ast_pb.SourceUnit]] `json:"root"`

	// Comments is the list of comments.
	Comments []*Comment `json:"comments"`
}

RootNode is the root node of the AST.

func NewRootNode

func NewRootNode(builder *ASTBuilder, entrySourceUnit int64, sourceUnits []*SourceUnit[Node[ast_pb.SourceUnit]], comments []*Comment) *RootNode

NewRootNode creates a new RootNode with the provided ASTBuilder, entry source unit, source units, and comments.

func (*RootNode) GetComments

func (r *RootNode) GetComments() []*Comment

GetComments returns the comments of the root node.

func (*RootNode) GetEntrySourceUnit

func (r *RootNode) GetEntrySourceUnit() int64

GetEntrySourceUnit returns the entry source unit of the root node.

func (*RootNode) GetGlobalNodes added in v0.3.1

func (r *RootNode) GetGlobalNodes() []Node[NodeType]

GetGlobalNodes returns the global nodes of the root node.

func (*RootNode) GetId

func (r *RootNode) GetId() int64

GetId returns the id of the RootNode node.

func (*RootNode) GetNodes

func (r *RootNode) GetNodes() []Node[NodeType]

GetNodes returns the nodes of the root node.

func (*RootNode) GetSourceUnitById

func (r *RootNode) GetSourceUnitById(id int64) *SourceUnit[Node[ast_pb.SourceUnit]]

GetSourceUnitById returns the source unit with the provided id.

func (*RootNode) GetSourceUnitByName

func (r *RootNode) GetSourceUnitByName(name string) *SourceUnit[Node[ast_pb.SourceUnit]]

GetSourceUnitByName returns the source unit with the provided name.

func (*RootNode) GetSourceUnitCount

func (r *RootNode) GetSourceUnitCount() int32

GetSourceUnitCount returns the number of source units of the root node.

func (*RootNode) GetSourceUnits

func (r *RootNode) GetSourceUnits() []*SourceUnit[Node[ast_pb.SourceUnit]]

GetSourceUnits returns the source units of the root node.

func (*RootNode) GetSrc

func (r *RootNode) GetSrc() SrcNode

GetSrc returns the source code location of the RootNode node.

func (*RootNode) GetType

func (r *RootNode) GetType() ast_pb.NodeType

GetType returns the type of the RootNode node.

func (*RootNode) GetTypeDescription

func (r *RootNode) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the RootNode node. RootNode nodes do not have type descriptions.

func (*RootNode) HasSourceUnits

func (r *RootNode) HasSourceUnits() bool

HasSourceUnits returns true if the root node has source units.

func (*RootNode) SetEntrySourceUnit

func (r *RootNode) SetEntrySourceUnit(entrySourceUnit int64)

SetEntrySourceUnit sets the entry source unit of the root node.

func (*RootNode) SetReferenceDescriptor

func (r *RootNode) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the RootNode node.

func (*RootNode) ToProto

func (r *RootNode) ToProto() *ast_pb.RootSourceUnit

ToProto returns the protobuf representation of the root node.

func (*RootNode) UnmarshalJSON added in v0.3.1

func (r *RootNode) UnmarshalJSON(data []byte) error

type ShiftOperation added in v0.3.1

type ShiftOperation struct {
	*ASTBuilder

	Id               int64              `json:"id"`
	NodeType         ast_pb.NodeType    `json:"nodeType"`
	Src              SrcNode            `json:"src"`
	Operator         ast_pb.NodeType    `json:"operator"`
	Expressions      []Node[NodeType]   `json:"expressions"`
	TypeDescriptions []*TypeDescription `json:"typeDescriptions"`
	TypeDescription  *TypeDescription   `json:"typeDescription"`
}

ShiftOperation represents an 'bit and' operation in an abstract syntax tree.

func NewShiftOperationExpression added in v0.3.1

func NewShiftOperationExpression(b *ASTBuilder) *ShiftOperation

NewShiftOperationExpression creates a new ShiftOperation instance.

func (*ShiftOperation) GetExpressions added in v0.3.1

func (f *ShiftOperation) GetExpressions() []Node[NodeType]

GetExpressions returns the expressions within the ShiftOperation.

func (*ShiftOperation) GetId added in v0.3.1

func (f *ShiftOperation) GetId() int64

GetId returns the ID of the ShiftOperation.

func (*ShiftOperation) GetNodes added in v0.3.1

func (f *ShiftOperation) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the ShiftOperation.

func (*ShiftOperation) GetSrc added in v0.3.1

func (f *ShiftOperation) GetSrc() SrcNode

GetSrc returns the source information of the ShiftOperation.

func (*ShiftOperation) GetType added in v0.3.1

func (f *ShiftOperation) GetType() ast_pb.NodeType

GetType returns the NodeType of the ShiftOperation.

func (*ShiftOperation) GetTypeDescription added in v0.3.1

func (f *ShiftOperation) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the ShiftOperation.

func (*ShiftOperation) Parse added in v0.3.1

func (f *ShiftOperation) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.ShiftOperationContext,
) Node[NodeType]

Parse parses the ShiftOperation node from the parsing context and associates it with other nodes.

func (*ShiftOperation) SetReferenceDescriptor added in v0.3.1

func (f *ShiftOperation) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the ShiftOperation node. This function always returns false for now.

func (*ShiftOperation) ToProto added in v0.3.1

func (f *ShiftOperation) ToProto() NodeType

ToProto converts the ShiftOperation to its corresponding protocol buffer representation.

func (*ShiftOperation) UnmarshalJSON added in v0.3.1

func (f *ShiftOperation) UnmarshalJSON(data []byte) error

type SimpleStatement

type SimpleStatement struct {
	*ASTBuilder

	Id       int64           `json:"id"`
	NodeType ast_pb.NodeType `json:"nodeType"`
	Src      SrcNode         `json:"src"`
}

SimpleStatement represents a simple statement in the AST.

func NewSimpleStatement

func NewSimpleStatement(b *ASTBuilder) *SimpleStatement

NewSimpleStatement creates a new instance of SimpleStatement using the provided ASTBuilder. This instance is more like a placeholder for the actual statements that are returned from Parse()

func (*SimpleStatement) Parse

func (s *SimpleStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	parentNode Node[NodeType],
	parentNodeId int64,
	ctx *parser.SimpleStatementContext,
) Node[NodeType]

Parse parses the SimpleStatement node from the provided context.

type SourceUnit

type SourceUnit[T NodeType] struct {
	Id              int64            `json:"id"`              // Id is the unique identifier of the source unit.
	Contract        Node[NodeType]   `json:"-"`               // Contract is the contract associated with the source unit.
	BaseContracts   []*BaseContract  `json:"baseContracts"`   // BaseContracts are the base contracts of the source unit.
	License         string           `json:"license"`         // License is the license of the source unit.
	ExportedSymbols []Symbol         `json:"exportedSymbols"` // ExportedSymbols is the list of source units, including its names and node tree ids used by current source unit.
	AbsolutePath    string           `json:"absolutePath"`    // AbsolutePath is the absolute path of the source unit.
	Name            string           `json:"name"`            // Name is the name of the source unit. This is going to be one of the following: contract, interface or library name. It's here for convenience.
	NodeType        ast_pb.NodeType  `json:"nodeType"`        // NodeType is the type of the AST node.
	Kind            ast_pb.NodeType  `json:"kind"`            // Kind is the type of the AST node (contract, library, interface).
	Nodes           []Node[NodeType] `json:"nodes"`           // Nodes is the list of AST nodes.
	Src             SrcNode          `json:"src"`             // Src is the source code location.
}

SourceUnit represents a source unit in the abstract syntax tree. It includes various attributes like id, license, exported symbols, absolute path, name, node type, nodes, and source node.

func NewSourceUnit

func NewSourceUnit[T any](builder *ASTBuilder, name string, license string) *SourceUnit[T]

NewSourceUnit creates a new SourceUnit with the provided ASTBuilder, name, and license. It returns a pointer to the created SourceUnit.

func (*SourceUnit[T]) GetAbsolutePath

func (s *SourceUnit[T]) GetAbsolutePath() string

GetAbsolutePath returns the absolute path of the source unit.

func (*SourceUnit[T]) GetBaseContracts

func (s *SourceUnit[T]) GetBaseContracts() []*BaseContract

GetBaseContracts returns the base contracts of the source unit.

func (*SourceUnit[T]) GetContract

func (s *SourceUnit[T]) GetContract() Node[NodeType]

GetContract returns the contract associated with the source unit.

func (*SourceUnit[T]) GetExportedSymbols

func (s *SourceUnit[T]) GetExportedSymbols() []Symbol

GetExportedSymbols returns the exported symbols of the source unit.

func (*SourceUnit[T]) GetId

func (s *SourceUnit[T]) GetId() int64

GetId returns the unique identifier of the source unit.

func (*SourceUnit[T]) GetImports

func (s *SourceUnit[T]) GetImports() []*Import

func (*SourceUnit[T]) GetKind added in v0.3.5

func (s *SourceUnit[T]) GetKind() ast_pb.NodeType

GetKind returns the type of the source unit.

func (*SourceUnit[T]) GetLicense

func (s *SourceUnit[T]) GetLicense() string

GetLicense returns the license of the source unit.

func (*SourceUnit[T]) GetName

func (s *SourceUnit[T]) GetName() string

GetName returns the name of the source unit.

func (*SourceUnit[T]) GetNodes

func (s *SourceUnit[T]) GetNodes() []Node[NodeType]

GetNodes returns the nodes associated with the source unit.

func (*SourceUnit[T]) GetPragmas

func (s *SourceUnit[T]) GetPragmas() []*Pragma

func (*SourceUnit[T]) GetSrc

func (s *SourceUnit[T]) GetSrc() SrcNode

GetSrc returns the source code location of the source unit.

func (*SourceUnit[T]) GetType

func (s *SourceUnit[T]) GetType() ast_pb.NodeType

GetType returns the type of the source unit.

func (*SourceUnit[T]) GetTypeDescription

func (s *SourceUnit[T]) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the source unit.

func (*SourceUnit[T]) SetAbsolutePathFromSources

func (s *SourceUnit[T]) SetAbsolutePathFromSources(sources *solgo.Sources)

SetAbsolutePathFromSources sets the absolute path of the source unit from the provided sources.

func (*SourceUnit[T]) SetContract added in v0.3.2

func (s *SourceUnit[T]) SetContract(contract Node[NodeType])

SetContract sets the contract associated with the source unit.

func (*SourceUnit[T]) SetReferenceDescriptor

func (s *SourceUnit[T]) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the SourceUnit node.

func (*SourceUnit[T]) ToProto

func (s *SourceUnit[T]) ToProto() NodeType

ToProto converts the SourceUnit to a protocol buffer representation.

func (*SourceUnit[T]) UnmarshalJSON added in v0.3.1

func (s *SourceUnit[T]) UnmarshalJSON(data []byte) error

type SrcNode

type SrcNode struct {
	Line        int64 `json:"line"`                  // Line number of the source node in the source code.
	Column      int64 `json:"column"`                // Column number of the source node in the source code.
	Start       int64 `json:"start"`                 // Start position of the source node in the source code.
	End         int64 `json:"end"`                   // End position of the source node in the source code.
	Length      int64 `json:"length"`                // Length of the source node in the source code.
	ParentIndex int64 `json:"parentIndex,omitempty"` // Index of the parent node in the source code.
}

SrcNode represents a node in the source code.

func (SrcNode) GetColumn

func (s SrcNode) GetColumn() int64

GetColumn returns the column number of the source node in the source code.

func (SrcNode) GetEnd

func (s SrcNode) GetEnd() int64

GetEnd returns the end position of the source node in the source code.

func (SrcNode) GetLength

func (s SrcNode) GetLength() int64

GetLength returns the length of the source node in the source code.

func (SrcNode) GetLine

func (s SrcNode) GetLine() int64

GetLine returns the line number of the source node in the source code.

func (SrcNode) GetParentIndex

func (s SrcNode) GetParentIndex() int64

GetParentIndex returns the index of the parent node in the source code.

func (SrcNode) GetStart

func (s SrcNode) GetStart() int64

GetStart returns the start position of the source node in the source code.

func (SrcNode) ToProto

func (s SrcNode) ToProto() *ast_pb.Src

ToProto converts the SrcNode to a protocol buffer representation.

type StateVariableDeclaration

type StateVariableDeclaration struct {
	*ASTBuilder                            // Embedding the ASTBuilder for common functionality
	Id              int64                  `json:"id"`              // Unique identifier for the state variable declaration
	Name            string                 `json:"name"`            // Name of the state variable
	Constant        bool                   `json:"isConstant"`      // Indicates if the state variable is constant
	StateVariable   bool                   `json:"isStateVariable"` // Indicates if the declaration is a state variable
	NodeType        ast_pb.NodeType        `json:"nodeType"`        // Type of the node (VARIABLE_DECLARATION for state variable declaration)
	Src             SrcNode                `json:"src"`             // Source information about the state variable declaration
	Scope           int64                  `json:"scope"`           // Scope of the state variable declaration
	TypeDescription *TypeDescription       `json:"typeDescription"` // Type description of the state variable declaration
	Visibility      ast_pb.Visibility      `json:"visibility"`      // Visibility of the state variable declaration
	StorageLocation ast_pb.StorageLocation `json:"storageLocation"` // Storage location of the state variable declaration
	StateMutability ast_pb.Mutability      `json:"mutability"`      // State mutability of the state variable declaration
	TypeName        *TypeName              `json:"typeName"`        // Type name of the state variable
	InitialValue    Node[NodeType]         `json:"initialValue"`    // Initial value of the state variable
}

StateVariableDeclaration represents a state variable declaration in the Solidity abstract syntax tree (AST).

func NewStateVariableDeclaration

func NewStateVariableDeclaration(b *ASTBuilder) *StateVariableDeclaration

NewStateVariableDeclaration creates a new StateVariableDeclaration instance.

func (*StateVariableDeclaration) GetId

func (v *StateVariableDeclaration) GetId() int64

GetId returns the unique identifier of the state variable declaration.

func (*StateVariableDeclaration) GetInitialValue added in v0.3.1

func (v *StateVariableDeclaration) GetInitialValue() Node[NodeType]

GetInitialValue returns the initial value of the state variable declaration.

func (*StateVariableDeclaration) GetName

func (v *StateVariableDeclaration) GetName() string

GetName returns the name of the state variable.

func (*StateVariableDeclaration) GetNodes

func (v *StateVariableDeclaration) GetNodes() []Node[NodeType]

GetNodes returns the type name node in the state variable declaration.

func (*StateVariableDeclaration) GetReferencedDeclaration

func (v *StateVariableDeclaration) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the type name in the state variable declaration.

func (*StateVariableDeclaration) GetScope

func (v *StateVariableDeclaration) GetScope() int64

GetScope returns the scope of the state variable declaration.

func (*StateVariableDeclaration) GetSrc

func (v *StateVariableDeclaration) GetSrc() SrcNode

GetSrc returns the source information about the state variable declaration.

func (*StateVariableDeclaration) GetStateMutability

func (v *StateVariableDeclaration) GetStateMutability() ast_pb.Mutability

GetStateMutability returns the state mutability of the state variable declaration.

func (*StateVariableDeclaration) GetStorageLocation

func (v *StateVariableDeclaration) GetStorageLocation() ast_pb.StorageLocation

GetStorageLocation returns the storage location of the state variable declaration.

func (*StateVariableDeclaration) GetType

GetType returns the type of the node, which is 'VARIABLE_DECLARATION' for a state variable declaration.

func (*StateVariableDeclaration) GetTypeDescription

func (v *StateVariableDeclaration) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the state variable declaration.

func (*StateVariableDeclaration) GetTypeName

func (v *StateVariableDeclaration) GetTypeName() *TypeName

GetTypeName returns the type name of the state variable declaration.

func (*StateVariableDeclaration) GetVisibility

func (v *StateVariableDeclaration) GetVisibility() ast_pb.Visibility

GetVisibility returns the visibility of the state variable declaration.

func (*StateVariableDeclaration) IsConstant

func (v *StateVariableDeclaration) IsConstant() bool

IsConstant returns whether the state variable declaration is constant.

func (*StateVariableDeclaration) IsStateVariable

func (v *StateVariableDeclaration) IsStateVariable() bool

IsStateVariable returns whether the declaration is a state variable.

func (*StateVariableDeclaration) Parse

Parse parses a state variable declaration from the provided parser.StateVariableDeclarationContext and updates the current instance.

func (*StateVariableDeclaration) ParseGlobal added in v0.3.1

ParseGlobal parses a state variable declaration from the provided parser.StateVariableDeclarationContext and updates the current instance.

func (*StateVariableDeclaration) ParseGlobalConstant added in v0.3.1

func (v *StateVariableDeclaration) ParseGlobalConstant(
	ctx *parser.ConstantVariableDeclarationContext,
)

ParseGlobalConstant parses a global constant state variable declaration from the provided parser.ConstantVariableDeclarationContext and updates the current instance.

func (*StateVariableDeclaration) ParseGlobalVariable added in v0.3.1

func (v *StateVariableDeclaration) ParseGlobalVariable(
	ctx *parser.VariableDeclarationContext,
)

ParseGlobalVariable parses a global variable declaration from the provided parser.VariableDeclarationContext and updates the current instance.

func (*StateVariableDeclaration) SetReferenceDescriptor

func (v *StateVariableDeclaration) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the StateVariableDeclaration node.

func (*StateVariableDeclaration) ToProto

func (v *StateVariableDeclaration) ToProto() NodeType

ToProto returns the protobuf representation of the state variable declaration.

func (*StateVariableDeclaration) UnmarshalJSON added in v0.3.5

func (v *StateVariableDeclaration) UnmarshalJSON(data []byte) error

UnmarshalJSON customizes the JSON unmarshaling for StateVariableDeclaration.

type StructDefinition

type StructDefinition struct {
	*ASTBuilder                                  // Embedding the ASTBuilder for common functionality
	SourceUnitName        string                 `json:"-"`                               // Name of the source unit
	Id                    int64                  `json:"id"`                              // Unique identifier for the struct definition
	NodeType              ast_pb.NodeType        `json:"nodeType"`                        // Type of the node (STRUCT_DEFINITION for struct definition)
	Src                   SrcNode                `json:"src"`                             // Source information about the struct definition
	Name                  string                 `json:"name"`                            // Name of the struct
	NameLocation          SrcNode                `json:"nameLocation"`                    // Source information about the name of the struct
	CanonicalName         string                 `json:"canonicalName"`                   // Canonical name of the struct
	ReferencedDeclaration int64                  `json:"referencedDeclaration,omitempty"` // Referenced declaration of the struct definition
	TypeDescription       *TypeDescription       `json:"typeDescription"`                 // Type description of the struct definition
	Members               []Node[NodeType]       `json:"members"`                         // Members of the struct definition
	Visibility            ast_pb.Visibility      `json:"visibility"`                      // Visibility of the struct definition
	StorageLocation       ast_pb.StorageLocation `json:"storageLocation"`                 // Storage location of the struct definition
}

StructDefinition represents a struct definition in the Solidity abstract syntax tree (AST).

func NewStructDefinition

func NewStructDefinition(b *ASTBuilder) *StructDefinition

NewStructDefinition creates a new StructDefinition instance.

func (*StructDefinition) GetCanonicalName

func (s *StructDefinition) GetCanonicalName() string

GetCanonicalName returns the canonical name of the struct definition.

func (*StructDefinition) GetId

func (s *StructDefinition) GetId() int64

GetId returns the unique identifier of the struct definition.

func (*StructDefinition) GetMembers

func (s *StructDefinition) GetMembers() []*Parameter

GetMembers returns the members of the struct definition.

func (*StructDefinition) GetName

func (s *StructDefinition) GetName() string

GetName returns the name of the struct definition.

func (*StructDefinition) GetNameLocation

func (s *StructDefinition) GetNameLocation() SrcNode

GetNameLocation returns the source information about the name of the struct definition.

func (*StructDefinition) GetNodes

func (s *StructDefinition) GetNodes() []Node[NodeType]

GetNodes returns the members of the struct definition.

func (*StructDefinition) GetReferencedDeclaration

func (s *StructDefinition) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the struct definition.

func (*StructDefinition) GetSourceUnitName

func (s *StructDefinition) GetSourceUnitName() string

GetSourceUnitName returns the name of the source unit.

func (*StructDefinition) GetSrc

func (s *StructDefinition) GetSrc() SrcNode

GetSrc returns the source information about the struct definition.

func (*StructDefinition) GetStorageLocation

func (s *StructDefinition) GetStorageLocation() ast_pb.StorageLocation

GetStorageLocation returns the storage location of the struct definition.

func (*StructDefinition) GetType

func (s *StructDefinition) GetType() ast_pb.NodeType

GetType returns the type of the node, which is 'STRUCT_DEFINITION' for a struct definition.

func (*StructDefinition) GetTypeDescription

func (s *StructDefinition) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the struct definition.

func (*StructDefinition) GetVisibility

func (s *StructDefinition) GetVisibility() ast_pb.Visibility

GetVisibility returns the visibility of the struct definition.

func (*StructDefinition) Parse

Parse parses a struct definition from the provided parser.StructDefinitionContext and returns the corresponding StructDefinition.

func (*StructDefinition) ParseGlobal added in v0.3.1

func (s *StructDefinition) ParseGlobal(
	ctx *parser.StructDefinitionContext,
) Node[NodeType]

ParseGlobal parses a struct definition from the provided parser.StructDefinitionContext and returns the corresponding StructDefinition.

func (*StructDefinition) SetReferenceDescriptor

func (s *StructDefinition) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the StructDefinition node.

func (*StructDefinition) ToProto

func (s *StructDefinition) ToProto() NodeType

ToProto returns the protobuf representation of the struct definition.

func (*StructDefinition) UnmarshalJSON added in v0.3.1

func (s *StructDefinition) UnmarshalJSON(data []byte) error

type Symbol

type Symbol struct {
	Id           int64  `json:"id"`            // Unique identifier for the symbol
	Name         string `json:"name"`          // Name of the symbol
	AbsolutePath string `json:"absolute_path"` // Absolute path to the symbol
}

Symbol represents a symbol in the Solidity abstract syntax tree (AST).

func NewSymbol

func NewSymbol(id int64, name string, absolutePath string) Symbol

NewSymbol creates a new Symbol instance with the provided attributes.

func (Symbol) GetAbsolutePath

func (s Symbol) GetAbsolutePath() string

GetAbsolutePath returns the absolute path to the symbol.

func (Symbol) GetId

func (s Symbol) GetId() int64

GetId returns the unique identifier of the symbol.

func (Symbol) GetName

func (s Symbol) GetName() string

GetName returns the name of the symbol.

type Tree

type Tree struct {
	*ASTBuilder
	// contains filtered or unexported fields
}

Tree is a structure that represents an Abstract Syntax Tree (AST). It contains a reference to an ASTBuilder and the root node of the AST.

func NewTree

func NewTree(b *ASTBuilder) *Tree

NewTree creates a new Tree with the provided ASTBuilder.

func (*Tree) AppendGlobalNodes added in v0.3.1

func (t *Tree) AppendGlobalNodes(nodes ...Node[NodeType])

func (*Tree) AppendRootNodes

func (t *Tree) AppendRootNodes(roots ...*SourceUnit[Node[ast_pb.SourceUnit]])

AppendRootNodes appends the provided SourceUnit nodes to the root node of the AST.

func (*Tree) ExecuteCustomTypeVisit added in v0.3.2

func (t *Tree) ExecuteCustomTypeVisit(nodes []Node[NodeType], nodeType ast_pb.NodeType, visitFunc func(node Node[NodeType]) (bool, error)) (bool, error)

ExecuteCustomTypeVisit executes a visitation function on all nodes of a specific type in a provided slice of nodes.

func (*Tree) ExecuteTypeVisit added in v0.3.2

func (t *Tree) ExecuteTypeVisit(nodeType ast_pb.NodeType, visitFunc func(node Node[NodeType]) (bool, error)) (bool, error)

ExecuteTypeVisit executes a visitation function on all nodes of a specific type in the AST, starting from the root.

func (*Tree) GetById

func (t *Tree) GetById(id int64) Node[NodeType]

GetById attempts to find a node in the AST by its ID. It performs a recursive search through all nodes in the AST. Returns the found Node or nil if the node cannot be found.

func (*Tree) GetRoot

func (t *Tree) GetRoot() *RootNode

GetRoot returns the root node of the Abstract Syntax Tree (AST).

func (*Tree) SetRoot

func (t *Tree) SetRoot(root *RootNode)

SetRoot sets the root node of the Abstract Syntax Tree (AST).

func (*Tree) UpdateNodeReferenceById

func (t *Tree) UpdateNodeReferenceById(nodeId int64, nodeRefId int64, typeRef *TypeDescription) bool

UpdateNodeReferenceById attempts to update the reference descriptor of a node in the AST by its ID. It performs a recursive search through all nodes in the AST. Returns true if the node was found and updated, false otherwise.

func (*Tree) Walk added in v0.3.2

func (t *Tree) Walk(visitor *NodeVisitor) error

Walk initiates the traversal of the AST from its root, using the provided NodeVisitor. It processes the AST nodes based on the visitation functions defined in the visitor.

func (*Tree) WalkNode added in v0.3.2

func (t *Tree) WalkNode(startNode Node[NodeType], visitor *NodeVisitor) error

WalkNode applies the NodeVisitor to a single node and its descendants in the AST.

func (*Tree) WalkNodes added in v0.3.2

func (t *Tree) WalkNodes(startNodes []Node[NodeType], visitor *NodeVisitor) error

WalkNodes applies the NodeVisitor to a slice of nodes and their descendants in the AST.

type TryStatement

type TryStatement struct {
	*ASTBuilder

	Id               int64            `json:"id"`               // Unique identifier for the TryStatement node.
	NodeType         ast_pb.NodeType  `json:"nodeType"`         // Type of the AST node.
	Src              SrcNode          `json:"src"`              // Source location information.
	Body             *BodyNode        `json:"body"`             // Body of the try block.
	Kind             ast_pb.NodeType  `json:"kind"`             // Kind of try statement.
	Returns          bool             `json:"returns"`          // True if the try statement returns.
	ReturnParameters *ParameterList   `json:"returnParameters"` // Return parameters of the try statement.
	Expression       Node[NodeType]   `json:"expression"`       // Expression within the try block.
	Clauses          []Node[NodeType] `json:"clauses"`          // List of catch clauses.
	Implemented      bool             `json:"implemented"`      // True if the try statement is implemented.
}

TryStatement represents a try-catch statement in the AST.

func NewTryStatement

func NewTryStatement(b *ASTBuilder) *TryStatement

NewTryStatement creates a new TryStatement node with a given ASTBuilder.

func (*TryStatement) GetBody

func (t *TryStatement) GetBody() *BodyNode

GetBody returns the body of the TryStatement node.

func (*TryStatement) GetClauses

func (t *TryStatement) GetClauses() []Node[NodeType]

GetClauses returns the list of catch clauses.

func (*TryStatement) GetExpression

func (t *TryStatement) GetExpression() Node[NodeType]

GetExpression returns the expression within the try block.

func (*TryStatement) GetId

func (t *TryStatement) GetId() int64

GetId returns the ID of the TryStatement node.

func (*TryStatement) GetKind

func (t *TryStatement) GetKind() ast_pb.NodeType

GetKind returns the kind of the try statement.

func (*TryStatement) GetNodes

func (t *TryStatement) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the TryStatement node.

func (*TryStatement) GetReturnParameters added in v0.3.1

func (t *TryStatement) GetReturnParameters() *ParameterList

GetReturnParameters returns the return parameters of the try statement.

func (*TryStatement) GetReturns added in v0.3.1

func (t *TryStatement) GetReturns() bool

GetReturns returns true if the try statement returns.

func (*TryStatement) GetSrc

func (t *TryStatement) GetSrc() SrcNode

GetSrc returns the SrcNode of the TryStatement node.

func (*TryStatement) GetType

func (t *TryStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the TryStatement node.

func (*TryStatement) GetTypeDescription

func (t *TryStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the TypeDescription of the TryStatement node.

func (*TryStatement) IsImplemented added in v0.3.1

func (t *TryStatement) IsImplemented() bool

GetImplemented returns true if the try statement is implemented.

func (*TryStatement) Parse

func (t *TryStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.TryStatementContext,
) Node[NodeType]

Parse parses a try-catch statement context into the TryStatement node.

func (*TryStatement) SetReferenceDescriptor

func (t *TryStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the TryStatement node.

func (*TryStatement) ToProto

func (t *TryStatement) ToProto() NodeType

ToProto returns a protobuf representation of the TryStatement node.

func (*TryStatement) UnmarshalJSON added in v0.3.1

func (t *TryStatement) UnmarshalJSON(data []byte) error

MarshalJSON marshals the TryStatement node into a JSON byte slice.

type TupleExpression

type TupleExpression struct {
	*ASTBuilder                            // Embedding the ASTBuilder to provide common functionality
	Id                    int64            `json:"id"`                              // Unique identifier for the tuple expression
	NodeType              ast_pb.NodeType  `json:"nodeType"`                        // Type of the node (TUPLE_EXPRESSION for a tuple expression)
	Src                   SrcNode          `json:"src"`                             // Source information about the tuple expression
	Constant              bool             `json:"isConstant"`                      // Whether the tuple expression is constant
	Pure                  bool             `json:"isPure"`                          // Whether the tuple expression is pure
	Components            []Node[NodeType] `json:"components"`                      // Components of the tuple expression
	ReferencedDeclaration int64            `json:"referencedDeclaration,omitempty"` // Referenced declaration of the tuple expression
	TypeDescription       *TypeDescription `json:"typeDescription"`                 // Type description of the tuple expression
}

TupleExpression represents a tuple expression in Solidity.

func NewTupleExpression

func NewTupleExpression(b *ASTBuilder) *TupleExpression

NewTupleExpression creates a new TupleExpression instance.

func (*TupleExpression) GetComponents

func (t *TupleExpression) GetComponents() []Node[NodeType]

GetComponents returns the components of the tuple expression.

func (*TupleExpression) GetId

func (t *TupleExpression) GetId() int64

GetId returns the unique identifier of the tuple expression.

func (*TupleExpression) GetNodes

func (t *TupleExpression) GetNodes() []Node[NodeType]

GetNodes returns the components of the tuple expression.

func (*TupleExpression) GetReferencedDeclaration

func (t *TupleExpression) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the tuple expression.

func (*TupleExpression) GetSrc

func (t *TupleExpression) GetSrc() SrcNode

GetSrc returns the source information about the tuple expression.

func (*TupleExpression) GetType

func (t *TupleExpression) GetType() ast_pb.NodeType

GetType returns the type of the node, which is 'TUPLE_EXPRESSION' for a tuple expression.

func (*TupleExpression) GetTypeDescription

func (t *TupleExpression) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the tuple expression.

func (*TupleExpression) IsConstant

func (t *TupleExpression) IsConstant() bool

IsConstant returns whether the tuple expression is constant.

func (*TupleExpression) IsPure

func (t *TupleExpression) IsPure() bool

IsPure returns whether the tuple expression is pure.

func (*TupleExpression) Parse

func (t *TupleExpression) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	exprNode Node[NodeType],
	ctx *parser.TupleContext,
) Node[NodeType]

Parse parses a tuple expression from the provided parser.TupleContext and returns the corresponding TupleExpression.

func (*TupleExpression) SetReferenceDescriptor

func (t *TupleExpression) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the TupleExpression node.

func (*TupleExpression) ToProto

func (t *TupleExpression) ToProto() NodeType

ToProto returns the protobuf representation of the tuple expression.

func (*TupleExpression) UnmarshalJSON added in v0.3.1

func (t *TupleExpression) UnmarshalJSON(data []byte) error

MarshalJSON marshals the TupleExpression node into a JSON byte slice.

type TypeDescription

type TypeDescription struct {
	TypeIdentifier string `json:"typeIdentifier"`
	TypeString     string `json:"typeString"`
}

TypeDescription represents a description of a type.

func (*TypeDescription) GetIdentifier

func (td *TypeDescription) GetIdentifier() string

GetIdentifier returns the type identifier of the TypeDescription.

func (*TypeDescription) GetString

func (td *TypeDescription) GetString() string

GetString returns the type string of the TypeDescription.

func (TypeDescription) ToProto

func (td TypeDescription) ToProto() *ast_pb.TypeDescription

ToProto converts the TypeDescription instance to its corresponding protocol buffer representation.

type TypeName

type TypeName struct {
	*ASTBuilder

	Id                    int64             `json:"id"`
	NodeType              ast_pb.NodeType   `json:"nodeType"`
	Src                   SrcNode           `json:"src"`
	Name                  string            `json:"name,omitempty"`
	KeyType               *TypeName         `json:"keyType,omitempty"`
	KeyNameLocation       *SrcNode          `json:"keyNameLocation,omitempty"`
	ValueType             *TypeName         `json:"valueType,omitempty"`
	ValueNameLocation     *SrcNode          `json:"valueNameLocation,omitempty"`
	PathNode              *PathNode         `json:"pathNode,omitempty"`
	StateMutability       ast_pb.Mutability `json:"stateMutability,omitempty"`
	ReferencedDeclaration int64             `json:"referencedDeclaration"`
	Expression            Node[NodeType]    `json:"expression,omitempty"`
	TypeDescription       *TypeDescription  `json:"typeDescription,omitempty"`

	// Helper parents so we can efficiently extract references if needed without
	// having to traverse whole AST.
	ParentNode          []Node[NodeType]            `json:"-"`
	ParentBody          *BodyNode                   `json:"-"`
	ParentParameterList Node[*ast_pb.ParameterList] `json:"-"`
}

TypeName represents a type name used in Solidity code.

func NewTypeName

func NewTypeName(b *ASTBuilder) *TypeName

NewTypeName creates a new TypeName instance with the given ASTBuilder.

func (*TypeName) GetExpression added in v0.3.1

func (t *TypeName) GetExpression() Node[NodeType]

GetExpression returns the expression associated with the TypeName.

func (*TypeName) GetId

func (t *TypeName) GetId() int64

GetId returns the unique identifier of the TypeName.

func (*TypeName) GetKeyNameLocation

func (t *TypeName) GetKeyNameLocation() *SrcNode

GetKeyNameLocation returns the key name location of the KeyTypeName.

func (*TypeName) GetKeyType

func (t *TypeName) GetKeyType() *TypeName

GetKeyType returns the key type for mapping types.

func (*TypeName) GetName

func (t *TypeName) GetName() string

GetName returns the name of the type.

func (*TypeName) GetNodes

func (t *TypeName) GetNodes() []Node[NodeType]

GetNodes returns a list of child nodes for traversal within the TypeName.

func (*TypeName) GetPathNode

func (t *TypeName) GetPathNode() *PathNode

GetPathNode returns the path node associated with the TypeName.

func (*TypeName) GetReferencedDeclaration

func (t *TypeName) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the TypeName.

func (*TypeName) GetSrc

func (t *TypeName) GetSrc() SrcNode

GetSrc returns the source location information of the TypeName.

func (*TypeName) GetStateMutability

func (t *TypeName) GetStateMutability() ast_pb.Mutability

GetStateMutability returns the state mutability of the TypeName.

func (*TypeName) GetType

func (t *TypeName) GetType() ast_pb.NodeType

GetType returns the node type of the TypeName.

func (*TypeName) GetTypeDescription

func (t *TypeName) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the TypeName.

func (*TypeName) GetValueNameLocation

func (t *TypeName) GetValueNameLocation() *SrcNode

GetValueNameLocation returns the value name location of the ValueTypeName.

func (*TypeName) GetValueType

func (t *TypeName) GetValueType() *TypeName

GetValueType returns the value type for mapping types.

func (*TypeName) Parse

func (t *TypeName) Parse(unit *SourceUnit[Node[ast_pb.SourceUnit]], fnNode Node[NodeType], parentNodeId int64, ctx parser.ITypeNameContext)

Parse parses the TypeName from the given TypeNameContext.

func (*TypeName) ParseElementaryType

func (t *TypeName) ParseElementaryType(unit *SourceUnit[Node[ast_pb.SourceUnit]], fnNode Node[NodeType], parentNodeId int64, ctx parser.IElementaryTypeNameContext)

ParseElementaryType parses the ElementaryTypeName from the given ElementaryTypeNameContext.

func (*TypeName) ParseMul added in v0.3.1

func (t *TypeName) ParseMul(unit *SourceUnit[Node[ast_pb.SourceUnit]], fnNode Node[NodeType], parentNodeId int64, ctx antlr.TerminalNode)

ParseMul parses the TypeName from the given TermalNode.

func (*TypeName) SetReferenceDescriptor

func (t *TypeName) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the TypeName node.

func (*TypeName) StorageSize added in v0.3.2

func (t *TypeName) StorageSize() (int64, bool)

StorageSize calculates and returns the storage size requirement of the type represented by the TypeName instance, in bits. It also returns a boolean indicating whether the size calculation is exact or an approximation. The function covers elementary types, mappings, function types, user-defined types, and identifiers, with special handling for each category.

func (*TypeName) ToProto

func (t *TypeName) ToProto() NodeType

ToProto converts the TypeName instance to its corresponding protocol buffer representation.

func (*TypeName) UnmarshalJSON added in v0.3.1

func (t *TypeName) UnmarshalJSON(data []byte) error

func (*TypeName) WithBodyNode added in v0.3.1

func (t *TypeName) WithBodyNode(b *BodyNode)

WithBodyNode sets the body node associated with TypeName.

func (*TypeName) WithParameterList added in v0.3.1

func (t *TypeName) WithParameterList(p Node[*ast_pb.ParameterList])

WithParameterList sets the parameter list associated with TypeName.

func (*TypeName) WithParentNode added in v0.3.1

func (t *TypeName) WithParentNode(p Node[NodeType])

WithParentNode sets the parent node associated with TypeName.

type UnaryPrefix

type UnaryPrefix struct {
	*ASTBuilder

	Id                    int64            `json:"id"`
	NodeType              ast_pb.NodeType  `json:"nodeType"`
	Kind                  ast_pb.NodeType  `json:"kind"`
	Src                   SrcNode          `json:"src"`
	Operator              ast_pb.Operator  `json:"operator"`
	Prefix                bool             `json:"prefix"`
	Constant              bool             `json:"isConstant"`
	LValue                bool             `json:"isLValue"`
	Pure                  bool             `json:"isPure"`
	LValueRequested       bool             `json:"lValueRequested"`
	ReferencedDeclaration int64            `json:"referencedDeclaration,omitempty"`
	Expression            Node[NodeType]   `json:"expression"`
	TypeDescription       *TypeDescription `json:"typeDescription"`
}

UnaryPrefix represents a unary operation applied as a prefix to an expression.

func NewUnaryPrefixExpression

func NewUnaryPrefixExpression(b *ASTBuilder) *UnaryPrefix

NewUnaryPrefixExpression creates a new UnaryPrefix instance with the given ASTBuilder.

func (*UnaryPrefix) GetExpression

func (u *UnaryPrefix) GetExpression() Node[NodeType]

GetExpression returns the expression to which the unary operation is applied.

func (*UnaryPrefix) GetId

func (u *UnaryPrefix) GetId() int64

GetId returns the unique identifier of the UnaryPrefix.

func (*UnaryPrefix) GetKind added in v0.3.1

func (u *UnaryPrefix) GetKind() ast_pb.NodeType

GetKind returns the node type of the UnaryPrefix.

func (*UnaryPrefix) GetNodes

func (u *UnaryPrefix) GetNodes() []Node[NodeType]

GetNodes returns a list of child nodes for traversal within the UnaryPrefix.

func (*UnaryPrefix) GetOperator

func (u *UnaryPrefix) GetOperator() ast_pb.Operator

GetOperator returns the unary operator applied to the expression.

func (*UnaryPrefix) GetPrefix

func (u *UnaryPrefix) GetPrefix() bool

GetPrefix returns true if the unary operation is a prefix operation.

func (*UnaryPrefix) GetReferencedDeclaration

func (u *UnaryPrefix) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the UnaryPrefix.

func (*UnaryPrefix) GetSrc

func (u *UnaryPrefix) GetSrc() SrcNode

GetSrc returns the source location information of the UnaryPrefix.

func (*UnaryPrefix) GetType

func (u *UnaryPrefix) GetType() ast_pb.NodeType

GetType returns the node type of the UnaryPrefix.

func (*UnaryPrefix) GetTypeDescription

func (u *UnaryPrefix) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the UnaryPrefix.

func (*UnaryPrefix) IsConstant

func (u *UnaryPrefix) IsConstant() bool

IsConstant returns true if the operation's result is a constant.

func (*UnaryPrefix) IsLValue

func (u *UnaryPrefix) IsLValue() bool

IsLValue returns true if the expression is an l-value.

func (*UnaryPrefix) IsLValueRequested

func (u *UnaryPrefix) IsLValueRequested() bool

IsLValueRequested returns true if an l-value is requested from the operation.

func (*UnaryPrefix) IsPure

func (u *UnaryPrefix) IsPure() bool

IsPure returns true if the operation is pure, i.e., it doesn't modify state.

func (*UnaryPrefix) Parse

func (u *UnaryPrefix) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	ctx *parser.UnaryPrefixOperationContext,
) Node[NodeType]

Parse populates the UnaryPrefix instance with information parsed from the provided contexts.

func (*UnaryPrefix) SetReferenceDescriptor

func (u *UnaryPrefix) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the UnaryPrefix node.

func (*UnaryPrefix) ToProto

func (u *UnaryPrefix) ToProto() NodeType

ToProto converts the UnaryPrefix instance to its corresponding protocol buffer representation.

func (*UnaryPrefix) UnmarshalJSON added in v0.3.1

func (u *UnaryPrefix) UnmarshalJSON(data []byte) error

type UnarySuffix

type UnarySuffix struct {
	*ASTBuilder

	Id                    int64            `json:"id"`
	NodeType              ast_pb.NodeType  `json:"nodeType"`
	Kind                  ast_pb.NodeType  `json:"kind"`
	Src                   SrcNode          `json:"src"`
	Operator              ast_pb.Operator  `json:"operator"`
	Expression            Node[NodeType]   `json:"expression"`
	ReferencedDeclaration int64            `json:"referencedDeclaration,omitempty"`
	TypeDescription       *TypeDescription `json:"typeDescription"`
	Prefix                bool             `json:"prefix"`
	Constant              bool             `json:"isConstant"`
	LValue                bool             `json:"isLValue"`
	Pure                  bool             `json:"isPure"`
	LValueRequested       bool             `json:"lValueRequested"`
}

UnarySuffix represents a unary operation applied as a suffix to an expression.

func NewUnarySuffixExpression

func NewUnarySuffixExpression(b *ASTBuilder) *UnarySuffix

NewUnarySuffixExpression creates a new UnarySuffix instance with the given ASTBuilder.

func (*UnarySuffix) GetExpression

func (u *UnarySuffix) GetExpression() Node[NodeType]

GetExpression returns the expression to which the unary operation is applied.

func (*UnarySuffix) GetId

func (u *UnarySuffix) GetId() int64

GetId returns the unique identifier of the UnarySuffix.

func (*UnarySuffix) GetKind added in v0.3.1

func (u *UnarySuffix) GetKind() ast_pb.NodeType

GetKind returns the kind of the UnarySuffix.

func (*UnarySuffix) GetNodes

func (u *UnarySuffix) GetNodes() []Node[NodeType]

GetNodes returns a list of child nodes for traversal within the UnarySuffix.

func (*UnarySuffix) GetOperator

func (u *UnarySuffix) GetOperator() ast_pb.Operator

GetOperator returns the unary operator applied to the expression.

func (*UnarySuffix) GetPrefix

func (u *UnarySuffix) GetPrefix() bool

GetPrefix returns true if the unary operation is a prefix operation.

func (*UnarySuffix) GetReferencedDeclaration

func (u *UnarySuffix) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the UnarySuffix.

func (*UnarySuffix) GetSrc

func (u *UnarySuffix) GetSrc() SrcNode

GetSrc returns the source location information of the UnarySuffix.

func (*UnarySuffix) GetType

func (u *UnarySuffix) GetType() ast_pb.NodeType

GetType returns the node type of the UnarySuffix.

func (*UnarySuffix) GetTypeDescription

func (u *UnarySuffix) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the UnarySuffix.

func (*UnarySuffix) IsConstant

func (u *UnarySuffix) IsConstant() bool

IsConstant returns true if the operation's result is a constant.

func (*UnarySuffix) IsLValue

func (u *UnarySuffix) IsLValue() bool

IsLValue returns true if the expression is an l-value.

func (*UnarySuffix) IsLValueRequested

func (u *UnarySuffix) IsLValueRequested() bool

IsLValueRequested returns true if an l-value is requested from the operation.

func (*UnarySuffix) IsPure

func (u *UnarySuffix) IsPure() bool

IsPure returns true if the operation is pure, i.e., it doesn't modify state.

func (*UnarySuffix) Parse

func (u *UnarySuffix) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	vDeclar *VariableDeclaration,
	expNode Node[NodeType],
	ctx *parser.UnarySuffixOperationContext,
) Node[NodeType]

Parse populates the UnarySuffix instance with information parsed from the provided contexts.

func (*UnarySuffix) SetReferenceDescriptor

func (u *UnarySuffix) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the UnarySuffix node.

func (*UnarySuffix) ToProto

func (u *UnarySuffix) ToProto() NodeType

ToProto converts the UnarySuffix instance to its corresponding protocol buffer representation.

func (*UnarySuffix) UnmarshalJSON added in v0.3.1

func (u *UnarySuffix) UnmarshalJSON(data []byte) error

type UnprocessedNode

type UnprocessedNode struct {
	Id           int64          `json:"id"`
	Name         string         `json:"name"`
	Node         Node[NodeType] `json:"ref"`
	ErrFindRef   bool           `json:"error_find_ref"`
	ErrUpdateRef bool           `json:"error_update_ref"`
}

UnprocessedNode is a structure that represents a node that could not be processed during the parsing of the AST.

type UserDefinedValueTypeDefinition added in v0.3.1

type UserDefinedValueTypeDefinition struct {
	*ASTBuilder // Embedding ASTBuilder for building the AST.

	Id                    int64            `json:"id"`                              // Unique identifier for this node.
	NodeType              ast_pb.NodeType  `json:"nodeType"`                        // Type of the node, representing a user-defined value type.
	Src                   SrcNode          `json:"src"`                             // Source information about the node.
	Is                    bool             `json:"is"`                              // Additional flag (needs more contextual detail).
	Type                  string           `json:"type"`                            // Type name for the user-defined value type.
	TypeLocation          SrcNode          `json:"typeLocation"`                    // Source location for the type.
	Name                  string           `json:"name"`                            // Name of the user-defined value type.
	NameLocation          SrcNode          `json:"nameLocation"`                    // Source location for the name.
	TypeName              *TypeName        `json:"typeName"`                        // AST node representing the type's name.
	ReferencedDeclaration int64            `json:"referencedDeclaration,omitempty"` // Referenced declaration (if any).
	TypeDescription       *TypeDescription `json:"typeDescription"`                 // Description of the type.
}

UserDefinedValueTypeDefinition represents a user-defined value type in Solidity.

func NewUserDefinedValueTypeDefinition added in v0.3.1

func NewUserDefinedValueTypeDefinition(b *ASTBuilder) *UserDefinedValueTypeDefinition

NewUserDefinedValueTypeDefinition creates a new UserDefinedValueTypeDefinition instance.

func (*UserDefinedValueTypeDefinition) GetId added in v0.3.1

GetId returns the unique identifier of the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) GetIs added in v0.3.1

GetIs returns the additional flag of the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) GetName added in v0.3.1

GetName returns the name of the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) GetNameLocation added in v0.3.1

func (b *UserDefinedValueTypeDefinition) GetNameLocation() SrcNode

GetNameLocation returns the source location of the name of the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) GetNodes added in v0.3.1

func (b *UserDefinedValueTypeDefinition) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) GetReferencedDeclaration added in v0.3.1

func (b *UserDefinedValueTypeDefinition) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the type name in the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) GetSrc added in v0.3.1

GetSrc returns the source information about the node, such as its line and column numbers in the source file.

func (*UserDefinedValueTypeDefinition) GetType added in v0.3.1

GetType returns the type of the node, which is 'USER_DEFINED_VALUE_TYPE' for a UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) GetTypeDescription added in v0.3.1

func (b *UserDefinedValueTypeDefinition) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) GetTypeLocation added in v0.3.1

func (b *UserDefinedValueTypeDefinition) GetTypeLocation() SrcNode

GetTypeLocation returns the source location of the type name of the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) GetTypeName added in v0.3.1

func (b *UserDefinedValueTypeDefinition) GetTypeName() *TypeName

GetTypeName returns the type name of the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) GetUserType added in v0.3.1

func (b *UserDefinedValueTypeDefinition) GetUserType() string

GetUserType returns the type name of the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) Parse added in v0.3.1

Parse populates the UserDefinedValueTypeDefinition fields using the provided parser context.

func (*UserDefinedValueTypeDefinition) ParseGlobal added in v0.3.1

ParseGlobal populates the UserDefinedValueTypeDefinition fields using the provided parser context.

func (*UserDefinedValueTypeDefinition) SetReferenceDescriptor added in v0.3.1

func (b *UserDefinedValueTypeDefinition) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the UserDefinedValueTypeDefinition node.

func (*UserDefinedValueTypeDefinition) ToProto added in v0.3.1

ToProto returns the protobuf representation of the UserDefinedValueTypeDefinition node.

type UsingDirective

type UsingDirective struct {
	*ASTBuilder

	Id              int64            `json:"id"`
	NodeType        ast_pb.NodeType  `json:"nodeType"`
	Src             SrcNode          `json:"src"`
	TypeDescription *TypeDescription `json:"typeDescription"`
	TypeName        *TypeName        `json:"typeName"`
	LibraryName     *LibraryName     `json:"libraryName"`
}

UsingDirective represents a Solidity using directive, which is used to import and use symbols from external libraries.

func NewUsingDirective

func NewUsingDirective(b *ASTBuilder) *UsingDirective

NewUsingDirective creates a new UsingDirective instance with the given ASTBuilder.

func (*UsingDirective) GetId

func (u *UsingDirective) GetId() int64

GetId returns the unique identifier of the UsingDirective.

func (*UsingDirective) GetLibraryName

func (u *UsingDirective) GetLibraryName() *LibraryName

GetLibraryName returns the library name associated with the UsingDirective.

func (*UsingDirective) GetNodes

func (u *UsingDirective) GetNodes() []Node[NodeType]

GetNodes returns a list of child nodes for traversal within the UsingDirective.

func (*UsingDirective) GetPathNode

func (u *UsingDirective) GetPathNode() *PathNode

GetPathNode returns the path node associated with the UsingDirective.

func (*UsingDirective) GetReferencedDeclaration

func (u *UsingDirective) GetReferencedDeclaration() int64

GetReferencedDeclaration returns the referenced declaration of the UsingDirective.

func (*UsingDirective) GetSrc

func (u *UsingDirective) GetSrc() SrcNode

GetSrc returns the source location information of the UsingDirective.

func (*UsingDirective) GetType

func (u *UsingDirective) GetType() ast_pb.NodeType

GetType returns the node type of the UsingDirective.

func (*UsingDirective) GetTypeDescription

func (u *UsingDirective) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the UsingDirective.

func (*UsingDirective) GetTypeName

func (u *UsingDirective) GetTypeName() *TypeName

GetTypeName returns the type name associated with the UsingDirective.

func (*UsingDirective) Parse

Parse populates the UsingDirective instance with information parsed from the provided contexts.

func (*UsingDirective) SetReferenceDescriptor

func (u *UsingDirective) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the UsingDirective node.

func (*UsingDirective) ToProto

func (u *UsingDirective) ToProto() NodeType

ToProto converts the UsingDirective instance to its corresponding protocol buffer representation.

type VariableDeclaration

type VariableDeclaration struct {
	*ASTBuilder

	Id           int64           `json:"id"`                     // Unique identifier of the variable declaration node.
	NodeType     ast_pb.NodeType `json:"nodeType"`               // Type of the node.
	Src          SrcNode         `json:"src"`                    // Source location information.
	Assignments  []int64         `json:"assignments"`            // List of assignment identifiers.
	Declarations []*Declaration  `json:"declarations"`           // List of declaration nodes.
	InitialValue Node[NodeType]  `json:"initialValue,omitempty"` // Initial value node.
}

VariableDeclaration represents a variable declaration node in the abstract syntax tree.

func NewVariableDeclarationStatement

func NewVariableDeclarationStatement(b *ASTBuilder) *VariableDeclaration

NewVariableDeclarationStatement creates a new instance of VariableDeclaration with the provided ASTBuilder.

func (*VariableDeclaration) GetAssignments

func (v *VariableDeclaration) GetAssignments() []int64

GetAssignments returns a list of assignment identifiers associated with the variable declaration.

func (*VariableDeclaration) GetDeclarations

func (v *VariableDeclaration) GetDeclarations() []*Declaration

GetDeclarations returns a list of declaration nodes associated with the variable declaration.

func (*VariableDeclaration) GetId

func (v *VariableDeclaration) GetId() int64

GetId returns the unique identifier of the variable declaration node.

func (*VariableDeclaration) GetInitialValue

func (v *VariableDeclaration) GetInitialValue() Node[NodeType]

GetInitialValue returns the initial value node associated with the variable declaration.

func (*VariableDeclaration) GetNodes

func (v *VariableDeclaration) GetNodes() []Node[NodeType]

GetNodes returns a list of nodes associated with the variable declaration (initial value and declarations).

func (*VariableDeclaration) GetSrc

func (v *VariableDeclaration) GetSrc() SrcNode

GetSrc returns the source location information of the variable declaration node.

func (*VariableDeclaration) GetType

func (v *VariableDeclaration) GetType() ast_pb.NodeType

GetType returns the type of the node.

func (*VariableDeclaration) GetTypeDescription

func (v *VariableDeclaration) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description associated with the variable declaration.

func (*VariableDeclaration) Parse

func (v *VariableDeclaration) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.VariableDeclarationStatementContext,
)

Parse parses the variable declaration statement context and populates the VariableDeclaration fields.

func (*VariableDeclaration) SetReferenceDescriptor

func (v *VariableDeclaration) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptors of the VariableDeclaration node.

func (*VariableDeclaration) ToProto

func (v *VariableDeclaration) ToProto() NodeType

ToProto converts the VariableDeclaration node to its corresponding protobuf representation.

func (*VariableDeclaration) UnmarshalJSON added in v0.3.1

func (v *VariableDeclaration) UnmarshalJSON(data []byte) error

type WhileStatement

type WhileStatement struct {
	*ASTBuilder

	Id        int64           `json:"id"`        // Unique identifier for the WhileStatement node.
	NodeType  ast_pb.NodeType `json:"nodeType"`  // Type of the AST node.
	Kind      ast_pb.NodeType `json:"kind"`      // Kind of while loop.
	Src       SrcNode         `json:"src"`       // Source location information.
	Condition Node[NodeType]  `json:"condition"` // Condition expression of the while loop.
	Body      *BodyNode       `json:"body"`      // Body of the while loop.
}

WhileStatement represents a while loop statement in the AST.

func NewWhileStatement

func NewWhileStatement(b *ASTBuilder) *WhileStatement

NewWhileStatement creates a new WhileStatement node with a given ASTBuilder.

func (*WhileStatement) GetBody

func (w *WhileStatement) GetBody() *BodyNode

GetBody returns the body of the WhileStatement node.

func (*WhileStatement) GetCondition

func (w *WhileStatement) GetCondition() Node[NodeType]

GetCondition returns the condition expression of the WhileStatement node.

func (*WhileStatement) GetId

func (w *WhileStatement) GetId() int64

GetId returns the ID of the WhileStatement node.

func (*WhileStatement) GetKind

func (w *WhileStatement) GetKind() ast_pb.NodeType

GetKind returns the kind of the while loop.

func (*WhileStatement) GetNodes

func (w *WhileStatement) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the WhileStatement node.

func (*WhileStatement) GetSrc

func (w *WhileStatement) GetSrc() SrcNode

GetSrc returns the SrcNode of the WhileStatement node.

func (*WhileStatement) GetType

func (w *WhileStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the WhileStatement node.

func (*WhileStatement) GetTypeDescription

func (w *WhileStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the TypeDescription of the WhileStatement node.

func (*WhileStatement) Parse

func (w *WhileStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.WhileStatementContext,
) Node[NodeType]

Parse parses a while loop statement context into the WhileStatement node.

func (*WhileStatement) SetReferenceDescriptor

func (w *WhileStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the WhileStatement node.

func (*WhileStatement) ToProto

func (w *WhileStatement) ToProto() NodeType

ToProto returns a protobuf representation of the WhileStatement node.

func (*WhileStatement) UnmarshalJSON added in v0.3.1

func (w *WhileStatement) UnmarshalJSON(data []byte) error

type Yul added in v0.3.1

type Yul struct {
	*ASTBuilder // Embedded ASTBuilder provides building functionalities for AST nodes.

	Id       int64           `json:"id"`       // Id uniquely identifies the assembly statement.
	NodeType ast_pb.NodeType `json:"nodeType"` // NodeType specifies the type of the node.
	Src      SrcNode         `json:"src"`      // Src contains source location details of the node.
	Body     *BodyNode       `json:"body"`     // Body represents the content of the assembly statement.
}

Yul represents an assembly statement in a Solidity source file.

func NewYul added in v0.3.1

func NewYul(b *ASTBuilder) *Yul

NewYul creates a new Yul and initializes its fields.

func (*Yul) GetBody added in v0.3.1

func (a *Yul) GetBody() *BodyNode

GetBody returns the content of the assembly statement.

func (*Yul) GetId added in v0.3.1

func (a *Yul) GetId() int64

GetId returns the unique identifier of the assembly statement.

func (*Yul) GetNodes added in v0.3.1

func (a *Yul) GetNodes() []Node[NodeType]

GetNodes retrieves the list of statements present in the assembly statement's body.

func (*Yul) GetSrc added in v0.3.1

func (a *Yul) GetSrc() SrcNode

GetSrc provides source location details of the node.

func (*Yul) GetType added in v0.3.1

func (a *Yul) GetType() ast_pb.NodeType

GetType returns the type of the node. For Yul, this is always NodeType_ASSEMBLY_STATEMENT.

func (*Yul) GetTypeDescription added in v0.3.1

func (a *Yul) GetTypeDescription() *TypeDescription

GetTypeDescription provides a description of the assembly statement's type. For Yul, this always returns an empty TypeDescription.

func (*Yul) Parse added in v0.3.1

func (a *Yul) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	ctx *parser.AssemblyStatementContext,
) Node[NodeType]

Parse populates the Yul fields by parsing the provided AssemblyStatementContext. It processes the context to generate the body of the assembly statement and its constituent statements.

func (*Yul) SetReferenceDescriptor added in v0.3.1

func (a *Yul) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor is a placeholder method which currently always returns false. Future implementations might set a reference descriptor based on provided arguments.

func (*Yul) ToProto added in v0.3.1

func (a *Yul) ToProto() NodeType

ToProto converts the assembly statement into its protobuf representation. Note: Complete implementation is yet to be provided.

type YulAssignment added in v0.3.1

type YulAssignment struct {
	*ASTBuilder

	Id            int64            `json:"id"`
	NodeType      ast_pb.NodeType  `json:"nodeType"`
	Src           SrcNode          `json:"src"`
	VariableNames []*YulIdentifier `json:"variableNames"`
	Value         Node[NodeType]   `json:"value"`
}

YulAssignment represents a Yul assignment structure in the AST.

func NewYulAssignment added in v0.3.1

func NewYulAssignment(b *ASTBuilder) *YulAssignment

NewYulAssignment initializes a new instance of the YulAssignment structure.

func (*YulAssignment) GetId added in v0.3.1

func (y *YulAssignment) GetId() int64

GetId retrieves the ID of the YulAssignment node.

func (*YulAssignment) GetNodes added in v0.3.1

func (y *YulAssignment) GetNodes() []Node[NodeType]

GetNodes retrieves the child nodes of the YulAssignment node.

func (*YulAssignment) GetSrc added in v0.3.1

func (y *YulAssignment) GetSrc() SrcNode

GetSrc retrieves the source of the YulAssignment node.

func (*YulAssignment) GetType added in v0.3.1

func (y *YulAssignment) GetType() ast_pb.NodeType

GetType retrieves the NodeType of the YulAssignment node.

func (*YulAssignment) GetTypeDescription added in v0.3.1

func (y *YulAssignment) GetTypeDescription() *TypeDescription

GetTypeDescription retrieves the type description of the YulAssignment node. It currently returns an empty TypeDescription, and is a placeholder for future extensions.

func (*YulAssignment) GetValue added in v0.3.1

func (y *YulAssignment) GetValue() Node[NodeType]

GetValue retrieves the value assigned in the YulAssignment node.

func (*YulAssignment) GetVariableNames added in v0.3.1

func (y *YulAssignment) GetVariableNames() []*YulIdentifier

GetVariableNames retrieves the variable names associated with the YulAssignment node.

func (*YulAssignment) Parse added in v0.3.1

func (y *YulAssignment) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	ctx *parser.YulAssignmentContext,
) Node[NodeType]

Parse parses a given YulAssignmentContext into the YulAssignment node.

func (*YulAssignment) SetReferenceDescriptor added in v0.3.1

func (y *YulAssignment) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulAssignment node. It currently always returns false, and is a placeholder for future extensions.

func (*YulAssignment) ToProto added in v0.3.1

func (y *YulAssignment) ToProto() NodeType

ToProto converts the YulAssignment node to its corresponding protocol buffer representation.

func (*YulAssignment) UnmarshalJSON added in v0.3.1

func (f *YulAssignment) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulAssignment node.

type YulBlockStatement added in v0.3.1

type YulBlockStatement struct {
	*ASTBuilder

	// Id is the unique identifier of the YUL block statement.
	Id int64 `json:"id"`

	// NodeType is the type of the YUL block statement node.
	NodeType ast_pb.NodeType `json:"nodeType"`

	// Src is the source location information of the YUL block statement.
	Src SrcNode `json:"src"`

	// Statements is a list of child nodes representing statements within the YUL block.
	Statements []Node[NodeType] `json:"statements"`
}

YulBlockStatement represents a YUL block statement in the abstract syntax tree.

func NewYulBlockStatement added in v0.3.1

func NewYulBlockStatement(b *ASTBuilder) *YulBlockStatement

NewYulBlockStatement creates a new YulBlockStatement instance.

func (*YulBlockStatement) GetId added in v0.3.1

func (y *YulBlockStatement) GetId() int64

GetId returns the ID of the YulBlockStatement.

func (*YulBlockStatement) GetNodes added in v0.3.1

func (y *YulBlockStatement) GetNodes() []Node[NodeType]

GetNodes returns the child nodes of the YulBlockStatement.

func (*YulBlockStatement) GetSrc added in v0.3.1

func (y *YulBlockStatement) GetSrc() SrcNode

GetSrc returns the source information of the YulBlockStatement.

func (*YulBlockStatement) GetStatements added in v0.3.1

func (y *YulBlockStatement) GetStatements() []Node[NodeType]

GetStatements returns the list of statements within the YulBlockStatement.

func (*YulBlockStatement) GetType added in v0.3.1

func (y *YulBlockStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulBlockStatement.

func (*YulBlockStatement) GetTypeDescription added in v0.3.1

func (y *YulBlockStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the YulBlockStatement.

func (*YulBlockStatement) Parse added in v0.3.1

func (y *YulBlockStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	ifStatement *parser.YulIfStatementContext,
	parentNode Node[NodeType],
	ctx *parser.YulBlockContext,
) Node[NodeType]

Parse parses a YulBlockStatement node.

func (*YulBlockStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulBlockStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulBlockStatement node.

func (*YulBlockStatement) ToProto added in v0.3.1

func (y *YulBlockStatement) ToProto() NodeType

ToProto converts the YulBlockStatement to its protocol buffer representation.

func (*YulBlockStatement) UnmarshalJSON added in v0.3.1

func (f *YulBlockStatement) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulBlockStatement node.

type YulBreakStatement added in v0.3.1

type YulBreakStatement struct {
	*ASTBuilder

	// Id is the unique identifier of the YUL break statement.
	Id int64 `json:"id"`

	// NodeType is the type of the YUL break statement node.
	NodeType ast_pb.NodeType `json:"nodeType"`

	// Src is the source location information of the YUL break statement.
	Src SrcNode `json:"src"`
}

YulBreakStatement represents a YUL break statement in the abstract syntax tree.

func NewYulBreakStatement added in v0.3.1

func NewYulBreakStatement(b *ASTBuilder) *YulBreakStatement

NewYulBreakStatement creates a new YulBreakStatement instance.

func (*YulBreakStatement) GetId added in v0.3.1

func (y *YulBreakStatement) GetId() int64

GetId returns the ID of the YulBreakStatement.

func (*YulBreakStatement) GetNodes added in v0.3.1

func (y *YulBreakStatement) GetNodes() []Node[NodeType]

GetNodes returns an empty list of child nodes for the YulBreakStatement.

func (*YulBreakStatement) GetSrc added in v0.3.1

func (y *YulBreakStatement) GetSrc() SrcNode

GetSrc returns the source information of the YulBreakStatement.

func (*YulBreakStatement) GetType added in v0.3.1

func (y *YulBreakStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulBreakStatement.

func (*YulBreakStatement) GetTypeDescription added in v0.3.1

func (y *YulBreakStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the YulBreakStatement.

func (*YulBreakStatement) Parse added in v0.3.1

func (y *YulBreakStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	ctx *antlr.TerminalNodeImpl,
) Node[NodeType]

Parse parses a YulBreakStatement node.

func (*YulBreakStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulBreakStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulBreakStatement node.

func (*YulBreakStatement) ToProto added in v0.3.1

func (y *YulBreakStatement) ToProto() NodeType

ToProto converts the YulBreakStatement to its protocol buffer representation.

type YulContinueStatement added in v0.3.1

type YulContinueStatement struct {
	*ASTBuilder

	// Id is the unique identifier of the YUL continue statement.
	Id int64 `json:"id"`

	// NodeType is the type of the YUL continue statement node.
	NodeType ast_pb.NodeType `json:"nodeType"`

	// Src is the source location information of the YUL continue statement.
	Src SrcNode `json:"src"`
}

YulContinueStatement represents a YUL continue statement in the abstract syntax tree.

func NewYulContinueStatement added in v0.3.1

func NewYulContinueStatement(b *ASTBuilder) *YulContinueStatement

NewYulContinueStatement creates a new YulContinueStatement instance.

func (*YulContinueStatement) GetId added in v0.3.1

func (y *YulContinueStatement) GetId() int64

GetId returns the ID of the YulContinueStatement.

func (*YulContinueStatement) GetNodes added in v0.3.1

func (y *YulContinueStatement) GetNodes() []Node[NodeType]

GetNodes returns an empty list of child nodes for the YulContinueStatement.

func (*YulContinueStatement) GetSrc added in v0.3.1

func (y *YulContinueStatement) GetSrc() SrcNode

GetSrc returns the source information of the YulContinueStatement.

func (*YulContinueStatement) GetType added in v0.3.1

func (y *YulContinueStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulContinueStatement.

func (*YulContinueStatement) GetTypeDescription added in v0.3.1

func (y *YulContinueStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the YulContinueStatement.

func (*YulContinueStatement) Parse added in v0.3.1

func (y *YulContinueStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	ctx *antlr.TerminalNodeImpl,
) Node[NodeType]

Parse parses a YulContinueStatement node.

func (*YulContinueStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulContinueStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulContinueStatement node.

func (*YulContinueStatement) ToProto added in v0.3.1

func (y *YulContinueStatement) ToProto() NodeType

ToProto converts the YulContinueStatement to its protocol buffer representation.

type YulExpressionStatement added in v0.3.1

type YulExpressionStatement struct {
	*ASTBuilder

	// Id is the unique identifier of the YUL expression statement.
	Id int64 `json:"id"`

	// NodeType is the type of the YUL expression statement node.
	NodeType ast_pb.NodeType `json:"nodeType"`

	// Src is the source location information of the YUL expression statement.
	Src SrcNode `json:"src"`

	// Expression is the expression node within the statement.
	Expression Node[NodeType] `json:"expression"`
}

YulExpressionStatement represents a YUL expression statement in the abstract syntax tree.

func NewYulExpressionStatement added in v0.3.1

func NewYulExpressionStatement(b *ASTBuilder) *YulExpressionStatement

NewYulExpressionStatement creates a new YulExpressionStatement instance.

func (*YulExpressionStatement) GetExpression added in v0.3.1

func (y *YulExpressionStatement) GetExpression() Node[NodeType]

GetExpression returns the expression node within the statement.

func (*YulExpressionStatement) GetId added in v0.3.1

func (y *YulExpressionStatement) GetId() int64

GetId returns the ID of the YulExpressionStatement.

func (*YulExpressionStatement) GetNodes added in v0.3.1

func (y *YulExpressionStatement) GetNodes() []Node[NodeType]

GetNodes returns a list containing the expression node.

func (*YulExpressionStatement) GetSrc added in v0.3.1

func (y *YulExpressionStatement) GetSrc() SrcNode

GetSrc returns the source information of the YulExpressionStatement.

func (*YulExpressionStatement) GetType added in v0.3.1

func (y *YulExpressionStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulExpressionStatement.

func (*YulExpressionStatement) GetTypeDescription added in v0.3.1

func (y *YulExpressionStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the YulExpressionStatement.

func (*YulExpressionStatement) Parse added in v0.3.1

func (y *YulExpressionStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	parentNode Node[NodeType],
	ctx *parser.YulExpressionContext,
) Node[NodeType]

Parse parses a YulExpressionStatement node.

func (*YulExpressionStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulExpressionStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulExpressionStatement node.

func (*YulExpressionStatement) ToProto added in v0.3.1

func (y *YulExpressionStatement) ToProto() NodeType

ToProto converts the YulExpressionStatement to its protocol buffer representation.

func (*YulExpressionStatement) UnmarshalJSON added in v0.3.1

func (f *YulExpressionStatement) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulExpressionStatement node.

type YulForStatement added in v0.3.1

type YulForStatement struct {
	*ASTBuilder

	// Id is the unique identifier of the YUL for statement.
	Id int64 `json:"id"`

	// NodeType is the type of the YUL for statement node.
	NodeType ast_pb.NodeType `json:"nodeType"`

	// Src is the source location information of the YUL for statement.
	Src SrcNode `json:"src"`

	// Pre is the initialization node before the loop.
	Pre Node[NodeType] `json:"pre"`

	// Post is the post-execution node after each iteration of the loop.
	Post Node[NodeType] `json:"post"`

	// Condition is the condition node of the loop.
	Condition Node[NodeType] `json:"condition"`

	// Body is the body of the loop.
	Body Node[NodeType] `json:"body"`
}

YulForStatement represents a YUL for statement in the abstract syntax tree.

func NewYulForStatement added in v0.3.1

func NewYulForStatement(b *ASTBuilder) *YulForStatement

NewYulForStatement creates a new YulForStatement instance.

func (*YulForStatement) GetBody added in v0.3.1

func (y *YulForStatement) GetBody() Node[NodeType]

GetBody returns the body of the loop.

func (*YulForStatement) GetCondition added in v0.3.1

func (y *YulForStatement) GetCondition() Node[NodeType]

GetCondition returns the condition node of the loop.

func (*YulForStatement) GetId added in v0.3.1

func (y *YulForStatement) GetId() int64

GetId returns the ID of the YulForStatement.

func (*YulForStatement) GetNodes added in v0.3.1

func (y *YulForStatement) GetNodes() []Node[NodeType]

GetNodes returns a list containing the condition and body nodes.

func (*YulForStatement) GetPost added in v0.3.1

func (y *YulForStatement) GetPost() Node[NodeType]

GetPost returns the post-execution node after each iteration of the loop.

func (*YulForStatement) GetPre added in v0.3.1

func (y *YulForStatement) GetPre() Node[NodeType]

GetPre returns the initialization node before the loop.

func (*YulForStatement) GetSrc added in v0.3.1

func (y *YulForStatement) GetSrc() SrcNode

GetSrc returns the source information of the YulForStatement.

func (*YulForStatement) GetType added in v0.3.1

func (y *YulForStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulForStatement.

func (*YulForStatement) GetTypeDescription added in v0.3.1

func (y *YulForStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the YulForStatement.

func (*YulForStatement) Parse added in v0.3.1

func (y *YulForStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	ctx *parser.YulForStatementContext,
) Node[NodeType]

Parse parses a YUL for statement.

func (*YulForStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulForStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulForStatement node.

func (*YulForStatement) ToProto added in v0.3.1

func (y *YulForStatement) ToProto() NodeType

ToProto converts the YulForStatement to its protocol buffer representation.

func (*YulForStatement) UnmarshalJSON added in v0.3.1

func (f *YulForStatement) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulForStatement node.

type YulFunctionCallStatement added in v0.3.1

type YulFunctionCallStatement struct {
	*ASTBuilder

	// Id is the unique identifier of the YUL function call statement.
	Id int64 `json:"id"`

	// NodeType is the type of the YUL function call statement node.
	NodeType ast_pb.NodeType `json:"nodeType"`

	// Src is the source location information of the YUL function call statement.
	Src SrcNode `json:"src"`

	// FunctionName is the name of the function being called.
	FunctionName *YulIdentifier `json:"functionName"`

	// Arguments is a list of argument nodes for the function call.
	Arguments []Node[NodeType] `json:"arguments"`
}

YulFunctionCallStatement represents a YUL function call statement in the abstract syntax tree.

func NewYulFunctionCallStatement added in v0.3.1

func NewYulFunctionCallStatement(b *ASTBuilder) *YulFunctionCallStatement

NewYulFunctionCallStatement creates a new YulFunctionCallStatement instance.

func (*YulFunctionCallStatement) GetArguments added in v0.3.1

func (y *YulFunctionCallStatement) GetArguments() []Node[NodeType]

GetArguments returns the list of argument nodes for the function call.

func (*YulFunctionCallStatement) GetFunctionName added in v0.3.1

func (y *YulFunctionCallStatement) GetFunctionName() *YulIdentifier

GetFunctionName returns the name of the function being called.

func (*YulFunctionCallStatement) GetId added in v0.3.1

func (y *YulFunctionCallStatement) GetId() int64

GetId returns the ID of the YulFunctionCallStatement.

func (*YulFunctionCallStatement) GetNodes added in v0.3.1

func (y *YulFunctionCallStatement) GetNodes() []Node[NodeType]

GetNodes returns a list containing the argument nodes.

func (*YulFunctionCallStatement) GetSrc added in v0.3.1

func (y *YulFunctionCallStatement) GetSrc() SrcNode

GetSrc returns the source information of the YulFunctionCallStatement.

func (*YulFunctionCallStatement) GetType added in v0.3.1

GetType returns the NodeType of the YulFunctionCallStatement.

func (*YulFunctionCallStatement) GetTypeDescription added in v0.3.1

func (y *YulFunctionCallStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the YulFunctionCallStatement.

func (*YulFunctionCallStatement) Parse added in v0.3.1

func (y *YulFunctionCallStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	parentNode Node[NodeType],
	ctx *parser.YulFunctionCallContext,
) Node[NodeType]

Parse parses a YUL function call statement.

func (*YulFunctionCallStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulFunctionCallStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulFunctionCallStatement node.

func (*YulFunctionCallStatement) ToProto added in v0.3.1

func (y *YulFunctionCallStatement) ToProto() NodeType

ToProto converts the YulFunctionCallStatement to its protocol buffer representation.

func (*YulFunctionCallStatement) UnmarshalJSON added in v0.3.1

func (y *YulFunctionCallStatement) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulFunctionCallStatement node.

type YulFunctionDefinition added in v0.3.1

type YulFunctionDefinition struct {
	*ASTBuilder

	// Id is the unique identifier of the YUL function definition.
	Id int64 `json:"id"`

	// NodeType is the type of the YUL function definition node.
	NodeType ast_pb.NodeType `json:"nodeType"`

	// Src is the source location information of the YUL function definition.
	Src SrcNode `json:"src"`

	// Arguments is a list of YUL identifiers representing function arguments.
	Arguments []*YulIdentifier `json:"arguments"`

	// Body is the body of the YUL function definition.
	Body Node[NodeType] `json:"body"`

	// ReturnParameters is a list of YUL identifiers representing return parameters.
	ReturnParameters []*YulIdentifier `json:"returnParameters"`
}

YulFunctionDefinition represents a YUL function definition in the abstract syntax tree.

func NewYulFunctionDefinition added in v0.3.1

func NewYulFunctionDefinition(b *ASTBuilder) *YulFunctionDefinition

NewYulFunctionDefinition creates a new YulFunctionDefinition instance.

func (*YulFunctionDefinition) GetArguments added in v0.3.1

func (y *YulFunctionDefinition) GetArguments() []*YulIdentifier

GetArguments returns the list of YUL identifiers representing function arguments.

func (*YulFunctionDefinition) GetBody added in v0.3.1

func (y *YulFunctionDefinition) GetBody() Node[NodeType]

GetBody returns the body of the YUL function definition.

func (*YulFunctionDefinition) GetId added in v0.3.1

func (y *YulFunctionDefinition) GetId() int64

GetId returns the ID of the YulFunctionDefinition.

func (*YulFunctionDefinition) GetNodes added in v0.3.1

func (y *YulFunctionDefinition) GetNodes() []Node[NodeType]

GetNodes returns a list containing the body node.

func (*YulFunctionDefinition) GetReturnParameters added in v0.3.1

func (y *YulFunctionDefinition) GetReturnParameters() []*YulIdentifier

GetReturnParameters returns the list of YUL identifiers representing return parameters.

func (*YulFunctionDefinition) GetSrc added in v0.3.1

func (y *YulFunctionDefinition) GetSrc() SrcNode

GetSrc returns the source information of the YulFunctionDefinition.

func (*YulFunctionDefinition) GetType added in v0.3.1

func (y *YulFunctionDefinition) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulFunctionDefinition.

func (*YulFunctionDefinition) GetTypeDescription added in v0.3.1

func (y *YulFunctionDefinition) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the YulFunctionDefinition.

func (*YulFunctionDefinition) Parse added in v0.3.1

func (y *YulFunctionDefinition) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	ctx *parser.YulFunctionDefinitionContext,
) Node[NodeType]

Parse parses a YUL function definition.

func (*YulFunctionDefinition) SetReferenceDescriptor added in v0.3.1

func (y *YulFunctionDefinition) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulFunctionDefinition node.

func (*YulFunctionDefinition) ToProto added in v0.3.1

func (y *YulFunctionDefinition) ToProto() NodeType

ToProto converts the YulFunctionDefinition to its protocol buffer representation.

func (*YulFunctionDefinition) UnmarshalJSON added in v0.3.1

func (f *YulFunctionDefinition) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulFunctionDefinition node.

type YulIdentifier added in v0.3.1

type YulIdentifier struct {
	*ASTBuilder

	// Id is the unique identifier of the YUL identifier.
	Id int64 `json:"id"`

	// NodeType is the type of the YUL identifier node.
	NodeType ast_pb.NodeType `json:"nodeType"`

	// Src is the source location information of the YUL identifier.
	Src SrcNode `json:"src"`

	// Name is the name of the YUL identifier.
	Name string `json:"name"`
}

YulIdentifier represents a YUL identifier in the abstract syntax tree.

func (*YulIdentifier) GetId added in v0.3.1

func (y *YulIdentifier) GetId() int64

GetId returns the ID of the YulIdentifier.

func (*YulIdentifier) GetName added in v0.3.1

func (y *YulIdentifier) GetName() string

GetName returns the name of the YulIdentifier.

func (*YulIdentifier) GetNodes added in v0.3.1

func (y *YulIdentifier) GetNodes() []Node[NodeType]

GetNodes returns an empty list of nodes.

func (*YulIdentifier) GetSrc added in v0.3.1

func (y *YulIdentifier) GetSrc() SrcNode

GetSrc returns the source information of the YulIdentifier.

func (*YulIdentifier) GetType added in v0.3.1

func (y *YulIdentifier) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulIdentifier.

func (*YulIdentifier) GetTypeDescription added in v0.3.1

func (y *YulIdentifier) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the YulIdentifier.

func (*YulIdentifier) SetReferenceDescriptor added in v0.3.1

func (y *YulIdentifier) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulIdentifier node.

func (*YulIdentifier) ToProto added in v0.3.1

func (y *YulIdentifier) ToProto() NodeType

ToProto converts the YulIdentifier to its protocol buffer representation.

type YulIfStatement added in v0.3.1

type YulIfStatement struct {
	*ASTBuilder

	// Id is the unique identifier of the YUL if statement.
	Id int64 `json:"id"`

	// NodeType is the type of the YUL if statement node.
	NodeType ast_pb.NodeType `json:"nodeType"`

	// Src is the source location information of the YUL if statement.
	Src SrcNode `json:"src"`

	// Condition is the condition expression of the if statement.
	Condition Node[NodeType] `json:"condition"`

	// Body is the body of the if statement.
	Body Node[NodeType] `json:"body"`
}

YulIfStatement represents an if statement in the abstract syntax tree.

func NewYulIfStatement added in v0.3.1

func NewYulIfStatement(b *ASTBuilder) *YulIfStatement

NewYulIfStatement creates a new YulIfStatement with the provided AST builder.

func (*YulIfStatement) GetBody added in v0.3.1

func (y *YulIfStatement) GetBody() Node[NodeType]

GetBody returns the body of the if statement.

func (*YulIfStatement) GetCondition added in v0.3.1

func (y *YulIfStatement) GetCondition() Node[NodeType]

GetCondition returns the condition expression of the if statement.

func (*YulIfStatement) GetId added in v0.3.1

func (y *YulIfStatement) GetId() int64

GetId returns the ID of the YulIfStatement.

func (*YulIfStatement) GetNodes added in v0.3.1

func (y *YulIfStatement) GetNodes() []Node[NodeType]

GetNodes returns a list containing the Condition and Body nodes.

func (*YulIfStatement) GetSrc added in v0.3.1

func (y *YulIfStatement) GetSrc() SrcNode

GetSrc returns the source information of the YulIfStatement.

func (*YulIfStatement) GetType added in v0.3.1

func (y *YulIfStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulIfStatement.

func (*YulIfStatement) GetTypeDescription added in v0.3.1

func (y *YulIfStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns the type description of the YulIfStatement.

func (*YulIfStatement) Parse added in v0.3.1

func (y *YulIfStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	ctx *parser.YulIfStatementContext,
) Node[NodeType]

Parse converts a YulIfStatementContext to a YulIfStatement node.

func (*YulIfStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulIfStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulIfStatement node.

func (*YulIfStatement) ToProto added in v0.3.1

func (y *YulIfStatement) ToProto() NodeType

ToProto converts the YulIfStatement to its protocol buffer representation.

func (*YulIfStatement) UnmarshalJSON added in v0.3.1

func (f *YulIfStatement) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulIfStatement node.

type YulLeaveStatement added in v0.3.1

type YulLeaveStatement struct {
	*ASTBuilder // Embedded ASTBuilder for utility functions.

	Id       int64           `json:"id"`       // Unique identifier for the statement.
	NodeType ast_pb.NodeType `json:"nodeType"` // Type of the node in the AST.
	Src      SrcNode         `json:"src"`      // Source code location information.
}

YulLeaveStatement represents a YUL Leave statement in the AST.

func NewYulLeaveStatement added in v0.3.1

func NewYulLeaveStatement(b *ASTBuilder) *YulLeaveStatement

NewYulLeaveStatement creates and initializes a new YulLeaveStatement.

func (*YulLeaveStatement) GetId added in v0.3.1

func (y *YulLeaveStatement) GetId() int64

GetId retrieves the unique identifier of the YulLeaveStatement.

func (*YulLeaveStatement) GetNodes added in v0.3.1

func (y *YulLeaveStatement) GetNodes() []Node[NodeType]

GetNodes retrieves child nodes of the YulLeaveStatement. For YulLeaveStatement, it always returns an empty slice as it doesn't have child nodes.

func (*YulLeaveStatement) GetSrc added in v0.3.1

func (y *YulLeaveStatement) GetSrc() SrcNode

GetSrc retrieves the source code location information for the YulLeaveStatement.

func (*YulLeaveStatement) GetType added in v0.3.1

func (y *YulLeaveStatement) GetType() ast_pb.NodeType

GetType retrieves the node type of the YulLeaveStatement.

func (*YulLeaveStatement) GetTypeDescription added in v0.3.1

func (y *YulLeaveStatement) GetTypeDescription() *TypeDescription

GetTypeDescription retrieves the type description of the YulLeaveStatement. This currently returns an empty TypeDescription.

func (*YulLeaveStatement) Parse added in v0.3.1

func (y *YulLeaveStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	ctx *antlr.TerminalNodeImpl,
) Node[NodeType]

Parse populates the YulLeaveStatement fields based on the provided context. This method is typically used during the AST construction phase.

func (*YulLeaveStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulLeaveStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulLeaveStatement node. Currently, it always returns false as there are no reference descriptions for YulLeaveStatement.

func (*YulLeaveStatement) ToProto added in v0.3.1

func (y *YulLeaveStatement) ToProto() NodeType

ToProto converts the YulLeaveStatement to its Protocol Buffer representation.

type YulLiteralStatement added in v0.3.1

type YulLiteralStatement struct {
	*ASTBuilder                 // Embedded ASTBuilder for utility functions.
	Id          int64           `json:"id"`
	NodeType    ast_pb.NodeType `json:"nodeType"`
	Kind        ast_pb.NodeType `json:"kind"`
	Src         SrcNode         `json:"src"`
	Value       string          `json:"value"`
	HexValue    string          `json:"hexValue"`
}

YulLiteralStatement represents a Yul literal in the AST.

func NewYulLiteralStatement added in v0.3.1

func NewYulLiteralStatement(b *ASTBuilder) *YulLiteralStatement

NewYulLiteralStatement initializes a new YulLiteralStatement node.

func (*YulLiteralStatement) GetHexValue added in v0.3.1

func (y *YulLiteralStatement) GetHexValue() string

GetHexValue returns back hexadecimal value of the literal

func (*YulLiteralStatement) GetId added in v0.3.1

func (y *YulLiteralStatement) GetId() int64

GetId retrieves the ID of the YulLiteralStatement.

func (*YulLiteralStatement) GetKind added in v0.3.1

func (y *YulLiteralStatement) GetKind() ast_pb.NodeType

func (*YulLiteralStatement) GetNodes added in v0.3.1

func (y *YulLiteralStatement) GetNodes() []Node[NodeType]

GetNodes retrieves child nodes of the YulLiteralStatement. This returns an empty slice as YulLiteralStatement doesn't have child nodes.

func (*YulLiteralStatement) GetSrc added in v0.3.1

func (y *YulLiteralStatement) GetSrc() SrcNode

GetSrc retrieves the source node information of the YulLiteralStatement.

func (*YulLiteralStatement) GetType added in v0.3.1

func (y *YulLiteralStatement) GetType() ast_pb.NodeType

GetType retrieves the node type of the YulLiteralStatement.

func (*YulLiteralStatement) GetTypeDescription added in v0.3.1

func (y *YulLiteralStatement) GetTypeDescription() *TypeDescription

GetTypeDescription retrieves the type description of the YulLiteralStatement. This currently returns an empty TypeDescription.

func (*YulLiteralStatement) GetValue added in v0.3.1

func (y *YulLiteralStatement) GetValue() string

GetValue returns back value of the literal

func (*YulLiteralStatement) Parse added in v0.3.1

func (y *YulLiteralStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	parentNode Node[NodeType],
	ctx *parser.YulLiteralContext,
) Node[NodeType]

Parse processes the given YulLiteralContext to populate the fields of the YulLiteralStatement.

func (*YulLiteralStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulLiteralStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulLiteralStatement node. Currently, this method always returns false and does not set any reference descriptor.

func (*YulLiteralStatement) ToProto added in v0.3.1

func (y *YulLiteralStatement) ToProto() NodeType

ToProto converts the YulLiteralStatement to its Protocol Buffer representation.

type YulStatement

type YulStatement struct {
	*ASTBuilder

	Id         int64            `json:"id"`         // Unique identifier for the statement node.
	NodeType   ast_pb.NodeType  `json:"nodeType"`   // The type of the node.
	Src        SrcNode          `json:"src"`        // Source information about the node.
	Statements []Node[NodeType] `json:"statements"` // Statements within this Yul statement.
}

YulStatement represents a statement in the Yul language.

func NewYulStatement

func NewYulStatement(b *ASTBuilder) *YulStatement

NewYulStatement creates a new YulStatement node and initializes its fields.

func (*YulStatement) GetId

func (y *YulStatement) GetId() int64

GetId returns the unique identifier of the YulStatement node.

func (*YulStatement) GetNodes

func (y *YulStatement) GetNodes() []Node[NodeType]

GetNodes returns the statements within the YulStatement node.

func (*YulStatement) GetSrc

func (y *YulStatement) GetSrc() SrcNode

GetSrc returns the source information of the YulStatement node.

func (*YulStatement) GetStatements added in v0.3.1

func (y *YulStatement) GetStatements() []Node[NodeType]

func (*YulStatement) GetType

func (y *YulStatement) GetType() ast_pb.NodeType

GetType returns the type of the YulStatement node.

func (*YulStatement) GetTypeDescription

func (y *YulStatement) GetTypeDescription() *TypeDescription

GetTypeDescription returns an empty TypeDescription for the YulStatement node.

func (*YulStatement) Parse

func (y *YulStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	parentNode Node[NodeType],
	ctx *parser.YulStatementContext,
) Node[NodeType]

Parse processes the provided YulStatementContext and populates the YulStatement node's fields based on its content.

func (*YulStatement) SetReferenceDescriptor

func (y *YulStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor sets the reference descriptions of the YulStatement node. It always returns false for this node type.

func (*YulStatement) ToProto

func (y *YulStatement) ToProto() NodeType

ToProto converts the YulStatement node into its protocol buffer representation.

func (*YulStatement) UnmarshalJSON added in v0.3.1

func (f *YulStatement) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulStatement node. Currently, this function does not perform any unmarshalling and always returns nil.

type YulSwitchCaseStatement added in v0.3.1

type YulSwitchCaseStatement struct {
	*ASTBuilder // Embedded ASTBuilder for utility functions.

	Id       int64           `json:"id"`       // Id is the unique identifier for the switch case statement.
	NodeType ast_pb.NodeType `json:"nodeType"` // NodeType specifies the type of the node.
	Src      SrcNode         `json:"src"`      // Src provides source location details of the switch case statement.
	Case     Node[NodeType]  `json:"case"`     // Case holds the condition for the switch case.
	Body     Node[NodeType]  `json:"body"`     // Body represents the block of code to execute for this case.
}

YulSwitchCaseStatement represents an individual case statement within a Yul switch structure.

func NewYulSwitchCaseStatement added in v0.3.1

func NewYulSwitchCaseStatement(b *ASTBuilder) *YulSwitchCaseStatement

NewYulSwitchCaseStatement creates and initializes a new YulSwitchCaseStatement.

func (*YulSwitchCaseStatement) GetBody added in v0.3.1

func (y *YulSwitchCaseStatement) GetBody() Node[NodeType]

GetBody returns body of the associated nodes

func (*YulSwitchCaseStatement) GetCase added in v0.3.1

func (y *YulSwitchCaseStatement) GetCase() Node[NodeType]

GetCase returns case identifier

func (*YulSwitchCaseStatement) GetId added in v0.3.1

func (y *YulSwitchCaseStatement) GetId() int64

GetId retrieves the unique identifier of the YulSwitchCaseStatement.

func (*YulSwitchCaseStatement) GetNodes added in v0.3.1

func (y *YulSwitchCaseStatement) GetNodes() []Node[NodeType]

GetNodes returns a list of nodes associated with the YulSwitchCaseStatement.

func (*YulSwitchCaseStatement) GetSrc added in v0.3.1

func (y *YulSwitchCaseStatement) GetSrc() SrcNode

GetSrc provides the source location details of the YulSwitchCaseStatement.

func (*YulSwitchCaseStatement) GetType added in v0.3.1

func (y *YulSwitchCaseStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulSwitchCaseStatement.

func (*YulSwitchCaseStatement) GetTypeDescription added in v0.3.1

func (y *YulSwitchCaseStatement) GetTypeDescription() *TypeDescription

GetTypeDescription provides a description of the YulSwitchCaseStatement's type. Always returns an empty TypeDescription.

func (*YulSwitchCaseStatement) Parse added in v0.3.1

func (y *YulSwitchCaseStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	parentNode Node[NodeType],
	ctx *parser.YulSwitchCaseContext,
) Node[NodeType]

Parse populates the YulSwitchCaseStatement fields based on the provided YulSwitchCaseContext.

func (*YulSwitchCaseStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulSwitchCaseStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor is a placeholder method for setting reference descriptors. Currently always returns false.

func (*YulSwitchCaseStatement) ToProto added in v0.3.1

func (y *YulSwitchCaseStatement) ToProto() NodeType

ToProto converts the YulSwitchCaseStatement into its protobuf representation. Note: This method currently returns an empty Statement.

func (*YulSwitchCaseStatement) UnmarshalJSON added in v0.3.1

func (f *YulSwitchCaseStatement) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulSwitchCaseStatement. Currently, this is a placeholder and does nothing.

type YulSwitchStatement added in v0.3.1

type YulSwitchStatement struct {
	*ASTBuilder // Embedded ASTBuilder for utility functions.

	Id       int64            `json:"id"`       // Id is the unique identifier for the switch statement.
	NodeType ast_pb.NodeType  `json:"nodeType"` // NodeType specifies the type of the node.
	Src      SrcNode          `json:"src"`      // Src provides source location details of the switch statement.
	Cases    []Node[NodeType] `json:"cases"`    // Cases holds the different cases of the switch statement.
}

YulSwitchStatement represents a switch statement in Yul assembly.

func NewYulSwitchStatement added in v0.3.1

func NewYulSwitchStatement(b *ASTBuilder) *YulSwitchStatement

NewYulSwitchStatement creates and initializes a new YulSwitchStatement.

func (*YulSwitchStatement) GetCases added in v0.3.1

func (y *YulSwitchStatement) GetCases() []Node[NodeType]

func (*YulSwitchStatement) GetId added in v0.3.1

func (y *YulSwitchStatement) GetId() int64

GetId retrieves the unique identifier of the YulSwitchStatement.

func (*YulSwitchStatement) GetNodes added in v0.3.1

func (y *YulSwitchStatement) GetNodes() []Node[NodeType]

GetNodes returns a list of nodes associated with the YulSwitchStatement.

func (*YulSwitchStatement) GetSrc added in v0.3.1

func (y *YulSwitchStatement) GetSrc() SrcNode

GetSrc provides the source location details of the YulSwitchStatement.

func (*YulSwitchStatement) GetType added in v0.3.1

func (y *YulSwitchStatement) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulSwitchStatement.

func (*YulSwitchStatement) GetTypeDescription added in v0.3.1

func (y *YulSwitchStatement) GetTypeDescription() *TypeDescription

GetTypeDescription provides a description of the YulSwitchStatement's type. Always returns an empty TypeDescription.

func (*YulSwitchStatement) Parse added in v0.3.1

func (y *YulSwitchStatement) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	ctx *parser.YulSwitchStatementContext,
) Node[NodeType]

Parse populates the YulSwitchStatement fields based on the provided YulSwitchStatementContext.

func (*YulSwitchStatement) SetReferenceDescriptor added in v0.3.1

func (y *YulSwitchStatement) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor is a placeholder method for setting reference descriptors. Currently always returns false.

func (*YulSwitchStatement) ToProto added in v0.3.1

func (y *YulSwitchStatement) ToProto() NodeType

ToProto converts the YulSwitchStatement into its protobuf representation. Note: This method currently returns an empty Statement.

func (*YulSwitchStatement) UnmarshalJSON added in v0.3.1

func (f *YulSwitchStatement) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulSwitchStatement. Currently, this is a placeholder and does nothing.

type YulVariable added in v0.3.1

type YulVariable struct {
	*ASTBuilder // Embedded ASTBuilder for utility functions.

	Id        int64            `json:"id"`        // Id is a unique identifier for the variable.
	NodeType  ast_pb.NodeType  `json:"nodeType"`  // NodeType specifies the type of the node.
	Src       SrcNode          `json:"src"`       // Src contains the source location details of the variable.
	Let       bool             `json:"let"`       // Let indicates if the variable is declared with a "let" keyword.
	Value     Node[NodeType]   `json:"value"`     // Value holds the initialized value of the variable.
	Variables []*YulIdentifier `json:"variables"` // Variables contains a list of Yul identifiers.
}

YulVariable represents a variable declaration in Yul assembly.

func NewYulVariable added in v0.3.1

func NewYulVariable(b *ASTBuilder) *YulVariable

NewYulVariable initializes a new YulVariable with default values.

func (*YulVariable) GetId added in v0.3.1

func (y *YulVariable) GetId() int64

GetId retrieves the unique identifier of the YulVariable.

func (*YulVariable) GetNodes added in v0.3.1

func (y *YulVariable) GetNodes() []Node[NodeType]

GetNodes returns a list of nodes associated with the YulVariable, including its initialized value.

func (*YulVariable) GetSrc added in v0.3.1

func (y *YulVariable) GetSrc() SrcNode

GetSrc provides the source location details of the YulVariable.

func (*YulVariable) GetType added in v0.3.1

func (y *YulVariable) GetType() ast_pb.NodeType

GetType returns the NodeType of the YulVariable.

func (*YulVariable) GetTypeDescription added in v0.3.1

func (y *YulVariable) GetTypeDescription() *TypeDescription

GetTypeDescription provides a description of the YulVariable's type. Always returns an empty TypeDescription.

func (*YulVariable) GetValue added in v0.3.1

func (y *YulVariable) GetValue() Node[NodeType]

GetValue returns variable value declaration

func (*YulVariable) GetVariables added in v0.3.1

func (y *YulVariable) GetVariables() []*YulIdentifier

GetVariables returns variable discovered variables

func (*YulVariable) IsLet added in v0.3.1

func (y *YulVariable) IsLet() bool

IsLet returns whenever variable is using let

func (*YulVariable) Parse added in v0.3.1

func (y *YulVariable) Parse(
	unit *SourceUnit[Node[ast_pb.SourceUnit]],
	contractNode Node[NodeType],
	fnNode Node[NodeType],
	bodyNode *BodyNode,
	assemblyNode *Yul,
	statementNode *YulStatement,
	ctx *parser.YulVariableDeclarationContext,
) Node[NodeType]

Parse populates the YulVariable fields by parsing the provided YulVariableDeclarationContext.

func (*YulVariable) SetReferenceDescriptor added in v0.3.1

func (y *YulVariable) SetReferenceDescriptor(refId int64, refDesc *TypeDescription) bool

SetReferenceDescriptor is a placeholder method for setting reference descriptors. Currently always returns false.

func (*YulVariable) ToProto added in v0.3.1

func (y *YulVariable) ToProto() NodeType

ToProto converts the YulVariable into its protobuf representation. Note: This method currently returns an empty Statement.

func (*YulVariable) UnmarshalJSON added in v0.3.1

func (y *YulVariable) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a given JSON byte array into a YulVariable.

Jump to

Keyboard shortcuts

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