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 ¶
- func NewTypedStruct(m protoreflect.ProtoMessage, protoType string) *v3.TypedStruct
- type Body
- func (e *Body) GetAST() *ast.BodyNode
- func (e *Body) GetId() int64
- func (e *Body) GetKind() ast_pb.NodeType
- func (e *Body) GetNodeType() ast_pb.NodeType
- func (e *Body) GetNodes() []Statement
- func (e *Body) GetSrc() ast.SrcNode
- func (e *Body) GetStatements() []Statement
- func (e *Body) ToProto() *ir_pb.Body
- type Builder
- func (b *Builder) Build() error
- func (b *Builder) GetAddress() common.Address
- func (b *Builder) GetAstBuilder() *ast.ASTBuilder
- func (b *Builder) GetParser() *solgo.Parser
- func (b *Builder) GetRoot() *RootSourceUnit
- func (b *Builder) GetSources() *solgo.Sources
- func (b *Builder) LookupReferencedFunctionsByNode(nodes ast.Node[ast.NodeType]) []*Function
- func (b *Builder) Parse() (errs []error)
- func (b *Builder) SetAddress(address common.Address)
- func (b *Builder) ToJSON() ([]byte, error)
- func (b *Builder) ToJSONPretty() ([]byte, error)
- func (b *Builder) ToProto() *ir_pb.Root
- func (b *Builder) ToProtoPretty() ([]byte, error)
- type Constructor
- func (f *Constructor) GetAST() *ast.Constructor
- func (f *Constructor) GetId() int64
- func (f *Constructor) GetKind() ast_pb.NodeType
- func (f *Constructor) GetModifiers() []*Modifier
- func (f *Constructor) GetName() string
- func (f *Constructor) GetNodeType() ast_pb.NodeType
- func (f *Constructor) GetParameters() []*Parameter
- func (f *Constructor) GetReturnStatements() []*Parameter
- func (f *Constructor) GetSrc() ast.SrcNode
- func (f *Constructor) GetStateMutability() ast_pb.Mutability
- func (f *Constructor) GetVisibility() ast_pb.Visibility
- func (f *Constructor) IsImplemented() bool
- func (f *Constructor) IsVirtual() bool
- func (f *Constructor) ToProto() *ir_pb.Constructor
- type Contract
- func (c *Contract) GetAST() *ast.SourceUnit[ast.Node[ast_pb.SourceUnit]]
- func (c *Contract) GetAbsolutePath() string
- func (c *Contract) GetBaseContracts() []*ast.BaseContract
- func (c *Contract) GetConstructor() *Constructor
- func (c *Contract) GetEnums() []*Enum
- func (c *Contract) GetErrors() []*Error
- func (c *Contract) GetEvents() []*Event
- func (c *Contract) GetFallback() *Fallback
- func (c *Contract) GetFunctions() []*Function
- func (c *Contract) GetId() int64
- func (c *Contract) GetImports() []*Import
- func (c *Contract) GetKind() ast_pb.NodeType
- func (c *Contract) GetLanguage() Language
- func (c *Contract) GetLicense() string
- func (c *Contract) GetName() string
- func (c *Contract) GetNodeType() ast_pb.NodeType
- func (c *Contract) GetPragmas() []*Pragma
- func (c *Contract) GetReceive() *Receive
- func (c *Contract) GetSourceUnitId() int64
- func (c *Contract) GetSrc() ast.SrcNode
- func (c *Contract) GetStateVariables() []*StateVariable
- func (c *Contract) GetStructs() []*Struct
- func (c *Contract) GetSymbols() []*Symbol
- func (c *Contract) GetUnitSrc() ast.SrcNode
- func (c *Contract) ToProto() *ir_pb.Contract
- type ContractNode
- type Enum
- func (e *Enum) GetAST() *ast.EnumDefinition
- func (e *Enum) GetCanonicalName() string
- func (e *Enum) GetId() int64
- func (e *Enum) GetMembers() []*Parameter
- func (e *Enum) GetName() string
- func (e *Enum) GetNodeType() ast_pb.NodeType
- func (e *Enum) GetSrc() ast.SrcNode
- func (e *Enum) ToProto() *ir_pb.Enum
- type Error
- func (e *Error) GetAST() *ast.ErrorDefinition
- func (e *Error) GetId() int64
- func (e *Error) GetName() string
- func (e *Error) GetNodeType() ast_pb.NodeType
- func (e *Error) GetParameters() []*Parameter
- func (e *Error) GetSrc() ast.SrcNode
- func (e *Error) GetTypeDescription() *ast.TypeDescription
- func (e *Error) ToProto() *ir_pb.Error
- type Event
- func (e *Event) GetAST() *ast.EventDefinition
- func (e *Event) GetId() int64
- func (e *Event) GetName() string
- func (e *Event) GetNodeType() ast_pb.NodeType
- func (e *Event) GetParameters() []*Parameter
- func (e *Event) GetSignature() common.Hash
- func (e *Event) GetSignatureRaw() string
- func (e *Event) GetSrc() ast.SrcNode
- func (e *Event) IsAnonymous() bool
- func (e *Event) ToProto() *ir_pb.Event
- type Expression
- type Fallback
- func (f *Fallback) GetAST() *ast.Fallback
- func (f *Fallback) GetId() int64
- func (f *Fallback) GetKind() ast_pb.NodeType
- func (f *Fallback) GetModifiers() []*Modifier
- func (f *Fallback) GetName() string
- func (f *Fallback) GetNodeType() ast_pb.NodeType
- func (f *Fallback) GetOverrides() []*Override
- func (f *Fallback) GetParameters() []*Parameter
- func (f *Fallback) GetReturnStatements() []*Parameter
- func (f *Fallback) GetSrc() ast.SrcNode
- func (f *Fallback) GetStateMutability() ast_pb.Mutability
- func (f *Fallback) GetVisibility() ast_pb.Visibility
- func (f *Fallback) IsImplemented() bool
- func (f *Fallback) IsVirtual() bool
- func (f *Fallback) ToProto() *ir_pb.Fallback
- type Function
- func (f *Function) GetAST() *ast.Function
- func (f *Function) GetBody() *Body
- func (f *Function) GetId() int64
- func (f *Function) GetKind() ast_pb.NodeType
- func (f *Function) GetModifiers() []*Modifier
- func (f *Function) GetName() string
- func (f *Function) GetNodeType() ast_pb.NodeType
- func (f *Function) GetOverrides() []*Override
- func (f *Function) GetParameters() []*Parameter
- func (f *Function) GetReferencedDeclarationId() int64
- func (f *Function) GetReturnStatements() []*Parameter
- func (f *Function) GetSignature() string
- func (f *Function) GetSrc() ast.SrcNode
- func (f *Function) GetStateMutability() ast_pb.Mutability
- func (f *Function) GetVisibility() ast_pb.Visibility
- func (f *Function) IsImplemented() bool
- func (f *Function) IsVirtual() bool
- func (f *Function) ToProto() *ir_pb.Function
- type FunctionCall
- func (e *FunctionCall) GetAST() *ast.FunctionCall
- func (e *FunctionCall) GetArgumentTypes() []*ast_pb.TypeDescription
- func (e *FunctionCall) GetExternalContract() ContractNode
- func (e *FunctionCall) GetExternalContractId() int64
- func (e *FunctionCall) GetExternalContractName() string
- func (e *FunctionCall) GetId() int64
- func (e *FunctionCall) GetKind() ast_pb.NodeType
- func (e *FunctionCall) GetName() string
- func (e *FunctionCall) GetNodeType() ast_pb.NodeType
- func (e *FunctionCall) GetNodes() []Statement
- func (e *FunctionCall) GetReferenceStatement() *Function
- func (e *FunctionCall) GetReferenceStatementId() int64
- func (e *FunctionCall) GetReferencedDeclarationId() int64
- func (e *FunctionCall) GetSrc() ast.SrcNode
- func (e *FunctionCall) GetTypeDescription() *ast_pb.TypeDescription
- func (e *FunctionCall) IsExternal() bool
- func (e *FunctionCall) ToProto() *v3.TypedStruct
- type Import
- func (i *Import) GetAST() *ast.Import
- func (i *Import) GetAbsolutePath() string
- func (i *Import) GetContractId() int64
- func (i *Import) GetFile() string
- func (i *Import) GetId() int64
- func (i *Import) GetNodeType() ast_pb.NodeType
- func (i *Import) GetSourceUnitId() int64
- func (i *Import) GetUnitAlias() string
- func (i *Import) ToProto() *ir_pb.Import
- type Language
- type Link
- type Modifier
- func (m *Modifier) GetAST() *ast.ModifierInvocation
- func (m *Modifier) GetArgumentTypes() []*ast.TypeDescription
- func (m *Modifier) GetId() int64
- func (m *Modifier) GetName() string
- func (m *Modifier) GetNodeType() ast_pb.NodeType
- func (m *Modifier) GetSrc() ast.SrcNode
- func (m *Modifier) ToProto() *ir_pb.Modifier
- type Override
- func (m *Override) GetAST() *ast.OverrideSpecifier
- func (m *Override) GetId() int64
- func (m *Override) GetName() string
- func (m *Override) GetNodeType() ast_pb.NodeType
- func (m *Override) GetReferencedDeclarationId() int64
- func (m *Override) GetSrc() ast.SrcNode
- func (m *Override) GetTypeDescription() *ast.TypeDescription
- func (m *Override) ToProto() *ir_pb.Override
- type Parameter
- func (p *Parameter) GetAST() *ast.Parameter
- func (p *Parameter) GetId() int64
- func (p *Parameter) GetName() string
- func (p *Parameter) GetNodeType() ast_pb.NodeType
- func (p *Parameter) GetSrc() ast.SrcNode
- func (p *Parameter) GetType() string
- func (p *Parameter) GetTypeDescription() *ast.TypeDescription
- func (p *Parameter) IsIndexed() bool
- func (p *Parameter) ToProto() *ir_pb.Parameter
- type Pragma
- func (p *Pragma) GetAST() *ast.Pragma
- func (p *Pragma) GetId() int64
- func (p *Pragma) GetLiterals() []string
- func (p *Pragma) GetNodeType() ast_pb.NodeType
- func (p *Pragma) GetSrc() ast.SrcNode
- func (p *Pragma) GetText() string
- func (p *Pragma) GetVersion() string
- func (p *Pragma) ToProto() *ir_pb.Pragma
- type Receive
- func (f *Receive) GetAST() *ast.Receive
- func (f *Receive) GetId() int64
- func (f *Receive) GetKind() ast_pb.NodeType
- func (f *Receive) GetModifiers() []*Modifier
- func (f *Receive) GetName() string
- func (f *Receive) GetNodeType() ast_pb.NodeType
- func (f *Receive) GetOverrides() []*Override
- func (f *Receive) GetParameters() []*Parameter
- func (f *Receive) GetSrc() ast.SrcNode
- func (f *Receive) GetStateMutability() ast_pb.Mutability
- func (f *Receive) GetVisibility() ast_pb.Visibility
- func (f *Receive) IsImplemented() bool
- func (f *Receive) IsVirtual() bool
- func (f *Receive) ToProto() *ir_pb.Receive
- type RootSourceUnit
- func (r *RootSourceUnit) GetAST() *ast.RootNode
- func (r *RootSourceUnit) GetContractById(id int64) *Contract
- func (r *RootSourceUnit) GetContractByName(name string) *Contract
- func (r *RootSourceUnit) GetContractBySourceUnitId(id int64) *Contract
- func (r *RootSourceUnit) GetContractTypes() []string
- func (r *RootSourceUnit) GetContracts() []*Contract
- func (r *RootSourceUnit) GetContractsCount() int32
- func (r *RootSourceUnit) GetContractsCountByKind(kind ast_pb.NodeType) int64
- func (r *RootSourceUnit) GetEntryContract() *Contract
- func (r *RootSourceUnit) GetEntryId() int64
- func (r *RootSourceUnit) GetEntryName() string
- func (r *RootSourceUnit) GetLinks() []*Link
- func (r *RootSourceUnit) GetNodeType() ast_pb.NodeType
- func (r *RootSourceUnit) GetStandard(standard standards.Standard) *Standard
- func (r *RootSourceUnit) GetStandards() []*Standard
- func (r *RootSourceUnit) HasContractType(ctype string) bool
- func (r *RootSourceUnit) HasContracts() bool
- func (r *RootSourceUnit) HasHighConfidenceStandard(standard standards.Standard) bool
- func (r *RootSourceUnit) HasPerfectConfidenceStandard(standard standards.Standard) bool
- func (r *RootSourceUnit) HasStandard(standard standards.Standard) bool
- func (r *RootSourceUnit) IsEntryContract(contract *Contract) bool
- func (r *RootSourceUnit) SetContractType(standard standards.Standard)
- func (r *RootSourceUnit) ToProto() *ir_pb.Root
- func (r *RootSourceUnit) Walk(nodeVisitor *ast.NodeVisitor) error
- type Standard
- type StateVariable
- func (v *StateVariable) GetAST() *ast.StateVariableDeclaration
- func (v *StateVariable) GetContractId() int64
- func (v *StateVariable) GetId() int64
- func (v *StateVariable) GetName() string
- func (v *StateVariable) GetNodeType() ast_pb.NodeType
- func (v *StateVariable) GetSrc() ast.SrcNode
- func (v *StateVariable) GetStateMutability() ast_pb.Mutability
- func (v *StateVariable) GetStorageLocation() ast_pb.StorageLocation
- func (v *StateVariable) GetStorageSize() (int64, bool)
- func (v *StateVariable) GetType() string
- func (v *StateVariable) GetTypeDescription() *ast.TypeDescription
- func (v *StateVariable) GetVisibility() ast_pb.Visibility
- func (v *StateVariable) IsConstant() bool
- func (v *StateVariable) ToProto() *ir_pb.StateVariable
- type Statement
- type Struct
- func (f *Struct) GetAST() *ast.StructDefinition
- func (f *Struct) GetCanonicalName() string
- func (f *Struct) GetId() int64
- func (f *Struct) GetMembers() []*Parameter
- func (f *Struct) GetName() string
- func (f *Struct) GetNodeType() ast_pb.NodeType
- func (f *Struct) GetReferencedDeclarationId() int64
- func (f *Struct) GetSrc() ast.SrcNode
- func (f *Struct) GetStorageLocation() ast_pb.StorageLocation
- func (f *Struct) GetType() string
- func (f *Struct) GetTypeDescription() *ast.TypeDescription
- func (f *Struct) GetVisibility() ast_pb.Visibility
- func (f *Struct) ToProto() *ir_pb.Struct
- type Symbol
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:"node_type"` 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) GetNodeType ¶
GetNodeType returns the type of the body node.
func (*Body) GetStatements ¶
GetStatements returns a list of statements contained within the body.
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
NewBuilderFromJSON creates a new IR builder from a JSON representation of the AST.
func NewBuilderFromSources ¶
NewBuilderFromSources creates a new IR builder from given sources. It initializes the necessary parser and AST builder from the provided sources.
func (*Builder) GetAddress ¶ added in v0.3.3
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) GetRoot ¶
func (b *Builder) GetRoot() *RootSourceUnit
GetRoot retrieves the root of the IR.
func (*Builder) GetSources ¶
GetSources returns the source files being processed.
func (*Builder) LookupReferencedFunctionsByNode ¶
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 ¶
Parse processes the sources using the parser and the AST builder and returns any encountered errors.
func (*Builder) SetAddress ¶ added in v0.3.3
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) ToJSONPretty ¶
ToJSONPretty provides a prettified JSON representation of the IR.
func (*Builder) ToProtoPretty ¶
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:"node_type"` 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:"state_mutability"` 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:"source_unit_id"` NodeType ast_pb.NodeType `json:"node_type"` Kind ast_pb.NodeType `json:"kind"` Name string `json:"name"` License string `json:"license"` Language Language `json:"language"` AbsolutePath string `json:"absolute_path"` Symbols []*Symbol `json:"symbols"` BaseContracts []*ast.BaseContract `json:"base_contracts"` Imports []*Import `json:"imports"` Pragmas []*Pragma `json:"pragmas"` StateVariables []*StateVariable `json:"state_variables"` 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 ¶
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) GetFallback ¶
GetFallback returns the fallback of the contract.
func (*Contract) GetFunctions ¶
GetFunctions returns the functions of the contract.
func (*Contract) GetImports ¶
GetImports returns the imports of the contract.
func (*Contract) GetLanguage ¶
GetLanguage returns the programming language of the contract.
func (*Contract) GetLicense ¶
GetLicense returns the license of the contract.
func (*Contract) GetNodeType ¶
GetNodeType returns the NodeType of the contract.
func (*Contract) GetPragmas ¶
GetPragmas returns the pragmas of the contract.
func (*Contract) GetReceive ¶
GetReceive returns the receive of the contract.
func (*Contract) GetSourceUnitId ¶
GetSourceUnitId returns the source unit ID of the contract.
func (*Contract) GetStateVariables ¶
func (c *Contract) GetStateVariables() []*StateVariable
GetStateVariables returns the state variables of the contract.
func (*Contract) GetStructs ¶
GetStructs returns the structs of the contract.
func (*Contract) GetSymbols ¶
GetSymbols returns the symbols of the contract.
func (*Contract) GetUnitSrc ¶
GetUnitSrc returns the source node of the contract unit.
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.
type Enum ¶
type Enum struct { Unit *ast.EnumDefinition `json:"ast"` Id int64 `json:"id"` NodeType ast_pb.NodeType `json:"node_type"` Name string `json:"name"` CanonicalName string `json:"canonical_name"` 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 ¶
GetCanonicalName returns the canonical name of the enum.
func (*Enum) GetMembers ¶
GetMembers returns the members of the enum.
func (*Enum) GetNodeType ¶
GetNodeType returns the NodeType of the enum.
type Error ¶
type Error struct { Unit *ast.ErrorDefinition `json:"ast"` Id int64 `json:"id"` NodeType ast_pb.NodeType `json:"node_type"` 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) GetNodeType ¶
GetNodeType returns the NodeType of the error definition.
func (*Error) GetParameters ¶
GetParameters returns the parameters of the error definition.
func (*Error) GetTypeDescription ¶
func (e *Error) GetTypeDescription() *ast.TypeDescription
GetTypeDescription returns the type description of the error definition.
type Event ¶
type Event struct { Unit *ast.EventDefinition `json:"ast"` Id int64 `json:"id"` NodeType ast_pb.NodeType `json:"node_type"` 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) GetNodeType ¶
GetNodeType returns the NodeType of the event definition.
func (*Event) GetParameters ¶
GetParameters returns the parameters of the event definition.
func (*Event) GetSignature ¶ added in v0.3.3
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
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) IsAnonymous ¶
IsAnonymous returns whether the event definition is anonymous.
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:"node_type"` 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:"state_mutability"` 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 ¶
GetAST returns the AST (Abstract Syntax Tree) for the fallback function definition.
func (*Fallback) GetModifiers ¶
GetModifiers returns the modifiers applied to the fallback function.
func (*Fallback) GetNodeType ¶
GetNodeType returns the NodeType of the fallback function definition.
func (*Fallback) GetOverrides ¶
GetOverrides returns the overrides applied to the fallback function.
func (*Fallback) GetParameters ¶
GetParameters returns the parameters of the fallback function.
func (*Fallback) GetReturnStatements ¶
GetReturnStatements returns the return statements 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 ¶
IsImplemented returns whether the fallback function is implemented.
type Function ¶
type Function struct { Unit *ast.Function `json:"ast"` Id int64 `json:"id"` NodeType ast_pb.NodeType `json:"node_type"` 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:"state_mutability"` Virtual bool `json:"virtual"` ReferencedDeclarationId int64 `json:"referenced_declaration_id"` 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 ¶
GetAST returns the AST (Abstract Syntax Tree) for the function declaration.
func (*Function) GetModifiers ¶
GetModifiers returns the modifiers of the function.
func (*Function) GetNodeType ¶
GetNodeType returns the NodeType of the function declaration.
func (*Function) GetOverrides ¶
GetOverrides returns the overrides of the function.
func (*Function) GetParameters ¶
GetParameters returns the parameters of the function.
func (*Function) GetReferencedDeclarationId ¶
GetReferencedDeclarationId returns the referenced declaration id of the function.
func (*Function) GetReturnStatements ¶
GetReturnStatements returns the return statements of the function.
func (*Function) GetSignature ¶ added in v0.3.1
GetSignature returns the keccak signature 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 ¶
IsImplemented returns whether the function is implemented or not.
type FunctionCall ¶
type FunctionCall struct { Unit *ast.FunctionCall `json:"-"` Id int64 `json:"id"` NodeType ast_pb.NodeType `json:"node_type"` Kind ast_pb.NodeType `json:"kind"` Name string `json:"name"` ArgumentTypes []*ast_pb.TypeDescription `json:"argument_types"` External bool `json:"external"` ExternalContractId int64 `json:"external_contract_id"` ExternalContractName string `json:"external_contract_name,omitempty"` ReferenceStatementId int64 `json:"reference_statement_id"` ReferencedDeclarationId int64 `json:"referenced_declaration_id"` TypeDescription *ast_pb.TypeDescription `json:"type_description"` // 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:"node_type"` AbsolutePath string `json:"absolute_path"` File string `json:"file"` UnitAlias string `json:"unit_alias"` SourceUnitId int64 `json:"source_unit_id"` ContractId int64 `json:"contract_id"` Contract *Contract `json:"contract"` }
Import represents an import statement in the IR.
func (*Import) GetAbsolutePath ¶
GetAbsolutePath returns the absolute path of the imported file.
func (*Import) GetContractId ¶
GetContractId returns the ID of the contract associated with the source unit.
func (*Import) GetNodeType ¶
GetNodeType returns the type of the node in the AST.
func (*Import) GetSourceUnitId ¶
GetSourceUnitId returns the ID of the source unit where the import statement is used.
func (*Import) GetUnitAlias ¶
GetUnitAlias returns the alias used for the imported unit.
type Language ¶
type Language string
Language represents a programming language.
Constants representing different programming languages.
type Link ¶ added in v0.3.1
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
GetLocation returns the link's location.
func (*Link) GetNetwork ¶ added in v0.3.1
GetNetwork returns the network or platform of the link.
type Modifier ¶
type Modifier struct { Unit *ast.ModifierInvocation `json:"ast"` Id int64 `json:"id"` NodeType ast_pb.NodeType `json:"node_type"` Name string `json:"name"` ArgumentTypes []*ast.TypeDescription `json:"argument_types"` }
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) GetNodeType ¶
GetNodeType returns the AST node type of the Modifier.
type Override ¶
type Override struct { Unit *ast.OverrideSpecifier `json:"ast"` Id int64 `json:"id"` NodeType ast_pb.NodeType `json:"node_type"` Name string `json:"name"` ReferencedDeclarationId int64 `json:"referenced_declaration_id"` TypeDescription *ast.TypeDescription `json:"type_description"` }
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) GetNodeType ¶
GetNodeType returns the AST node type of the Override.
func (*Override) GetReferencedDeclarationId ¶
GetReferencedDeclarationId returns the ID of the referenced declaration for the Override.
func (*Override) GetTypeDescription ¶
func (m *Override) GetTypeDescription() *ast.TypeDescription
GetTypeDescription returns the type description of the Override.
type Parameter ¶
type Parameter struct { Unit *ast.Parameter `json:"ast"` Id int64 `json:"id"` NodeType ast_pb.NodeType `json:"node_type"` Name string `json:"name"` Type string `json:"type"` TypeDescription *ast.TypeDescription `json:"type_description"` Indexed bool `json:"indexed"` }
Parameter represents a Parameter in the Abstract Syntax Tree.
func (*Parameter) GetNodeType ¶
GetNodeType returns the AST node type of the Parameter.
func (*Parameter) GetTypeDescription ¶
func (p *Parameter) GetTypeDescription() *ast.TypeDescription
GetTypeDescription returns the type description of the Parameter.
type Pragma ¶
type Pragma struct { Unit *ast.Pragma `json:"ast"` Id int64 `json:"id"` NodeType ast_pb.NodeType `json:"node_type"` Literals []string `json:"literals"` Text string `json:"text"` }
Pragma represents a Pragma in the Abstract Syntax Tree.
func (*Pragma) GetLiterals ¶
GetLiterals returns the literals associated with the Pragma.
func (*Pragma) GetNodeType ¶
GetNodeType returns the AST node type of the Pragma.
func (*Pragma) GetVersion ¶
GetVersion extracts and returns the version information from the Pragma text.
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:"node_type"` // 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:"state_mutability"` // 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) GetKind ¶
GetKind returns the kind of the receive function node (e.g., FunctionDefinition, FunctionType).
func (*Receive) GetModifiers ¶
GetModifiers returns a list of modifiers applied to the receive function.
func (*Receive) GetName ¶
GetName returns the name of the receive function (always "receive" for Solidity receive functions).
func (*Receive) GetNodeType ¶
GetNodeType returns the type of the receive function node in the AST.
func (*Receive) GetOverrides ¶
GetOverrides returns a list of functions overridden by the receive function.
func (*Receive) GetParameters ¶
GetParameters returns a list of parameters 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 ¶
IsImplemented returns true if the receive function is implemented in the contract, false otherwise.
type RootSourceUnit ¶
type RootSourceUnit struct { Unit *ast.RootNode `json:"ast"` NodeType ast_pb.NodeType `json:"node_type"` Address common.Address `json:"address"` EntryContractId int64 `json:"entry_contract_id"` EntryContractName string `json:"entry_contract_name"` ContractsCount int32 `json:"contracts_count"` ContractTypes []string `json:"contract_types"` 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 (*RootSourceUnit) GetLinks ¶ added in v0.3.1
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 ¶
GetConfidence returns the confidence level of the contract adhering to a specific EIP standard.
func (*Standard) GetContractId ¶
GetContractId returns the unique identifier for the contract.
func (*Standard) GetContractName ¶
GetContractName returns the name of the contract.
func (*Standard) GetStandard ¶
func (e *Standard) GetStandard() standards.ContractStandard
GetStandard returns the EIP standard.
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:"contract_id"` // 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:"node_type"` // 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:"is_constant"` // Constant is true if the state variable is constant, false otherwise. StorageLocation ast_pb.StorageLocation `json:"storage_location"` // StorageLocation represents the storage location of the state variable. StateMutability ast_pb.Mutability `json:"state_mutability"` // 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:"type_description"` // 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 ¶
func (v *StateVariable) GetAST() *ast.StateVariableDeclaration
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:"node_type"` Name string `json:"name"` CanonicalName string `json:"canonical_name"` ReferencedDeclarationId int64 `json:"referenced_declaration_id"` Visibility ast_pb.Visibility `json:"visibility"` StorageLocation ast_pb.StorageLocation `json:"storage_location"` Members []*Parameter `json:"members"` Type string `json:"type"` TypeDescription *ast.TypeDescription `json:"type_description"` }
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 ¶
GetCanonicalName returns the canonical name of the struct.
func (*Struct) GetMembers ¶
GetMembers returns the list of members (parameters) in the struct.
func (*Struct) GetNodeType ¶
GetNodeType returns the type of the node in the AST.
func (*Struct) GetReferencedDeclarationId ¶
GetReferencedDeclarationId returns the referenced declaration ID of the struct.
func (*Struct) GetStorageLocation ¶
func (f *Struct) GetStorageLocation() ast_pb.StorageLocation
GetStorageLocation returns the storage location 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.
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 ¶
GetAbsolutePath returns the absolute path of the symbol.