ast

class wrenfold.ast.Add

Addition operation: args[0] + args[1] + ...

__init__(*args, **kwargs)
property args

Operands to the addition. There will always be more than one element.

class wrenfold.ast.AssignOutputMatrix

Assign a matrix to an output argument.

__init__(*args, **kwargs)
property arg

Destination argument.

property value

ConstructMatrix specifying values to assign.

class wrenfold.ast.AssignOutputScalar

Assign a scalar to an output argument.

__init__(*args, **kwargs)
property arg

Destination argument.

property value

Scalar value to assign.

class wrenfold.ast.AssignOutputStruct

Assign a struct to an output argument.

__init__(*args, **kwargs)
property arg

Destination argument.

property value

ConstructCustomType specifying values to assign.

class wrenfold.ast.AssignTemporary

Assignment to a temporary variable: left = right

__init__(*args, **kwargs)
property left

Name of the variable to which the assignment applies.

property right

The value being assigned.

class wrenfold.ast.AstSpan

Stores a sequence of AST elements.

__getitem__(self: wrenfold.ast.AstSpan, index: int) Union[wf::ast::add, wf::ast::assign_temporary, wf::ast::assign_output_matrix, wf::ast::assign_output_scalar, wf::ast::assign_output_struct, wf::ast::boolean_literal, wf::ast::branch, wf::ast::call_external_function, wf::ast::call_std_function, wf::ast::cast, wf::ast::comment, wf::ast::compare, wf::ast::construct_custom_type, wf::ast::construct_matrix, wf::ast::declaration, wf::ast::divide, wf::ast::float_literal, wf::ast::get_argument, wf::ast::get_field, wf::ast::get_matrix_element, wf::ast::integer_literal, wf::ast::multiply, wf::ast::negate, wf::ast::optional_output_branch, wf::ast::parenthetical, wf::ast::special_constant, wf::ast::return_object, wf::ast::ternary, wf::ast::variable_ref]

Array access operator.

__init__(*args, **kwargs)
__iter__(self: wrenfold.ast.AstSpan) Iterator[Union[wf::ast::add, wf::ast::assign_temporary, wf::ast::assign_output_matrix, wf::ast::assign_output_scalar, wf::ast::assign_output_struct, wf::ast::boolean_literal, wf::ast::branch, wf::ast::call_external_function, wf::ast::call_std_function, wf::ast::cast, wf::ast::comment, wf::ast::compare, wf::ast::construct_custom_type, wf::ast::construct_matrix, wf::ast::declaration, wf::ast::divide, wf::ast::float_literal, wf::ast::get_argument, wf::ast::get_field, wf::ast::get_matrix_element, wf::ast::integer_literal, wf::ast::multiply, wf::ast::negate, wf::ast::optional_output_branch, wf::ast::parenthetical, wf::ast::special_constant, wf::ast::return_object, wf::ast::ternary, wf::ast::variable_ref]]
__len__(self: wrenfold.ast.AstSpan) int
class wrenfold.ast.BooleanLiteral

Emit a boolean literal constant.

__init__(*args, **kwargs)
property value

Value of the constant (True or False).

class wrenfold.ast.Branch

Emit an if-else statement: if (condition) { ... } else { ... }

__init__(*args, **kwargs)
property condition

Condition governing which branch to take.

property else_branch

Statements that evaluate when the condition is false.

property if_branch

Statements that evaluate when the condition is true.

class wrenfold.ast.CallExternalFunction

Invoke a user-provided external function.

__init__(*args, **kwargs)
class wrenfold.ast.CallStdFunction

Invoke a standard library math function.

__init__(*args, **kwargs)
property args

Arguments to the function.

property function

The function being invoked.

class wrenfold.ast.Cast

Cast a numerical value.

__init__(*args, **kwargs)
property arg

Source value being casted.

property destination_type

The destination numerical type.

class wrenfold.ast.Comment

Emit a comment block.

__init__(*args, **kwargs)
property content

Comment as a single string.

split_lines(self: wrenfold.ast.Comment) list[str]

Split comment by newlines and return a list of strings, one per line.

class wrenfold.ast.Compare

Compare two operands.

__init__(*args, **kwargs)
property left

The left operand.

property operation

Relational operation.

property right

The right operand.

class wrenfold.ast.ConstructCustomType

Construct an instance of a user-provided type.

__init__(*args, **kwargs)
get_field_value(self: wrenfold.ast.ConstructCustomType, name: str) wrenfold.ast.Add | wrenfold.ast.AssignTemporary | wrenfold.ast.AssignOutputMatrix | wrenfold.ast.AssignOutputScalar | wrenfold.ast.AssignOutputStruct | wrenfold.ast.BooleanLiteral | wrenfold.ast.Branch | wrenfold.ast.CallExternalFunction | wrenfold.ast.CallStdFunction | wrenfold.ast.Cast | wrenfold.ast.Comment | wrenfold.ast.Compare | wrenfold.ast.ConstructCustomType | wrenfold.ast.ConstructMatrix | wrenfold.ast.Declaration | wrenfold.ast.Divide | wrenfold.ast.FloatLiteral | wrenfold.ast.GetArgument | wrenfold.ast.GetField | wrenfold.ast.GetMatrixElement | wrenfold.ast.IntegerLiteral | wrenfold.ast.Multiply | wrenfold.ast.Negate | wrenfold.ast.OptionalOutputBranch | wrenfold.ast.Parenthetical | wrenfold.ast.SpecialConstant | wrenfold.ast.ReturnObject | wrenfold.ast.Ternary | wrenfold.ast.VariableRef | None

Given the name of a field, return the statement being assigned to it (or None if the field does not exist).

property type

Instance of wrenfold.codegen.CustomType specifying which type to instantiate.

class wrenfold.ast.ConstructMatrix

Construct a matrix from a list of statements.

__init__(*args, **kwargs)
property args

Contents of the matrix, in row-major order.

property type

Describe dimensions of the matrix.

class wrenfold.ast.Declaration

Declare a variable, and optionally assign it a value: name: type = value

__init__(*args, **kwargs)
property name

Name of the variable.

property type

Type of the variable.

property value

Optional value with which the variable should be initialized.

class wrenfold.ast.Divide

Division operation: left / right

__init__(*args, **kwargs)
property left

Left operand (numerator).

property right

Right operand (denominator).

class wrenfold.ast.FloatLiteral

Emit a floating-point literal constant.

__init__(*args, **kwargs)
property value

Value of the constant.

class wrenfold.ast.FunctionDefinition

Define a generated function. This is the top level object of the emitted syntax tree.

__init__(*args, **kwargs)
property body

Statements that make up the body of the function.

property signature

Function signature.

class wrenfold.ast.FunctionSignature

Emit the signature of a generated function: name(... arguments ...) -> return_annotation

__init__(*args, **kwargs)
property arguments

List of arguments.

property name

Name of the function.

property return_type

Return type of the function.

class wrenfold.ast.GetArgument

Reference an argument to the generated function.

__init__(*args, **kwargs)
property argument

Argument being accessed.

class wrenfold.ast.GetField

Reference a field on a struct: arg.field_name

__init__(*args, **kwargs)
property arg

Operand from which we wish to retrieve the specified field.

property field_name

Name of the field being accessed.

property struct_type

Type of the struct.

class wrenfold.ast.GetMatrixElement

Retrieve a value from a matrix: arg[row, col]

__init__(*args, **kwargs)
property arg

Operand matrix.

property col

Column to access.

property row

Row to access.

class wrenfold.ast.IntegerLiteral

Emit an integer literal constant.

__init__(*args, **kwargs)
property value

Value of the constant.

class wrenfold.ast.Multiply

Multiplication operation: args[0] * args[1] * ...

__init__(*args, **kwargs)
property args

Operands to the multiplication. There will always be more than one.

class wrenfold.ast.Negate

Negation operation: -arg

__init__(*args, **kwargs)
property arg

Operand being negated.

class wrenfold.ast.OptionalOutputBranch

Conditionally assign values to an optional output argument: if (<argument exists>) { ... }

__init__(*args, **kwargs)
property argument

An optional output argument.

property statements

Statements that are relevant when the optional argument is present.

class wrenfold.ast.Parenthetical

Wrap an expression in parentheses.

__init__(*args, **kwargs)
property contents

Value that should be wrapped in parentheses.

class wrenfold.ast.ReturnObject

Return a value from the function.

__init__(*args, **kwargs)
property value

Value or object being returned.

class wrenfold.ast.SpecialConstant

Emit a mathematical constant

__init__(*args, **kwargs)
property value

Enum indicating the value of the constant.

class wrenfold.ast.Ternary

A ternary expression: condition ? left : right

__init__(*args, **kwargs)
property condition

Value that should be wrapped in parentheses.

property left

Value when the condition is true.

property right

Value when the condition is false.

class wrenfold.ast.VariableRef

Reference a local variable.

__init__(*args, **kwargs)
property name

Name of the variable.