Expand description
Re-exportsยง
Modulesยง
- common
- expressions ๐
- function_
stub - functions ๐
- indent_
display ๐ - interpreter_
value - locator
- mapping ๐
- member
- passes ๐
- This module contains both a Reducer and Visitor design pattern. These both iterate over the AST.
- program ๐
- A Leo program consists of import statements and program scopes.
- statement ๐
- struct ๐
- stub ๐
- A stub contains function templates as well as definitions for mappings, structs, records, and constants.
- types ๐
- value ๐
Macrosยง
Structsยง
- Annotation
- An annotation, e.g. @program.
- Array
Access - An array access expression, e.g.,
foo[index]
. - Array
Expression - An array expression, e.g.,
[true, false, true, false]
. - Array
Type - An array type.
- Assert
Statement - An assert statement,
assert(<expr>)
,assert_eq(<expr>)
orassert_neq(<expr>)
. - Assign
Statement - An assignment statement,
assignee = value
. Note that there is no operation associated with the assignment. - Associated
Constant Expression - An access expression to a struct constant., e.g.
u8::MAX
. - Associated
Function Expression - An access expression to an associated function in a struct, e.g.
Pedersen64::hash()
. - Ast
- The abstract syntax tree (AST) for a Leo program.
- Binary
Expression - A binary expression
left op right
of two operands separated by some operator. For example,foo + bar
. - Block
- A block
{ [stmt]* }
consisting of a list of statements to execute in order. - Call
Expression - A function call expression, e.g.
foo(args)
orFoo::bar(args)
. - Cast
Expression - A cast expression, e.g.
42u8 as u16
. - Composite
- A composite type definition, e.g.,
struct Foo { my_field: Bar }
andrecord Token { owner: address, amount: u64}
. In some languages these are calledstruct
s. - Composite
Type - A composite type of a identifier and external program name.
- Conditional
Statement - An
if condition block (else next)?
statement. - Const
Declaration - A constant declaration statement.
- Const
Parameter - A function const parameter.
- Definition
Statement - A
let
orconst
declaration statement. - ErrExpression
- Represents a syntactically invalid expression.
- Expression
Statement - An expression statement,
foo(a);
. - Function
- A function definition.
- Function
Stub - A function stub definition.
- Future
Type - A future type consisting of the type of the inputs.
- Input
- A function parameter.
- Iteration
Statement - A bounded
for
loop statementfor variable in start .. =? stop block
. - Literal
- A literal.
- Locator
Expression - A locator that references an external resource.
- Mapping
- A mapping declaration, e.g
mapping balances: address => u128
. - Mapping
Type - A mapping type of a key and value type.
- Member
- A member of a structured data type, e.g
foobar: u8
orprivate baz: bool
. - Member
Access - A struct member access expression
inner.name
to some structure with named members. - Output
- A function output.
- Program
- Stores the Leo program abstract syntax tree.
- Program
Id - An identifier for a program that is eventually deployed to the network.
- Program
Scope - Stores the Leo program scope abstract syntax tree.
- Repeat
Expression - An array expression constructed from one repeated element.
- Return
Statement - A return statement
return expression;
. - Struct
Expression - A struct initialization expression, e.g.,
Foo { bar: 42, baz }
. - Struct
Variable Initializer - An initializer for a single field / variable of a struct initializer expression.
That is, in
Foo { bar: 42, baz }
, this is eitherbar: 42
, orbaz
. - Stub
- Stores the Leo stub abstract syntax tree.
- Ternary
Expression - A ternary conditional expression, that is,
condition ? if_true : if_false
. - Tuple
Access - A tuple access expression, e.g.,
tuple.index
. - Tuple
Expression - A tuple expression, e.g.,
(foo, false, 42)
. - Tuple
Type - A type list of at least two types.
- Unary
Expression - An unary expression applying an operator to an inner expression.
- Unit
Expression - Represents a unit expression.
Enumsยง
- Assert
Variant - A variant of an assert statement.
- Binary
Operation - A binary operator.
- Core
Constant - A core constant that maps directly to an AVM bytecode constant.
- Core
Function - A core instruction that maps directly to an AVM bytecode instruction.
- Definition
Place - Expression
- Expression that evaluates to a value.
- Integer
Type - Explicit integer type.
- Literal
Variant - Mode
- The mode associated with a type.
- Statement
- Program statement that defines some action (or expression) to be carried out.
- Type
- Explicit type used for defining a variable or expression type
- Unary
Operation - A unary operator for a unary expression.
- Value
- Variant
- Functions are always one of six variants. A transition function is permitted the ability to manipulate records. An asynchronous transition function is a transition function that calls an asynchronous function. A regular function is not permitted to manipulate records. An asynchronous function contains on-chain operations. An inline function is directly copied at the call site.
Traitsยง
- Expression
Consumer - A Consumer trait for expressions in the AST.
- Expression
Reconstructor - A Reconstructor trait for expressions in the AST.
- Expression
Visitor - A Visitor trait for expressions in the AST.
- From
StrRadix - This trait allows to parse integer literals of any type generically.
- Function
Consumer - A Consumer trait for functions in the AST.
- Import
Consumer - A Consumer trait for imported programs in the AST.
- Mapping
Consumer - A Consumer trait for mappings in the AST.
- Program
Consumer - A Consumer trait for the program represented by the AST.
- Program
Reconstructor - A Reconstructor trait for the program represented by the AST.
- Program
Scope Consumer - A Consumer trait for program scopes in the AST.
- Program
Visitor - A Visitor trait for the program represented by the AST.
- Statement
Consumer - A Consumer trait for statements in the AST.
- Statement
Reconstructor - A Reconstructor trait for statements in the AST.
- Statement
Visitor - A Visitor trait for statements in the AST.
- Struct
Consumer - A Consumer trait for structs in the AST.
- Type
Reconstructor - A Reconstructor trait for types in the AST.
- Type
Visitor - A Visitor trait for types in the AST.
Functionsยง
- normalize_
json_ value - Helper function to normalize AST JSON into a form compatible with tgc. This function will traverse the original JSON value and produce a new one under the following rules:
- remove_
key_ from_ json - Helper function to recursively filter keys from AST JSON