Rhai.AST (rhai_rustler v1.0.2)
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
Functions
clear_functions(ast)
Clear all function definitions in the AST.
clear_source(ast)
Clear the source.
clear_statements(ast)
Clear all statements in the AST, leaving only function definitions.
clone_functions_only(ast)
Clone the AST’s functions into a new AST. No statements are cloned.
combine(ast1, ast2)
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)
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)
Set the source.
source(ast)
Get the source if any.