package solidity-common
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=d5d0f31101413c9a36d6a37973aa03fde788644808f34dbff0220ee45c17ece4
doc/solidity-common/Solidity_ast/index.html
Module Solidity_astSource
Generic identifiers
Context relative identifiers
type program = {program_modules : module_ list;program_modules_by_id : module_ Solidity_common.IdentMap.t;program_modules_by_file : module_ Solidity_common.StringMap.t;
}The program definition. Modules (files) are sorted in different ways, but they all are the same.
and module_ = {module_file : string;module_id : Solidity_common.Ident.t;module_units : module_units;
}A file definition
and source_unit = | Pragma of Solidity_common.Ident.t * string(*Options for the official solidity compiler
*)| Import of import_directive(*Import directive
*)| GlobalTypeDefinition of type_definition(*Definition of a type for the whole file
*)| GlobalFunctionDefinition of function_definition(*Definition of a function for the whole file
*)| GlobalVariableDefinition of state_variable_definition(*Definition of a variable for the whole file
*)| ContractDefinition of contract_definition(*Definition of a contract
*)
The different kind of contents.
and contract_definition = {contract_name : ident;contract_kind : contract_kind;contract_abstract : bool;contract_inheritance : inheritance_specifier list;contract_parts : contract_part Solidity_common.node list;
}and contract_part = | TypeDefinition of type_definition(*Definition of a local type ; can be an enum or a struct
*)| StateVariableDeclaration of state_variable_definition(*Declaration/definition of a state variable
*)| FunctionDefinition of function_definition(*Declaration/definition of a state variable
*)| ModifierDefinition of modifier_definition(*Definition of a modifier
*)| EventDefinition of event_definition(*Definition of an event
*)| UsingForDeclaration of longident * type_ option
Components of a contract
and type_definition = | EnumDefinition of enum_definition| StructDefinition of struct_definition
and state_variable_definition = {var_name : ident;var_type : type_;var_visibility : visibility;var_mutability : var_mutability;var_override : longident list option;var_init : expression option;
}Definition of a state variable. Its initializer is optional, in which case it is only a declaration.
and function_definition = {fun_name : ident;fun_params : param list;fun_returns : return list;fun_modifiers : (longident * expression list option) list;fun_visibility : visibility;fun_mutability : fun_mutability;fun_override : longident list option;fun_virtual : bool;fun_body : block option;
}Definition of a contract function. Its body is optional, in which case it is only a declaration.
and modifier_definition = {mod_name : ident;mod_params : param list;mod_override : longident list option;mod_virtual : bool;mod_body : block option;
}Definition of a modifier. Its body is optional, in which case it is only a declaration.
Definition of an event.
and type_ = | ElementaryType of elementary_type(*A builtin elementary type
*)| Array of type_ * expression option(*Array types
*)| Mapping of type_ * type_(*Type of mappings with types (key, element)
*)| FunctionType of function_type(*Type of functions
*)| UserDefinedType of longident(*User defined type (see type_definition)
*)
Type identifiers
and function_type = {fun_type_params : param list;fun_type_returns : (type_ * storage_location option) list;fun_type_visibility : visibility;fun_type_mutability : fun_mutability;
}and raw_statement = | Block of block(*An ordered list of statements
*)| VariableDefinition of variable_definition(*Local variable definition
*)| ExpressionStatement of expression(*Single expression returning nothing
*)| IfStatement of expression * statement * statement option(*If-then-else statement; else is optional
*)| WhileStatement of expression * statement(*While loop; expression is the boolean condition, statement is its body
*)| DoWhileStatement of statement * expression(*Do while loop; expression is the boolean condition, statement is its body
*)| ForStatement of statement option * expression option * expression option * statement(*For loop ; the first statement is the initializer, the next expression is the condition, the third is the for action and the last statement the loop body.
*)| TryStatement of expression * return list * block * catch_clause list(*Try-catch statement
*)| Emit of expression * function_call_arguments(*Event emission
*)| Return of expression option(*Return statement
*)| Continue(*Continue (loop statement)
*)| Break(*Break (loop statement)
*)| PlaceholderStatement(*Placeholder for modifiers
*)
and raw_expression = | BooleanLiteral of bool| NumberLiteral of Q.t * number_unit * int option| StringLiteral of string| AddressLiteral of string| IdentifierExpression of ident| ImmediateArray of expression list| ArrayAccess of expression * expression option| ArraySlice of expression * expression option * expression option| TupleExpression of expression option list| PrefixExpression of unary_operator * expression| SuffixExpression of expression * unary_operator| CompareExpression of expression * compare_operator * expression| BinaryExpression of expression * binary_operator * expression| AssignExpression of expression * expression| AssignBinaryExpression of expression * binary_operator * expression| IfExpression of expression * expression * expression| FieldExpression of expression * ident| FunctionCallExpression of expression * function_call_arguments| CallOptions of expression * (ident * expression) list| NewExpression of type_| TypeExpression of type_
and variable_definition = | VarInfer of ident option list * expression(*Variable without type
*)| VarType of (type_ * storage_location option * ident) option list * expression option(*Typed variable
*)
and function_call_arguments = | ExpressionList of expression list(*Anonymous arguments
*)| NameValueList of (ident * expression) list(*Named arguments
*)
True iff not private
Checks the equality of mutabilities
Tests if a function with `from` mutability can be overridden by a function with `to` mutability.
Checks the equality of visibilities
Tests if a function with `from` visibility can be overridden by a function with `to` visibility.
Returns the quantity in argument with the unit in argument in the smallest quantity of the language of the similar unit. Examples: * `apply_unit 1 Minutes = 60 (Seconds)` * `apply_unit 1 Ether = 1e15 (Wei)` * `apply_unit 1 Unit = 1 (Unit)`
Apply the unary operator in argument to a zarith rational. Returns `None` when applying UNot on non-integers If the operator is not an arithmetical operator, also returns `None`.
Apply the binary operator in argument to a zarith rational. If the operator is not an arithmetical operator, returns `None`.