ir

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: 18 Imported by: 7

Documentation

Overview

Package ir provides an intermediate representation of the AST.

Package ir provides an intermediate representation for the AST of a Solidity contract.

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 v3.TypedStruct from the given proto message and protoType.

Types

type Body

type Body struct {
	Unit       *ast.BodyNode   `json:"ast"` // Original AST node reference
	Id         int64           `json:"id"`
	NodeType   ast_pb.NodeType `json:"nodeType"`
	Kind       ast_pb.NodeType `json:"kind"`
	Statements []Statement     `json:"statements"`
}

Body represents a generic body of a construct, which can contain multiple statements.

func (*Body) GetAST

func (e *Body) GetAST() *ast.BodyNode

GetAST returns the original AST node reference for the body.

func (*Body) GetId

func (e *Body) GetId() int64

GetId returns the unique identifier of the body node.

func (*Body) GetKind

func (e *Body) GetKind() ast_pb.NodeType

GetKind returns the kind of the body node.

func (*Body) GetNodeType

func (e *Body) GetNodeType() ast_pb.NodeType

GetNodeType returns the type of the body node.

func (*Body) GetNodes

func (e *Body) GetNodes() []Statement

GetNodes returns a list of statements contained within the body.

func (*Body) GetSrc

func (e *Body) GetSrc() ast.SrcNode

GetSrc returns the source location of the body node.

func (*Body) GetStatements

func (e *Body) GetStatements() []Statement

GetStatements returns a list of statements contained within the body.

func (*Body) ToProto

func (e *Body) ToProto() *ir_pb.Body

ToProto converts the Body into its protocol buffer representation.

type Builder

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

Builder facilitates the creation of the IR from source code using solgo and AST tools.

func NewBuilderFromJSON added in v0.3.1

func NewBuilderFromJSON(ctx context.Context, data []byte) (*Builder, error)

NewBuilderFromJSON creates a new IR builder from a JSON representation of the AST.

func NewBuilderFromSources

func NewBuilderFromSources(ctx context.Context, sources *solgo.Sources) (*Builder, error)

NewBuilderFromSources creates a new IR builder from given sources. It initializes the necessary parser and AST builder from the provided sources.

func (*Builder) Build

func (b *Builder) Build() error

Build constructs the IR from the sources.

func (*Builder) GetAddress added in v0.3.3

func (b *Builder) GetAddress() common.Address

GetAddress retrieves the Ethereum address currently associated with the Builder. If an address has been set using SetAddress, this method returns that address. Otherwise, it returns an empty common.Address. This function can be useful to check if an address has been set or to retrieve the address for use in context-specific operations.

func (*Builder) GetAstBuilder

func (b *Builder) GetAstBuilder() *ast.ASTBuilder

GetAstBuilder returns the AST builder.

func (*Builder) GetParser

func (b *Builder) GetParser() *solgo.Parser

GetParser returns the underlying solgo parser.

func (*Builder) GetRoot

func (b *Builder) GetRoot() *RootSourceUnit

GetRoot retrieves the root of the IR.

func (*Builder) GetSources

func (b *Builder) GetSources() *solgo.Sources

GetSources returns the source files being processed.

func (*Builder) LookupReferencedFunctionsByNode

func (b *Builder) LookupReferencedFunctionsByNode(nodes ast.Node[ast.NodeType]) []*Function

LookupReferencedFunctionsByNode searches for referenced functions in the given AST nodes and returns a slice of functions. It searches for referenced functions in member access expressions and function calls within the AST nodes recursively.

func (*Builder) Parse

func (b *Builder) Parse() (errs []error)

Parse processes the sources using the parser and the AST builder and returns any encountered errors.

func (*Builder) SetAddress added in v0.3.3

func (b *Builder) SetAddress(address common.Address)

SetAddress assigns a specific Ethereum address to the Builder. This address can be associated with the sources being processed and might be used for context-specific operations that require an Ethereum address. For instance, when generating IR that includes information specific to a deployed contract, the address could be essential for accurate data representation.

func (*Builder) ToJSON

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

ToJSON returns the JSON representation of the IR.

func (*Builder) ToJSONPretty

func (b *Builder) ToJSONPretty() ([]byte, error)

ToJSONPretty provides a prettified JSON representation of the IR.

func (*Builder) ToProto

func (b *Builder) ToProto() *ir_pb.Root

ToProto converts the IR to its protocol buffer representation.

func (*Builder) ToProtoPretty

func (b *Builder) ToProtoPretty() ([]byte, error)

ToProtoPretty provides a prettified JSON representation of the protocol buffer version of the IR.

type Constructor

type Constructor struct {
	Unit             *ast.Constructor  `json:"ast"`
	Id               int64             `json:"id"`
	NodeType         ast_pb.NodeType   `json:"nodeType"`
	Kind             ast_pb.NodeType   `json:"kind"`
	Name             string            `json:"name"`
	Implemented      bool              `json:"implemented"`
	Visibility       ast_pb.Visibility `json:"visibility"`
	StateMutability  ast_pb.Mutability `json:"stateMutability"`
	Virtual          bool              `json:"virtual"`
	Modifiers        []*Modifier       `json:"modifiers"`
	Parameters       []*Parameter      `json:"parameters"`
	ReturnStatements []*Parameter      `json:"return"`
}

Constructor represents a contract constructor.

func (*Constructor) GetAST

func (f *Constructor) GetAST() *ast.Constructor

GetAST returns the underlying ast.Constructor.

func (*Constructor) GetId

func (f *Constructor) GetId() int64

GetId returns the ID of the constructor.

func (*Constructor) GetKind

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

GetKind returns the kind of the constructor.

func (*Constructor) GetModifiers

func (f *Constructor) GetModifiers() []*Modifier

GetModifiers returns the modifiers of the constructor.

func (*Constructor) GetName

func (f *Constructor) GetName() string

GetName returns the name of the constructor.

func (*Constructor) GetNodeType

func (f *Constructor) GetNodeType() ast_pb.NodeType

GetNodeType returns the node type of the constructor.

func (*Constructor) GetParameters

func (f *Constructor) GetParameters() []*Parameter

GetParameters returns the parameters of the constructor.

func (*Constructor) GetReturnStatements

func (f *Constructor) GetReturnStatements() []*Parameter

GetReturnStatements returns the return statements of the constructor.

func (*Constructor) GetSrc

func (f *Constructor) GetSrc() ast.SrcNode

GetSrc returns the source code location of the constructor.

func (*Constructor) GetStateMutability

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

GetStateMutability returns the state mutability of the constructor.

func (*Constructor) GetVisibility

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

GetVisibility returns the visibility of the constructor.

func (*Constructor) IsImplemented

func (f *Constructor) IsImplemented() bool

IsImplemented checks if the constructor is implemented.

func (*Constructor) IsVirtual

func (f *Constructor) IsVirtual() bool

IsVirtual checks if the constructor is virtual.

func (*Constructor) ToProto

func (f *Constructor) ToProto() *ir_pb.Constructor

ToProto converts the constructor to its protobuf representation.

type Contract

type Contract struct {
	Unit           *ast.SourceUnit[ast.Node[ast_pb.SourceUnit]] `json:"ast"`
	Id             int64                                        `json:"id"`
	SourceUnitId   int64                                        `json:"sourceUnitId"`
	NodeType       ast_pb.NodeType                              `json:"nodeType"`
	Kind           ast_pb.NodeType                              `json:"kind"`
	Name           string                                       `json:"name"`
	License        string                                       `json:"license"`
	Language       Language                                     `json:"language"`
	AbsolutePath   string                                       `json:"absolutePath"`
	Symbols        []*Symbol                                    `json:"symbols"`
	BaseContracts  []*ast.BaseContract                          `json:"baseContracts"`
	Imports        []*Import                                    `json:"imports"`
	Pragmas        []*Pragma                                    `json:"pragmas"`
	StateVariables []*StateVariable                             `json:"stateVariables"`
	Structs        []*Struct                                    `json:"structs"`
	Enums          []*Enum                                      `json:"enums"`
	Events         []*Event                                     `json:"events"`
	Errors         []*Error                                     `json:"errors"`
	Constructor    *Constructor                                 `json:"constructor,omitempty"`
	Functions      []*Function                                  `json:"functions"`
	Fallback       *Fallback                                    `json:"fallback,omitempty"`
	Receive        *Receive                                     `json:"receive,omitempty"`
}

Contract represents a contract in the Intermediate Representation (IR).

func (*Contract) GetAST

func (c *Contract) GetAST() *ast.SourceUnit[ast.Node[ast_pb.SourceUnit]]

GetAST returns the AST (Abstract Syntax Tree) for the contract.

func (*Contract) GetAbsolutePath

func (c *Contract) GetAbsolutePath() string

GetAbsolutePath returns the absolute path of the contract.

func (*Contract) GetBaseContracts added in v0.3.3

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

GetBaseContracts returns the base contracts of the contract.

func (*Contract) GetConstructor

func (c *Contract) GetConstructor() *Constructor

GetConstructor returns the constructor of the contract.

func (*Contract) GetEnums

func (c *Contract) GetEnums() []*Enum

GetEnums returns the enums of the contract.

func (*Contract) GetErrors

func (c *Contract) GetErrors() []*Error

GetErrors returns the errors of the contract.

func (*Contract) GetEvents

func (c *Contract) GetEvents() []*Event

GetEvents returns the events of the contract.

func (*Contract) GetFallback

func (c *Contract) GetFallback() *Fallback

GetFallback returns the fallback of the contract.

func (*Contract) GetFunctions

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

GetFunctions returns the functions of the contract.

func (*Contract) GetId

func (c *Contract) GetId() int64

GetId returns the ID of the contract.

func (*Contract) GetImports

func (c *Contract) GetImports() []*Import

GetImports returns the imports of the contract.

func (*Contract) GetKind

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

GetKind returns the kind of the contract.

func (*Contract) GetLanguage

func (c *Contract) GetLanguage() Language

GetLanguage returns the programming language of the contract.

func (*Contract) GetLicense

func (c *Contract) GetLicense() string

GetLicense returns the license of the contract.

func (*Contract) GetName

func (c *Contract) GetName() string

GetName returns the name of the contract.

func (*Contract) GetNodeType

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

GetNodeType returns the NodeType of the contract.

func (*Contract) GetPragmas

func (c *Contract) GetPragmas() []*Pragma

GetPragmas returns the pragmas of the contract.

func (*Contract) GetReceive

func (c *Contract) GetReceive() *Receive

GetReceive returns the receive of the contract.

func (*Contract) GetSourceUnitId

func (c *Contract) GetSourceUnitId() int64

GetSourceUnitId returns the source unit ID of the contract.

func (*Contract) GetSrc

func (c *Contract) GetSrc() ast.SrcNode

GetSrc returns the source node of the contract.

func (*Contract) GetStateVariables

func (c *Contract) GetStateVariables() []*StateVariable

GetStateVariables returns the state variables of the contract.

func (*Contract) GetStructs

func (c *Contract) GetStructs() []*Struct

GetStructs returns the structs of the contract.

func (*Contract) GetSymbols

func (c *Contract) GetSymbols() []*Symbol

GetSymbols returns the symbols of the contract.

func (*Contract) GetUnitSrc

func (c *Contract) GetUnitSrc() ast.SrcNode

GetUnitSrc returns the source node of the contract unit.

func (*Contract) ToProto

func (c *Contract) ToProto() *ir_pb.Contract

ToProto converts the Contract to its protobuf representation.

type ContractNode

type ContractNode interface {
	GetId() int64
	GetName() string
	GetType() ast_pb.NodeType
	GetKind() ast_pb.NodeType
	GetSrc() ast.SrcNode
	GetTypeDescription() *ast.TypeDescription
	GetNodes() []ast.Node[ast.NodeType]
	ToProto() ast.NodeType
	SetReferenceDescriptor(refId int64, refDesc *ast.TypeDescription) bool
	GetStateVariables() []*ast.StateVariableDeclaration
	GetStructs() []*ast.StructDefinition
	GetConstructor() *ast.Constructor
	GetFunctions() []*ast.Function
	GetFallback() *ast.Fallback
	GetReceive() *ast.Receive
	GetEnums() []*ast.EnumDefinition
	GetEvents() []*ast.EventDefinition
	GetErrors() []*ast.ErrorDefinition
}

ContractNode defines the interface for a contract node.

func GetContractByNodeType added in v0.3.5

func GetContractByNodeType(c ast.Node[ast.NodeType]) ContractNode

GetContractByNodeType returns the ContractNode based on the node type.

type Enum

type Enum struct {
	Unit          *ast.EnumDefinition `json:"ast"`
	Id            int64               `json:"id"`
	NodeType      ast_pb.NodeType     `json:"nodeType"`
	Name          string              `json:"name"`
	CanonicalName string              `json:"canonicalName"`
	Members       []*Parameter        `json:"members"`
}

Enum represents an enumeration in the IR.

func (*Enum) GetAST

func (e *Enum) GetAST() *ast.EnumDefinition

GetAST returns the AST (Abstract Syntax Tree) for the enum.

func (*Enum) GetCanonicalName

func (e *Enum) GetCanonicalName() string

GetCanonicalName returns the canonical name of the enum.

func (*Enum) GetId

func (e *Enum) GetId() int64

GetId returns the ID of the enum.

func (*Enum) GetMembers

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

GetMembers returns the members of the enum.

func (*Enum) GetName

func (e *Enum) GetName() string

GetName returns the name of the enum.

func (*Enum) GetNodeType

func (e *Enum) GetNodeType() ast_pb.NodeType

GetNodeType returns the NodeType of the enum.

func (*Enum) GetSrc

func (e *Enum) GetSrc() ast.SrcNode

GetSrc returns the source location of the enum.

func (*Enum) ToProto

func (e *Enum) ToProto() *ir_pb.Enum

ToProto converts the Enum to its protobuf representation.

type Error

type Error struct {
	Unit            *ast.ErrorDefinition `json:"ast"`
	Id              int64                `json:"id"`
	NodeType        ast_pb.NodeType      `json:"nodeType"`
	Name            string               `json:"name"`
	Parameters      []*Parameter         `json:"parameters"`
	TypeDescription *ast.TypeDescription `json:"type_description"`
}

Error represents an error definition in the IR.

func (*Error) GetAST

func (e *Error) GetAST() *ast.ErrorDefinition

GetAST returns the AST (Abstract Syntax Tree) for the error definition.

func (*Error) GetId

func (e *Error) GetId() int64

GetId returns the ID of the error definition.

func (*Error) GetName

func (e *Error) GetName() string

GetName returns the name of the error definition.

func (*Error) GetNodeType

func (e *Error) GetNodeType() ast_pb.NodeType

GetNodeType returns the NodeType of the error definition.

func (*Error) GetParameters

func (e *Error) GetParameters() []*Parameter

GetParameters returns the parameters of the error definition.

func (*Error) GetSrc

func (e *Error) GetSrc() ast.SrcNode

GetSrc returns the source location of the error definition.

func (*Error) GetTypeDescription

func (e *Error) GetTypeDescription() *ast.TypeDescription

GetTypeDescription returns the type description of the error definition.

func (*Error) ToProto

func (e *Error) ToProto() *ir_pb.Error

ToProto converts the Error to its protobuf representation.

type Event

type Event struct {
	Unit       *ast.EventDefinition `json:"ast"`
	Id         int64                `json:"id"`
	NodeType   ast_pb.NodeType      `json:"nodeType"`
	Name       string               `json:"name"`
	Anonymous  bool                 `json:"anonymous"`
	Parameters []*Parameter         `json:"parameters"`
}

Event represents an event definition in the IR.

func (*Event) GetAST

func (e *Event) GetAST() *ast.EventDefinition

GetAST returns the AST (Abstract Syntax Tree) for the event definition.

func (*Event) GetId

func (e *Event) GetId() int64

GetId returns the ID of the event definition.

func (*Event) GetName

func (e *Event) GetName() string

GetName returns the name of the event definition.

func (*Event) GetNodeType

func (e *Event) GetNodeType() ast_pb.NodeType

GetNodeType returns the NodeType of the event definition.

func (*Event) GetParameters

func (e *Event) GetParameters() []*Parameter

GetParameters returns the parameters of the event definition.

func (*Event) GetSignature added in v0.3.3

func (e *Event) GetSignature() common.Hash

GetSignature computes the Keccak-256 hash of the event signature to generate the 'topic0' hash. This method calls GetSignatureRaw to obtain the raw event signature string and then applies the Keccak-256 hash function to it. The resulting hash is commonly used in Ethereum as the identifier for the event in logs and is crucial for event tracking and decoding in smart contract interactions.

func (*Event) GetSignatureRaw added in v0.3.3

func (e *Event) GetSignatureRaw() string

GetSignatureRaw constructs the raw event signature string for the Event. It generates this signature by concatenating the event's name with a list of its parameters' types in their canonical form. The canonical form of each parameter type is obtained by using the canonicalizeType function. This method is particularly useful for creating a human-readable version of the event signature, which is essential for various Ethereum-related operations, such as logging and event filtering.

func (*Event) GetSrc

func (e *Event) GetSrc() ast.SrcNode

GetSrc returns the source location of the event definition.

func (*Event) IsAnonymous

func (e *Event) IsAnonymous() bool

IsAnonymous returns whether the event definition is anonymous.

func (*Event) ToProto

func (e *Event) ToProto() *ir_pb.Event

ToProto converts the Event to its protobuf representation.

type Expression

type Expression interface {
	GetId() int64
	GetType() ast_pb.NodeType
	GetName() string
	GetTypeDescription() *ast.TypeDescription
	GetReferencedDeclaration() int64
}

Expression is an interface that abstracts operations on expression-like AST nodes. It is useful in ensuring consistent interaction with different expression nodes.

type Fallback

type Fallback struct {
	Unit             *ast.Fallback     `json:"ast"`
	Id               int64             `json:"id"`
	NodeType         ast_pb.NodeType   `json:"nodeType"`
	Name             string            `json:"name"`
	Kind             ast_pb.NodeType   `json:"kind"`
	Implemented      bool              `json:"implemented"`
	Visibility       ast_pb.Visibility `json:"visibility"`
	StateMutability  ast_pb.Mutability `json:"stateMutability"`
	Virtual          bool              `json:"virtual"`
	Modifiers        []*Modifier       `json:"modifiers"`
	Overrides        []*Override       `json:"overrides"`
	Parameters       []*Parameter      `json:"parameters"`
	ReturnStatements []*Parameter      `json:"return"`
}

Fallback represents a fallback function definition in the IR.

func (*Fallback) GetAST

func (f *Fallback) GetAST() *ast.Fallback

GetAST returns the AST (Abstract Syntax Tree) for the fallback function definition.

func (*Fallback) GetId

func (f *Fallback) GetId() int64

GetId returns the ID of the fallback function definition.

func (*Fallback) GetKind

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

GetKind returns the kind of the fallback function definition.

func (*Fallback) GetModifiers

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

GetModifiers returns the modifiers applied to the fallback function.

func (*Fallback) GetName

func (f *Fallback) GetName() string

GetName returns the name of the fallback function definition.

func (*Fallback) GetNodeType

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

GetNodeType returns the NodeType of the fallback function definition.

func (*Fallback) GetOverrides

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

GetOverrides returns the overrides applied to the fallback function.

func (*Fallback) GetParameters

func (f *Fallback) GetParameters() []*Parameter

GetParameters returns the parameters of the fallback function.

func (*Fallback) GetReturnStatements

func (f *Fallback) GetReturnStatements() []*Parameter

GetReturnStatements returns the return statements of the fallback function.

func (*Fallback) GetSrc

func (f *Fallback) GetSrc() ast.SrcNode

GetSrc returns the source code location of the fallback function.

func (*Fallback) GetStateMutability

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

GetStateMutability returns the state mutability of the fallback function.

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 whether the fallback function is implemented.

func (*Fallback) IsVirtual

func (f *Fallback) IsVirtual() bool

IsVirtual returns whether the fallback function is virtual.

func (*Fallback) ToProto

func (f *Fallback) ToProto() *ir_pb.Fallback

ToProto converts the Fallback to its protobuf representation.

type Function

type Function struct {
	Unit                    *ast.Function     `json:"ast"`
	Id                      int64             `json:"id"`
	NodeType                ast_pb.NodeType   `json:"nodeType"`
	Kind                    ast_pb.NodeType   `json:"kind"`
	Name                    string            `json:"name"`
	Implemented             bool              `json:"implemented"`
	Visibility              ast_pb.Visibility `json:"visibility"`
	StateMutability         ast_pb.Mutability `json:"stateMutability"`
	Virtual                 bool              `json:"virtual"`
	ReferencedDeclarationId int64             `json:"referencedDeclarationId"`
	Signature               string            `json:"signature"`
	Modifiers               []*Modifier       `json:"modifiers"`
	Overrides               []*Override       `json:"overrides"`
	Parameters              []*Parameter      `json:"parameters"`
	Body                    *Body             `json:"body"`
	ReturnStatements        []*Parameter      `json:"return"`
	Src                     ast.SrcNode       `json:"src"`
}

Function represents a function declaration in the IR.

func (*Function) GetAST

func (f *Function) GetAST() *ast.Function

GetAST returns the AST (Abstract Syntax Tree) for the function declaration.

func (*Function) GetBody

func (f *Function) GetBody() *Body

GetBody returns the body of the function.

func (*Function) GetId

func (f *Function) GetId() int64

GetId returns the ID of the function declaration.

func (*Function) GetKind

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

GetKind returns the kind of the function declaration.

func (*Function) GetModifiers

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

GetModifiers returns the modifiers of the function.

func (*Function) GetName

func (f *Function) GetName() string

GetName returns the name of the function declaration.

func (*Function) GetNodeType

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

GetNodeType returns the NodeType of the function declaration.

func (*Function) GetOverrides

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

GetOverrides returns the overrides of the function.

func (*Function) GetParameters

func (f *Function) GetParameters() []*Parameter

GetParameters returns the parameters of the function.

func (*Function) GetReferencedDeclarationId

func (f *Function) GetReferencedDeclarationId() int64

GetReferencedDeclarationId returns the referenced declaration id of the function.

func (*Function) GetReturnStatements

func (f *Function) GetReturnStatements() []*Parameter

GetReturnStatements returns the return statements of the function.

func (*Function) GetSignature added in v0.3.1

func (f *Function) GetSignature() string

GetSignature returns the keccak signature of the function.

func (*Function) GetSrc

func (f *Function) GetSrc() ast.SrcNode

GetSrc returns the source code of the function.

func (*Function) GetStateMutability

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

GetStateMutability returns the state mutability of the function.

func (*Function) GetVisibility

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

GetVisibility returns the visibility of the function.

func (*Function) IsImplemented

func (f *Function) IsImplemented() bool

IsImplemented returns whether the function is implemented or not.

func (*Function) IsVirtual

func (f *Function) IsVirtual() bool

IsVirtual returns whether the function is virtual or not.

func (*Function) ToProto

func (f *Function) ToProto() *ir_pb.Function

ToProto returns the protocol buffer version of the function.

type FunctionCall

type FunctionCall struct {
	Unit *ast.FunctionCall `json:"-"`

	Id                      int64                     `json:"id"`
	NodeType                ast_pb.NodeType           `json:"nodeType"`
	Kind                    ast_pb.NodeType           `json:"kind"`
	Name                    string                    `json:"name"`
	ArgumentTypes           []*ast_pb.TypeDescription `json:"argumentTypes"`
	External                bool                      `json:"external"`
	ExternalContractId      int64                     `json:"externalContractId"`
	ExternalContractName    string                    `json:"externalContractName,omitempty"`
	ReferenceStatementId    int64                     `json:"referenceStatementId"`
	ReferencedDeclarationId int64                     `json:"referencedDeclarationId"`
	TypeDescription         *ast_pb.TypeDescription   `json:"typeDescription"`
	// contains filtered or unexported fields
}

FunctionCall represents a function call statement in the IR.

func (*FunctionCall) GetAST

func (e *FunctionCall) GetAST() *ast.FunctionCall

GetAST returns the AST (Abstract Syntax Tree) for the function call statement.

func (*FunctionCall) GetArgumentTypes

func (e *FunctionCall) GetArgumentTypes() []*ast_pb.TypeDescription

GetArgumentTypes returns the argument types of the function call statement.

func (*FunctionCall) GetExternalContract

func (e *FunctionCall) GetExternalContract() ContractNode

GetExternalSourceUnit returns the external contract of the function call statement.

func (*FunctionCall) GetExternalContractId

func (e *FunctionCall) GetExternalContractId() int64

GetExternalContractId returns the external contract id of the function call statement.

func (*FunctionCall) GetExternalContractName

func (e *FunctionCall) GetExternalContractName() string

GetExternalContractName returns the external contract name of the function call statement.

func (*FunctionCall) GetId

func (e *FunctionCall) GetId() int64

GetId returns the ID of the function call statement.

func (*FunctionCall) GetKind

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

GetKind returns the kind of the function call statement.

func (*FunctionCall) GetName

func (e *FunctionCall) GetName() string

GetName returns the name of the function call statement.

func (*FunctionCall) GetNodeType

func (e *FunctionCall) GetNodeType() ast_pb.NodeType

GetNodeType returns the NodeType of the function call statement.

func (*FunctionCall) GetNodes

func (e *FunctionCall) GetNodes() []Statement

GetNodes returns the nodes of the statement.

func (*FunctionCall) GetReferenceStatement

func (e *FunctionCall) GetReferenceStatement() *Function

GetReferenceStatement returns the reference statement of the function call statement.

func (*FunctionCall) GetReferenceStatementId

func (e *FunctionCall) GetReferenceStatementId() int64

GetReferenceStatementId returns the reference statement id of the function call statement.

func (*FunctionCall) GetReferencedDeclarationId

func (e *FunctionCall) GetReferencedDeclarationId() int64

GetReferencedDeclarationId returns the referenced declaration id of the function call statement.

func (*FunctionCall) GetSrc

func (e *FunctionCall) GetSrc() ast.SrcNode

GetSrc returns the source location of the function call statement.

func (*FunctionCall) GetTypeDescription

func (e *FunctionCall) GetTypeDescription() *ast_pb.TypeDescription

GetTypeDescription returns the type description of the function call statement.

func (*FunctionCall) IsExternal

func (e *FunctionCall) IsExternal() bool

IsExternal returns if the function call is an external contract call.

func (*FunctionCall) ToProto

func (e *FunctionCall) ToProto() *v3.TypedStruct

ToProto returns the protocol buffer version of the function call statement.

type Import

type Import struct {
	Unit         *ast.Import     `json:"ast"`
	Id           int64           `json:"id"`
	NodeType     ast_pb.NodeType `json:"nodeType"`
	AbsolutePath string          `json:"absolutePath"`
	File         string          `json:"file"`
	UnitAlias    string          `json:"unitAlias"`
	SourceUnitId int64           `json:"sourceUnitId"`
	ContractId   int64           `json:"contractId"`
	Contract     *Contract       `json:"contract"`
}

Import represents an import statement in the IR.

func (*Import) GetAST

func (i *Import) GetAST() *ast.Import

GetAST returns the AST (Abstract Syntax Tree) for the import statement.

func (*Import) GetAbsolutePath

func (i *Import) GetAbsolutePath() string

GetAbsolutePath returns the absolute path of the imported file.

func (*Import) GetContractId

func (i *Import) GetContractId() int64

GetContractId returns the ID of the contract associated with the source unit.

func (*Import) GetFile

func (i *Import) GetFile() string

GetFile returns the file name of the imported file.

func (*Import) GetId

func (i *Import) GetId() int64

GetId returns the unique identifier of the import statement.

func (*Import) GetNodeType

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

GetNodeType returns the type of the node in the AST.

func (*Import) GetSourceUnitId

func (i *Import) GetSourceUnitId() int64

GetSourceUnitId returns the ID of the source unit where the import statement is used.

func (*Import) GetUnitAlias

func (i *Import) GetUnitAlias() string

GetUnitAlias returns the alias used for the imported unit.

func (*Import) ToProto

func (i *Import) ToProto() *ir_pb.Import

ToProto returns the protocol buffer version of the import statement.

type Language

type Language string

Language represents a programming language.

const (
	LanguageSolidity Language = "solidity"
	LanguageVyper    Language = "vyper"
)

Constants representing different programming languages.

func (Language) String

func (l Language) String() string

String returns the string representation of the Language.

type Link struct {
	Location string `json:"location"`  // The actual URL or link location.
	Social   bool   `json:"is_social"` // Indicates if the link is from a social media/network.
	Network  string `json:"network"`   // Represents the network or platform of the link.
}

Link represents a link extracted from a comment.

func (*Link) GetLocation added in v0.3.1

func (l *Link) GetLocation() string

GetLocation returns the link's location.

func (*Link) GetNetwork added in v0.3.1

func (l *Link) GetNetwork() string

GetNetwork returns the network or platform of the link.

func (*Link) IsSocial added in v0.3.1

func (l *Link) IsSocial() bool

IsSocial returns true if the link is from a social media/network.

type Modifier

type Modifier struct {
	Unit          *ast.ModifierInvocation `json:"ast"`
	Id            int64                   `json:"id"`
	NodeType      ast_pb.NodeType         `json:"nodeType"`
	Name          string                  `json:"name"`
	ArgumentTypes []*ast.TypeDescription  `json:"argumentTypes"`
}

Modifier represents a Modifier in the Abstract Syntax Tree.

func (*Modifier) GetAST

func (m *Modifier) GetAST() *ast.ModifierInvocation

GetAST returns the underlying AST node for the Modifier.

func (*Modifier) GetArgumentTypes

func (m *Modifier) GetArgumentTypes() []*ast.TypeDescription

GetArgumentTypes returns the argument types of the Modifier.

func (*Modifier) GetId

func (m *Modifier) GetId() int64

GetId returns the ID of the Modifier.

func (*Modifier) GetName

func (m *Modifier) GetName() string

GetName returns the name of the Modifier.

func (*Modifier) GetNodeType

func (m *Modifier) GetNodeType() ast_pb.NodeType

GetNodeType returns the AST node type of the Modifier.

func (*Modifier) GetSrc

func (m *Modifier) GetSrc() ast.SrcNode

GetSrc returns the source code location for the Modifier.

func (*Modifier) ToProto

func (m *Modifier) ToProto() *ir_pb.Modifier

ToProto converts the Modifier to its corresponding protobuf representation.

type Override

type Override struct {
	Unit                    *ast.OverrideSpecifier `json:"ast"`
	Id                      int64                  `json:"id"`
	NodeType                ast_pb.NodeType        `json:"nodeType"`
	Name                    string                 `json:"name"`
	ReferencedDeclarationId int64                  `json:"referencedDeclarationId"`
	TypeDescription         *ast.TypeDescription   `json:"typeDescription"`
}

Override represents an Override in the Abstract Syntax Tree.

func (*Override) GetAST

func (m *Override) GetAST() *ast.OverrideSpecifier

GetAST returns the underlying AST node for the Override.

func (*Override) GetId

func (m *Override) GetId() int64

GetId returns the ID of the Override.

func (*Override) GetName

func (m *Override) GetName() string

GetName returns the name of the Override.

func (*Override) GetNodeType

func (m *Override) GetNodeType() ast_pb.NodeType

GetNodeType returns the AST node type of the Override.

func (*Override) GetReferencedDeclarationId

func (m *Override) GetReferencedDeclarationId() int64

GetReferencedDeclarationId returns the ID of the referenced declaration for the Override.

func (*Override) GetSrc

func (m *Override) GetSrc() ast.SrcNode

GetSrc returns the source node of the Override.

func (*Override) GetTypeDescription

func (m *Override) GetTypeDescription() *ast.TypeDescription

GetTypeDescription returns the type description of the Override.

func (*Override) ToProto

func (m *Override) ToProto() *ir_pb.Override

ToProto converts the Override to its corresponding protobuf representation.

type Parameter

type Parameter struct {
	Unit            *ast.Parameter       `json:"ast"`
	Id              int64                `json:"id"`
	NodeType        ast_pb.NodeType      `json:"nodeType"`
	Name            string               `json:"name"`
	Type            string               `json:"type"`
	TypeDescription *ast.TypeDescription `json:"typeDescription"`
	Indexed         bool                 `json:"indexed"`
}

Parameter represents a Parameter in the Abstract Syntax Tree.

func (*Parameter) GetAST

func (p *Parameter) GetAST() *ast.Parameter

GetAST returns the underlying AST node for the Parameter.

func (*Parameter) GetId

func (p *Parameter) GetId() int64

GetId returns the ID of the Parameter.

func (*Parameter) GetName

func (p *Parameter) GetName() string

GetName returns the name of the Parameter.

func (*Parameter) GetNodeType

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

GetNodeType returns the AST node type of the Parameter.

func (*Parameter) GetSrc

func (p *Parameter) GetSrc() ast.SrcNode

GetSrc returns the source code location for the Parameter.

func (*Parameter) GetType

func (p *Parameter) GetType() string

GetType returns the type of the Parameter.

func (*Parameter) GetTypeDescription

func (p *Parameter) GetTypeDescription() *ast.TypeDescription

GetTypeDescription returns the type description of the Parameter.

func (*Parameter) IsIndexed

func (p *Parameter) IsIndexed() bool

IsIndexed returns whether the Parameter is indexed.

func (*Parameter) ToProto

func (p *Parameter) ToProto() *ir_pb.Parameter

ToProto converts the Parameter to its corresponding protobuf representation.

type Pragma

type Pragma struct {
	Unit     *ast.Pragma     `json:"ast"`
	Id       int64           `json:"id"`
	NodeType ast_pb.NodeType `json:"nodeType"`
	Literals []string        `json:"literals"`
	Text     string          `json:"text"`
}

Pragma represents a Pragma in the Abstract Syntax Tree.

func (*Pragma) GetAST

func (p *Pragma) GetAST() *ast.Pragma

GetAST returns the underlying AST node for the Pragma.

func (*Pragma) GetId

func (p *Pragma) GetId() int64

GetId returns the ID of the Pragma.

func (*Pragma) GetLiterals

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

GetLiterals returns the literals associated with the Pragma.

func (*Pragma) GetNodeType

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

GetNodeType returns the AST node type of the Pragma.

func (*Pragma) GetSrc

func (p *Pragma) GetSrc() ast.SrcNode

GetSrc returns the source code location associated with the Pragma.

func (*Pragma) GetText

func (p *Pragma) GetText() string

GetText returns the text of the Pragma.

func (*Pragma) GetVersion

func (p *Pragma) GetVersion() string

GetVersion extracts and returns the version information from the Pragma text.

func (*Pragma) ToProto

func (p *Pragma) ToProto() *ir_pb.Pragma

ToProto converts the Pragma to its corresponding protobuf representation.

type Receive

type Receive struct {
	Unit            *ast.Receive      `json:"ast"`
	Id              int64             `json:"id"`              // Id is the unique identifier of the receive function.
	NodeType        ast_pb.NodeType   `json:"nodeType"`        // NodeType is the type of the receive function node in the AST.
	Name            string            `json:"name"`            // Name is the name of the receive function (always "receive" for Solidity receive functions).
	Kind            ast_pb.NodeType   `json:"kind"`            // Kind is the kind of the receive function node (e.g., FunctionDefinition, FunctionType).
	Implemented     bool              `json:"implemented"`     // Implemented is true if the receive function is implemented in the contract, false otherwise.
	Visibility      ast_pb.Visibility `json:"visibility"`      // Visibility represents the visibility of the receive function (e.g., public, private, internal, external).
	StateMutability ast_pb.Mutability `json:"stateMutability"` // StateMutability represents the mutability of the receive function (e.g., pure, view, nonpayable, payable).
	Virtual         bool              `json:"virtual"`         // Virtual is true if the receive function is virtual, false otherwise.
	Modifiers       []*Modifier       `json:"modifiers"`       // Modifiers is a list of modifiers applied to the receive function.
	Overrides       []*Override       `json:"overrides"`       // Overrides is a list of functions overridden by the receive function.
	Parameters      []*Parameter      `json:"parameters"`      // Parameters is a list of parameters of the receive function.
}

Receive represents a receive function in the Intermediate Representation (IR) of Solidity contracts' Abstract Syntax Tree (AST).

func (*Receive) GetAST

func (f *Receive) GetAST() *ast.Receive

GetAST returns the underlying AST node of the receive function.

func (*Receive) GetId

func (f *Receive) GetId() int64

GetId returns the unique identifier of the receive function.

func (*Receive) GetKind

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

GetKind returns the kind of the receive function node (e.g., FunctionDefinition, FunctionType).

func (*Receive) GetModifiers

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

GetModifiers returns a list of modifiers applied to the receive function.

func (*Receive) GetName

func (f *Receive) GetName() string

GetName returns the name of the receive function (always "receive" for Solidity receive functions).

func (*Receive) GetNodeType

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

GetNodeType returns the type of the receive function node in the AST.

func (*Receive) GetOverrides

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

GetOverrides returns a list of functions overridden by the receive function.

func (*Receive) GetParameters

func (f *Receive) GetParameters() []*Parameter

GetParameters returns a list of parameters of the receive function.

func (*Receive) GetSrc

func (f *Receive) GetSrc() ast.SrcNode

GetSrc returns the source code location of the receive function.

func (*Receive) GetStateMutability

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

GetStateMutability returns the mutability of the receive function (e.g., pure, view, nonpayable, payable).

func (*Receive) GetVisibility

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

GetVisibility returns the visibility of the receive function (e.g., public, private, internal, external).

func (*Receive) IsImplemented

func (f *Receive) IsImplemented() bool

IsImplemented returns true if the receive function is implemented in the contract, false otherwise.

func (*Receive) IsVirtual

func (f *Receive) IsVirtual() bool

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

func (*Receive) ToProto

func (f *Receive) ToProto() *ir_pb.Receive

ToProto is a function that converts the Receive to a protobuf message.

type RootSourceUnit

type RootSourceUnit struct {
	Unit              *ast.RootNode   `json:"ast"`
	NodeType          ast_pb.NodeType `json:"nodeType"`
	Address           common.Address  `json:"address"`
	EntryContractId   int64           `json:"entryContractId"`
	EntryContractName string          `json:"entryContractName"`
	ContractsCount    int32           `json:"contractsCount"`
	ContractTypes     []string        `json:"contractTypes"`
	Standards         []*Standard     `json:"standards"`
	Contracts         []*Contract     `json:"contracts"`
	Links             []*Link         `json:"links"`
	// contains filtered or unexported fields
}

RootSourceUnit represents the root of a Solidity contract's AST as an IR node.

func (*RootSourceUnit) GetAST

func (r *RootSourceUnit) GetAST() *ast.RootNode

GetAST returns the underlying AST node of the RootSourceUnit.

func (*RootSourceUnit) GetContractById

func (r *RootSourceUnit) GetContractById(id int64) *Contract

GetContractById returns the contract with the given ID from the IR. If no contract with the given ID is found, it returns nil.

func (*RootSourceUnit) GetContractByName

func (r *RootSourceUnit) GetContractByName(name string) *Contract

GetContractByName returns the contract with the given name from the IR. If no contract with the given name is found, it returns nil.

func (*RootSourceUnit) GetContractBySourceUnitId added in v0.3.3

func (r *RootSourceUnit) GetContractBySourceUnitId(id int64) *Contract

GetContractBySourceUnitId returns the contract with the given source unit ID from the IR.

func (*RootSourceUnit) GetContractTypes

func (r *RootSourceUnit) GetContractTypes() []string

GetContractTypes returns the list of contract types.

func (*RootSourceUnit) GetContracts

func (r *RootSourceUnit) GetContracts() []*Contract

GetContracts returns the list of contracts in the IR.

func (*RootSourceUnit) GetContractsCount

func (r *RootSourceUnit) GetContractsCount() int32

GetContractsCount returns the count of contracts in the AST.

func (*RootSourceUnit) GetContractsCountByKind added in v0.3.1

func (r *RootSourceUnit) GetContractsCountByKind(kind ast_pb.NodeType) int64

GetContractsCountByKind returns the count of contracts in the AST by the given kind.

func (*RootSourceUnit) GetEntryContract

func (r *RootSourceUnit) GetEntryContract() *Contract

GetEntryContract returns the entry contract from the IR.

func (*RootSourceUnit) GetEntryId

func (r *RootSourceUnit) GetEntryId() int64

GetEntryId returns the entry contract ID.

func (*RootSourceUnit) GetEntryName

func (r *RootSourceUnit) GetEntryName() string

GetEntryName returns the entry contract name.

func (r *RootSourceUnit) GetLinks() []*Link

GetLinks returns the list of links discovered in the AST comments.

func (*RootSourceUnit) GetNodeType

func (r *RootSourceUnit) GetNodeType() ast_pb.NodeType

GetNodeType returns the type of the node in the AST.

func (*RootSourceUnit) GetStandard added in v0.3.3

func (r *RootSourceUnit) GetStandard(standard standards.Standard) *Standard

GetStandard returns the EIP with the given type.

func (*RootSourceUnit) GetStandards

func (r *RootSourceUnit) GetStandards() []*Standard

GetStandards returns the EIPs discovered for any contract in the source units.

func (*RootSourceUnit) HasContractType

func (r *RootSourceUnit) HasContractType(ctype string) bool

HasContractType returns the list of contract types.

func (*RootSourceUnit) HasContracts

func (r *RootSourceUnit) HasContracts() bool

HasContracts returns true if the AST has one or more contracts, false otherwise.

func (*RootSourceUnit) HasHighConfidenceStandard added in v0.3.3

func (r *RootSourceUnit) HasHighConfidenceStandard(standard standards.Standard) bool

HasHighConfidenceStandard returns true if high standard is already registered false otherwise.

func (*RootSourceUnit) HasPerfectConfidenceStandard added in v0.3.3

func (r *RootSourceUnit) HasPerfectConfidenceStandard(standard standards.Standard) bool

HasPerfectConfidenceStandard returns true if perfect standard is already registered false otherwise.

func (*RootSourceUnit) HasStandard

func (r *RootSourceUnit) HasStandard(standard standards.Standard) bool

HasStandard returns true if standard is already registered false otherwise.

func (*RootSourceUnit) IsEntryContract added in v0.3.3

func (r *RootSourceUnit) IsEntryContract(contract *Contract) bool

IsEntryContract checks if provided contract is root unit entry contract

func (*RootSourceUnit) SetContractType

func (r *RootSourceUnit) SetContractType(standard standards.Standard)

SetContractType sets the contract type for the given standard.

func (*RootSourceUnit) ToProto

func (r *RootSourceUnit) ToProto() *ir_pb.Root

ToProto is a placeholder function for converting the RootSourceUnit to a protobuf message.

func (*RootSourceUnit) Walk added in v0.3.3

func (r *RootSourceUnit) Walk(nodeVisitor *ast.NodeVisitor) error

Walk iterates through the AST (Abstract Syntax Tree) of a RootSourceUnit, applying the provided NodeVisitor to each node. This function facilitates traversal of the AST, allowing for operations such as analysis, modification, or inspection to be performed on each node.

type Standard

type Standard struct {
	// ContractId is the unique identifier for the contract.
	ContractId int64 `json:"contract_id"`

	// ContractName is the name of the contract.
	ContractName string `json:"contract_name"`

	// Confidence represents the confidence level of the contract adhering to a specific EIP standard.
	Confidence standards.Discovery `json:"confidences"`

	// Standard provides details about the specific EIP standard.
	Standard standards.ContractStandard `json:"standards"`
}

Standard represents a specific Ethereum Improvement Proposal standard that a contract may adhere to.

func (*Standard) GetConfidence

func (e *Standard) GetConfidence() standards.Discovery

GetConfidence returns the confidence level of the contract adhering to a specific EIP standard.

func (*Standard) GetContractId

func (e *Standard) GetContractId() int64

GetContractId returns the unique identifier for the contract.

func (*Standard) GetContractName

func (e *Standard) GetContractName() string

GetContractName returns the name of the contract.

func (*Standard) GetStandard

func (e *Standard) GetStandard() standards.ContractStandard

GetStandard returns the EIP standard.

func (*Standard) ToProto

func (e *Standard) ToProto() *ir_pb.EIP

ToProto converts the EIP to its protobuf representation.

type StateVariable

type StateVariable struct {
	Unit            *ast.StateVariableDeclaration `json:"ast"`
	Id              int64                         `json:"id"`              // Id is the unique identifier of the state variable.
	ContractId      int64                         `json:"contractId"`      // ContractId is the unique identifier of the contract containing the state variable.
	Name            string                        `json:"name"`            // Name is the name of the state variable.
	NodeType        ast_pb.NodeType               `json:"nodeType"`        // NodeType is the type of the state variable node in the AST.
	Visibility      ast_pb.Visibility             `json:"visibility"`      // Visibility represents the visibility of the state variable (e.g., public, private, internal, external).
	Constant        bool                          `json:"isConstant"`      // Constant is true if the state variable is constant, false otherwise.
	StorageLocation ast_pb.StorageLocation        `json:"storageLocation"` // StorageLocation represents the storage location of the state variable.
	StateMutability ast_pb.Mutability             `json:"stateMutability"` // StateMutability represents the mutability of the state variable (e.g., pure, view, nonpayable, payable).
	Type            string                        `json:"type"`            // Type is the type of the state variable.
	TypeDescription *ast.TypeDescription          `json:"typeDescription"` // TypeDescription is the description of the type of the state variable.
}

StateVariable represents a state variable in the Intermediate Representation (IR) of Solidity contracts' Abstract Syntax Tree (AST).

func (*StateVariable) GetAST

GetAST returns the underlying AST node of the state variable.

func (*StateVariable) GetContractId

func (v *StateVariable) GetContractId() int64

GetContractId returns the unique identifier of the contract containing the state variable.

func (*StateVariable) GetId

func (v *StateVariable) GetId() int64

GetId returns the unique identifier of the state variable.

func (*StateVariable) GetName

func (v *StateVariable) GetName() string

GetName returns the name of the state variable.

func (*StateVariable) GetNodeType

func (v *StateVariable) GetNodeType() ast_pb.NodeType

GetNodeType returns the type of the state variable node in the AST.

func (*StateVariable) GetSrc

func (v *StateVariable) GetSrc() ast.SrcNode

GetSrc returns the source node of the state variable.

func (*StateVariable) GetStateMutability

func (v *StateVariable) GetStateMutability() ast_pb.Mutability

GetStateMutability returns the mutability of the state variable (e.g., pure, view, nonpayable, payable).

func (*StateVariable) GetStorageLocation

func (v *StateVariable) GetStorageLocation() ast_pb.StorageLocation

GetStorageLocation returns the storage location of the state variable.

func (*StateVariable) GetStorageSize added in v0.3.3

func (v *StateVariable) GetStorageSize() (int64, bool)

func (*StateVariable) GetType

func (v *StateVariable) GetType() string

GetType returns the type of the state variable.

func (*StateVariable) GetTypeDescription

func (v *StateVariable) GetTypeDescription() *ast.TypeDescription

GetTypeDescription returns the description of the type of the state variable.

func (*StateVariable) GetVisibility

func (v *StateVariable) GetVisibility() ast_pb.Visibility

GetVisibility returns the visibility of the state variable (e.g., public, private, internal, external).

func (*StateVariable) IsConstant

func (v *StateVariable) IsConstant() bool

IsConstant returns true if the state variable is constant, false otherwise.

func (*StateVariable) ToProto

func (v *StateVariable) ToProto() *ir_pb.StateVariable

ToProto is a function that converts the StateVariable to a protobuf message.

type Statement

type Statement interface {
	GetId() int64
	GetNodeType() ast_pb.NodeType
	GetKind() ast_pb.NodeType
	GetTypeDescription() *ast_pb.TypeDescription
	GetNodes() []Statement
	ToProto() *v3.TypedStruct
}

Statement is an interface that defines common methods for all statement-like AST nodes. It ensures consistency in extracting information from different node types.

type Struct

type Struct struct {
	Unit                    *ast.StructDefinition  `json:"ast"`
	Id                      int64                  `json:"id"`
	NodeType                ast_pb.NodeType        `json:"nodeType"`
	Name                    string                 `json:"name"`
	CanonicalName           string                 `json:"canonicalName"`
	ReferencedDeclarationId int64                  `json:"referencedDeclarationId"`
	Visibility              ast_pb.Visibility      `json:"visibility"`
	StorageLocation         ast_pb.StorageLocation `json:"storageLocation"`
	Members                 []*Parameter           `json:"members"`
	Type                    string                 `json:"type"`
	TypeDescription         *ast.TypeDescription   `json:"typeDescription"`
}

Struct represents a Solidity struct definition as an IR node.

func (*Struct) GetAST

func (f *Struct) GetAST() *ast.StructDefinition

GetAST returns the underlying AST node of the Struct.

func (*Struct) GetCanonicalName

func (f *Struct) GetCanonicalName() string

GetCanonicalName returns the canonical name of the struct.

func (*Struct) GetId

func (f *Struct) GetId() int64

GetId returns the unique identifier of the struct.

func (*Struct) GetMembers

func (f *Struct) GetMembers() []*Parameter

GetMembers returns the list of members (parameters) in the struct.

func (*Struct) GetName

func (f *Struct) GetName() string

GetName returns the name of the struct.

func (*Struct) GetNodeType

func (f *Struct) GetNodeType() ast_pb.NodeType

GetNodeType returns the type of the node in the AST.

func (*Struct) GetReferencedDeclarationId

func (f *Struct) GetReferencedDeclarationId() int64

GetReferencedDeclarationId returns the referenced declaration ID of the struct.

func (*Struct) GetSrc

func (f *Struct) GetSrc() ast.SrcNode

GetSrc returns the source node of the struct.

func (*Struct) GetStorageLocation

func (f *Struct) GetStorageLocation() ast_pb.StorageLocation

GetStorageLocation returns the storage location of the struct.

func (*Struct) GetType

func (f *Struct) GetType() string

GetType returns the type of the struct.

func (*Struct) GetTypeDescription

func (f *Struct) GetTypeDescription() *ast.TypeDescription

GetTypeDescription returns the type description of the struct.

func (*Struct) GetVisibility

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

GetVisibility returns the visibility of the struct.

func (*Struct) ToProto

func (f *Struct) ToProto() *ir_pb.Struct

ToProto is a placeholder function for converting the Struct to a protobuf message.

type Symbol

type Symbol struct {
	Id           int64  `json:"id"`            // Id is the unique identifier of the symbol.
	Name         string `json:"name"`          // Name is the name of the symbol.
	AbsolutePath string `json:"absolute_path"` // AbsolutePath is the absolute path of the symbol.
}

Symbol represents a symbol in the Intermediate Representation (IR) of Solidity contracts' Abstract Syntax Tree (AST).

func (*Symbol) GetAbsolutePath

func (s *Symbol) GetAbsolutePath() string

GetAbsolutePath returns the absolute path of 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.

func (*Symbol) ToProto

func (s *Symbol) ToProto() *ir_pb.Symbol

ToProto is a function that converts the Symbol to a protobuf message.

Jump to

Keyboard shortcuts

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