Crate spacetimedb_vm
source ·Expand description
Abstract Virtual Machine for execution of end-user logic
It optimizes the code & include a more general “query planner”
The execution is split in 3 “phases”:
1- AST formation
Generate the AST (that could be invalid according to the semantics).
This step is outside the [vm] and can be done, for example, by the SQL layer.
Use dsl to build the [expr:Expr] that build the AST.
2- AST validation
Calling eval::optimize verify the code has the correct semantics (ie: It checks types, schemas, functions are valid, etc.), and “desugar” the code in a more optimal form for later execution.
This build expr::ExprOpt that is what could be stored in the database, ie: Is like bytecode.
3- Execution
Run the AST build from expr::ExprOpt. It assumes is correct.
Modules§
- Utilities for build valid constructs for the vm.
- The different
environmentsthat support the runtime/compilation storage ofidents,functions,lambdas, etc. - Operators are implemented as “alias” of functions that are loaded at the start of the [ProgramVm] creation, ie:
- Implements the in-built operators & functions loaded by the
vm - Definition for a
Programto run code. - Define an in-progress
typeannotation.