Documentation
¶
Overview ¶
Package ast contains Go type definitions representing AST nodes produced by solc, the Soldity compiler.
Index ¶
- Constants
- func PostTraverse(root Node, f func(Node))
- func PreTraverse(root Node, f func(Node))
- type ArrayTypeName
- type Block
- type Combined
- type CombinedSource
- type CompiledContract
- type ContractDefinition
- type ContractKind
- type ElementaryTypeName
- type EnumDefinition
- type EnumValue
- type EventDefinition
- type FunctionDefinition
- type Header
- type Identifier
- type IgnoredNode
- type ImportDirective
- type InheritanceSpecifier
- type Literal
- type Mapping
- type ModifierDefinition
- type ModifierInvocation
- type Node
- type ParameterList
- type PragmaDirective
- type SourceUnit
- type StateMutability
- type StorageLocation
- type StructDefinition
- type UserDefinedTypeName
- type UsingForDirective
- type VariableDeclaration
- type Visibility
Constants ¶
const ( ContractKindContract ContractKind = "contract" ContractKindInterface = "interface" ContractKindLibrary = "library" )
const ( VisibilityPublic Visibility = "public" VisibilityInternal = "internal" VisibilityExternal = "external" VisibilityPrivate = "private" )
const ( StateMutabilityPure StateMutability = "pure" StateMutabilityView = "view" StateMutabilityNonpayable = "nonpayable" )
const ( StorageLocationDefault StorageLocation = "default" StorageLocationMemory = "memory" StorageLocationStorage = "storage" )
Variables ¶
This section is empty.
Functions ¶
func PostTraverse ¶
PostTraverse traverses a Node-tree in post-order.
func PreTraverse ¶
PreTraverse traverses a Node-tree in pre-order.
Types ¶
type ArrayTypeName ¶
type ArrayTypeName struct { Type string `json:"type"` // contains filtered or unexported fields }
ArrayTypeName represents an array-type's name (e.g. "int32[8]") in a Solidity AST.
func (ArrayTypeName) Children ¶
func (n ArrayTypeName) Children() []Node
func (ArrayTypeName) Header ¶
func (n ArrayTypeName) Header() Header
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block represents a function's command-list in a Solidity AST.
type Combined ¶
type Combined struct { Contracts map[string]CompiledContract `json:"contracts"` SourceList []string `json:"sourceList"` Sources map[string]CombinedSource `json:"sources"` Version string `json:"version"` }
Combined is the top-most node in a Solidity AST. It holds all source files involved in the compilation process.
type CombinedSource ¶
type CombinedSource struct {
AST json.RawMessage `json:"AST"`
}
CombinedSource is the raw JSON analog to Combined.
type CompiledContract ¶
type CompiledContract struct {
Binary string `json:"bin"`
}
CompiledContract represents a compiled Solidity contract's binary payload in hex.
type ContractDefinition ¶
type ContractDefinition struct { Name string `json:"name"` Scope int `json:"scope"` FullyImplemented bool `json:"fullyImplemented"` LinearizedBaseContracts []int `json:"linearizedBaseContracts"` Documentation string `json:"documentation"` ContractKind ContractKind `json:"contractKind"` // contains filtered or unexported fields }
ContractDefinition represents a contract definition in a Solidity AST.
func (ContractDefinition) Children ¶
func (n ContractDefinition) Children() []Node
func (ContractDefinition) Header ¶
func (n ContractDefinition) Header() Header
type ElementaryTypeName ¶
type ElementaryTypeName struct { Name string `json:"name"` Type string `json:"type"` // contains filtered or unexported fields }
ElementaryTypeName represents an elementary type name in a Solidity AST.
func (ElementaryTypeName) Children ¶
func (n ElementaryTypeName) Children() []Node
func (ElementaryTypeName) Header ¶
func (n ElementaryTypeName) Header() Header
type EnumDefinition ¶
type EnumDefinition struct { CanonicalName string `json:"canonicalName"` Name string `json:"name"` // contains filtered or unexported fields }
EnumDefinition represents an enum definition in a Solidity AST.
func (EnumDefinition) Children ¶
func (n EnumDefinition) Children() []Node
func (EnumDefinition) Header ¶
func (n EnumDefinition) Header() Header
type EnumValue ¶
type EnumValue struct { Name string `json:"name"` // contains filtered or unexported fields }
EnumValue represents each element in an enum definition in a Solidity AST.
type EventDefinition ¶
type EventDefinition struct { CanonicalName string `json:"canonicalName"` // NOTE: not present in json file, added in post. Name string `json:"name"` // contains filtered or unexported fields }
EventDefinition represents an even definition in a Solidity AST.
func (EventDefinition) Children ¶
func (n EventDefinition) Children() []Node
func (EventDefinition) Header ¶
func (n EventDefinition) Header() Header
type FunctionDefinition ¶
type FunctionDefinition struct { Constant bool `json:"constant"` Implemented bool `json:"implemented"` IsConstructor bool `json:"isConstructor"` Name string `json:"name"` Payable bool `json:"payable"` Scope int `json:"scope"` StateMutability StateMutability `json:"stateMutability"` Visibility Visibility `json:"visibility"` Documentation string `json:"documentation"` //": null, // contains filtered or unexported fields }
FunctionDefinition represents a function definition in a Solidity AST.
func (FunctionDefinition) Children ¶
func (n FunctionDefinition) Children() []Node
func (FunctionDefinition) Header ¶
func (n FunctionDefinition) Header() Header
type Header ¶
type Header struct { Id int `json:"id"` Name string `json:"name"` Source string `json:"src"` Attributes json.RawMessage `json:"attributes"` Children []json.RawMessage `json:"children"` }
Header holds the common fields every Solidity AST node has.
type Identifier ¶
type Identifier struct { Value string `json:"value"` ReferencedDeclaration int `json:"referencedDeclaration"` // contains filtered or unexported fields }
Identifier represents any identifier in a Solidity AST.
func (Identifier) Children ¶
func (n Identifier) Children() []Node
func (Identifier) Header ¶
func (n Identifier) Header() Header
type IgnoredNode ¶
type IgnoredNode struct {
// contains filtered or unexported fields
}
IgnoredNode represents a node that we ignored in a Solidity AST.
func (IgnoredNode) Children ¶
func (n IgnoredNode) Children() []Node
func (IgnoredNode) Header ¶
func (n IgnoredNode) Header() Header
type ImportDirective ¶
type ImportDirective struct { SourceUnit json.RawMessage `json:"SourceUnit"` AbsolutePath json.RawMessage `json:"absolutePath"` File json.RawMessage `json:"file"` Scope json.RawMessage `json:"scope"` SymbolAliases json.RawMessage `json:"symbolAliases"` UnitAlias json.RawMessage `json:"unitAlias"` // contains filtered or unexported fields }
ImportDirective represents an import declaration in a Solidity AST.
func (ImportDirective) Children ¶
func (n ImportDirective) Children() []Node
func (ImportDirective) Header ¶
func (n ImportDirective) Header() Header
type InheritanceSpecifier ¶
type InheritanceSpecifier struct {
// contains filtered or unexported fields
}
InheritanceSpecifier represents an inheritance specifier (`contract X is Y, Z`) in a Solidity AST.
func (InheritanceSpecifier) Children ¶
func (n InheritanceSpecifier) Children() []Node
func (InheritanceSpecifier) Header ¶
func (n InheritanceSpecifier) Header() Header
type Literal ¶
type Literal struct { Hexvalue string `json:"hexvalue"` Value string `json:"value"` IsConstant bool `json:"isConstant"` IsLValue bool `json:"isLValue"` IsPure bool `json:"isPure"` LValueRequested bool `json:"lValueRequested"` Type string `json:"type"` // contains filtered or unexported fields }
Literal represents a literal in a Solidity AST.
type Mapping ¶
type Mapping struct { Type string `json:"type"` // contains filtered or unexported fields }
Mapping represents a mapping definition in a Solidity AST.
type ModifierDefinition ¶
type ModifierDefinition struct { Name string `json:"name"` Visibility Visibility `json:"visibility"` // contains filtered or unexported fields }
ModifierDefinition represents a modifier definition in a Solidity AST.
func (ModifierDefinition) Children ¶
func (n ModifierDefinition) Children() []Node
func (ModifierDefinition) Header ¶
func (n ModifierDefinition) Header() Header
type ModifierInvocation ¶
type ModifierInvocation struct {
// contains filtered or unexported fields
}
ModifierInvocation represents a modifier invokation in a Solidity AST.
func (ModifierInvocation) Children ¶
func (n ModifierInvocation) Children() []Node
func (ModifierInvocation) Header ¶
func (n ModifierInvocation) Header() Header
type Node ¶
Node represents a Solidity AST node.
func UnserializeJSON ¶
func UnserializeJSON(raw json.RawMessage) (Node, error)
UnserializeJSON parses a raw JSON AST representation into a Node tree.
type ParameterList ¶
type ParameterList struct {
// contains filtered or unexported fields
}
ParameterList represents a list of types in a Solidity AST. It is not used exclusively in function parameter declarations.
func (ParameterList) Children ¶
func (n ParameterList) Children() []Node
func (ParameterList) Header ¶
func (n ParameterList) Header() Header
type PragmaDirective ¶
type PragmaDirective struct { Literals []string `json:"literals"` // contains filtered or unexported fields }
PragmaDirective represents a Solidity file-level pragma declaration.
func (PragmaDirective) Children ¶
func (n PragmaDirective) Children() []Node
func (PragmaDirective) Header ¶
func (n PragmaDirective) Header() Header
type SourceUnit ¶
type SourceUnit struct { AbsolutePath string `json:"absolutePath"` ExportedSymbols map[string][]int `json:"exportedSymbols"` // contains filtered or unexported fields }
SourceUnit bundles all Solidity definitions from a single file.
func (SourceUnit) Children ¶
func (n SourceUnit) Children() []Node
func (SourceUnit) Header ¶
func (n SourceUnit) Header() Header
type StateMutability ¶
type StateMutability string
StateMutability represents a Solidity function's state mutability.
type StorageLocation ¶
type StorageLocation string
StorageLocation represents a Solidity variables's storage location.
type StructDefinition ¶
type StructDefinition struct { CanonicalName string `json:"canonicalName"` Name string `json:"name"` Scope int `json:"scope"` Visibility Visibility `json:"visibility"` // contains filtered or unexported fields }
StructDefinition represents a struct definition in a Solidity AST.
func (StructDefinition) Children ¶
func (n StructDefinition) Children() []Node
func (StructDefinition) Header ¶
func (n StructDefinition) Header() Header
type UserDefinedTypeName ¶
type UserDefinedTypeName struct { Name string `json:"name"` ReferencedDeclaration int `json:"referencedDeclaration"` Type string `json:"type"` // contains filtered or unexported fields }
UserDefinedTypeName represents a user defined type name (e.g. enums, structs) in a Solidity AST.
func (UserDefinedTypeName) Children ¶
func (n UserDefinedTypeName) Children() []Node
func (UserDefinedTypeName) Header ¶
func (n UserDefinedTypeName) Header() Header
type UsingForDirective ¶
type UsingForDirective struct {
// contains filtered or unexported fields
}
UsingForDirective represents the `using X for Y` directive in a Solidity AST.
func (UsingForDirective) Children ¶
func (n UsingForDirective) Children() []Node
func (UsingForDirective) Header ¶
func (n UsingForDirective) Header() Header
type VariableDeclaration ¶
type VariableDeclaration struct { Constant bool `json:"constant"` Name string `json:"name"` Scope int `json:"scope"` StateVariable bool `json:"stateVariable"` StorageLocation string `json:"storageLocation"` Type string `json:"type"` Visibility Visibility `json:"visibility"` // contains filtered or unexported fields }
VariableDeclaration represents a variable declaration in a Solidity AST.
func (VariableDeclaration) Children ¶
func (n VariableDeclaration) Children() []Node
func (VariableDeclaration) Header ¶
func (n VariableDeclaration) Header() Header