Documentation ¶
Overview ¶
Package extract contains methods to extract type information from ast.Node trees.
Index ¶
- func ArrayType(path string, arrayTypeName ast.ArrayTypeName) (types.Array, error)
- func ContractAPI(contractDefinition ast.ContractDefinition, typeMap types.Map) ([]types.Function, error)
- func ContractDefinitions(root ast.SourceUnit) []ast.ContractDefinition
- func EnumType(path string, enumDefinition ast.EnumDefinition) (types.Named, error)
- func EventType(path string, eventDefinition ast.EventDefinition) (types.Named, error)
- func FunctionAPI(functionDefinition ast.FunctionDefinition, typeMap types.Map) (types.Function, error)
- func MappingType(path string, mapping ast.Mapping) (types.Mapping, error)
- func Project(combined ast.Combined) (types.Project, error)
- func StructType(path string, structDefinition ast.StructDefinition) (types.Named, error)
- func Type(path string, node ast.Node) (types.Type, error)
- func Types(path string, root ast.SourceUnit) (types.Map, error)
- func VariableAPI(variableDeclaration ast.VariableDeclaration, typeMap types.Map) types.Function
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContractAPI ¶
func ContractAPI(contractDefinition ast.ContractDefinition, typeMap types.Map) ([]types.Function, error)
ContractAPI extracts all functions from a ast.ContractDefinition. Remember that public top-level variables in Solidity export automatic getter functions. These functions are also part of the extracted API. typeMap is used to resolve type references in the process.
func ContractDefinitions ¶
func ContractDefinitions(root ast.SourceUnit) []ast.ContractDefinition
ContractDefinitions extracts all ast.ContractDefinition's from an ast.SourceUnit.
func FunctionAPI ¶
func FunctionAPI(functionDefinition ast.FunctionDefinition, typeMap types.Map) (types.Function, error)
FunctionAPI extracts an ast.FunctionDefinition's type information.
func MappingType ¶
MappingType extracts a types.Mapping from an ast.Mapping.
func Project ¶
Project extracts an entire smart contract project's combined type information and structure. It will remove the longest shared path prefix among all source units (solidity files). E.g. files "a/x/b.sol" and "a/c.sol" will be referenced as "x/b.sol" and "c.sol", respectively. TODO: Windows support: normalize paths to forward slashes without drive letters, etc.
func StructType ¶
StructType extracts a named types.Struct from an ast.StructDefinition.
func Type ¶
Type extracts type information from an AST node which may be any of: ast.ContractDefinition, ast.UserDefinedTypeName, ast.ElementaryTypeName, ast.ArrayTypeName, ast.EnumDefinition, ast.StructDefinition, ast.EventDefinition, ast.Mapping. It returns an error for everything else.
func VariableAPI ¶
VariableAPI extracts the generated getter function that public top-level contract variables get automatically in Solidity.
Types ¶
This section is empty.