Rhai.AST (rhai_rustler v1.2.0)

Compiled AST (abstract syntax tree) of a Rhai script.

Summary

Functions

Clear all function definitions in the AST.

Clear the source.

Clear all statements in the AST, leaving only function definitions.

Clone the AST’s functions into a new AST. No statements are cloned.

Combine one AST with another. The second AST is consumed.

Create an empty AST.

Does this AST contain script-defined functions?

Merge two AST into one. Both AST’s are untouched and a new, merged, version is returned.

Set the source.

Get the source if any.

Types

t()

@type t() :: %Rhai.AST{reference: term(), resource: term()}

Functions

clear_functions(ast)

@spec clear_functions(t()) :: t()

Clear all function definitions in the AST.

clear_source(ast)

@spec clear_source(t()) :: t()

Clear the source.

clear_statements(ast)

@spec clear_statements(t()) :: t()

Clear all statements in the AST, leaving only function definitions.

clone_functions_only(ast)

@spec clone_functions_only(t()) :: t()

Clone the AST’s functions into a new AST. No statements are cloned.

combine(ast1, ast2)

@spec combine(t(), t()) :: t()

Combine one AST with another. The second AST is consumed.

Statements in the second AST are simply appended to the end of the first without any processing. Thus, the return value of the first AST (if using expression-statement syntax) is buried. Of course, if the first AST uses a return statement at the end, then the second AST will essentially be dead code.

All script-defined functions in the second AST overwrite similarly-named functions in the first AST with the same number of parameters.

See example in the Rhai documentation.

empty()

Create an empty AST.

has_functions?(ast)

@spec has_functions?(t()) :: bool()

Does this AST contain script-defined functions?

merge(ast1, ast2)

@spec merge(t(), t()) :: t()

Merge two AST into one. Both AST’s are untouched and a new, merged, version is returned.

Statements in the second AST are simply appended to the end of the first without any processing. Thus, the return value of the first AST (if using expression-statement syntax) is buried. Of course, if the first AST uses a return statement at the end, then the second AST will essentially be dead code.

All script-defined functions in the second AST overwrite similarly-named functions in the first AST with the same number of parameters.

See example in the Rhai documentation.

set_source(ast, source)

@spec set_source(t(), String.t()) :: t()

Set the source.

source(ast)

@spec source(t()) :: String.t() | nil

Get the source if any.