Rhai.AST (rhai_rustler v1.1.1)

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

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

Functions

Link to this function

clear_functions(ast)

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

Clear all function definitions in the AST.

Link to this function

clear_source(ast)

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

Clear the source.

Link to this function

clear_statements(ast)

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

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

Link to this function

clone_functions_only(ast)

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

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

Link to this function

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.

Create an empty AST.

Link to this function

has_functions?(ast)

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

Does this AST contain script-defined functions?

Link to this function

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.

Link to this function

set_source(ast, source)

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

Set the source.

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

Get the source if any.