ast

class wrenfold.ast.Add

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

__init__(*args, **kwargs)
__new__(**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)
__new__(**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)
__new__(**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)
__new__(**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)
__new__(**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__

Array access operator.

__init__(*args, **kwargs)
__iter__
__len__
__new__(**kwargs)
class wrenfold.ast.BooleanLiteral

Emit a boolean literal constant.

__init__(*args, **kwargs)
__new__(**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)
__new__(**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)
__new__(**kwargs)
property args

(self) -> wrenfold.ast.AstSpan

property function

(self) -> wf::external_function

class wrenfold.ast.CallStdFunction

Invoke a standard library math function.

__init__(*args, **kwargs)
__new__(**kwargs)
property args

Arguments to the function.

property function

The function being invoked.

class wrenfold.ast.Cast

Cast a numerical value.

__init__(*args, **kwargs)
__new__(**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)
__new__(**kwargs)
property content

Comment as a single string.

split_lines

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

class wrenfold.ast.Compare

Compare two operands.

__init__(*args, **kwargs)
__new__(**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)
__new__(**kwargs)
get_field_value

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)
__new__(**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)
__new__(**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)
__new__(**kwargs)
property left

Left operand (numerator).

property right

Right operand (denominator).

class wrenfold.ast.FloatLiteral

Emit a floating-point literal constant.

__init__(*args, **kwargs)
__new__(**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)
__new__(**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)
__new__(**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)
__new__(**kwargs)
property argument

Argument being accessed.

class wrenfold.ast.GetField

Reference a field on a struct: arg.field_name

__init__(*args, **kwargs)
__new__(**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)
__new__(**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)
__new__(**kwargs)
property value

Value of the constant.

class wrenfold.ast.Multiply

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

__init__(*args, **kwargs)
__new__(**kwargs)
property args

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

class wrenfold.ast.Negate

Negation operation: -arg

__init__(*args, **kwargs)
__new__(**kwargs)
property arg

Operand being negated.

class wrenfold.ast.OptionalOutputBranch

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

__init__(*args, **kwargs)
__new__(**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)
__new__(**kwargs)
property contents

Value that should be wrapped in parentheses.

class wrenfold.ast.ReturnObject

Return a value from the function.

__init__(*args, **kwargs)
__new__(**kwargs)
property value

Value or object being returned.

class wrenfold.ast.SpecialConstant

Emit a mathematical constant

__init__(*args, **kwargs)
__new__(**kwargs)
property value

Enum indicating the value of the constant.

class wrenfold.ast.Ternary

A ternary expression: condition ? left : right

__init__(*args, **kwargs)
__new__(**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)
__new__(**kwargs)
property name

Name of the variable.