Struct debris_backends::datapack::generator::DatapackGenerator
source · pub struct DatapackGenerator<'a> {
compile_context: &'a CompileContext,
llir: &'a Llir,
function_ctx: FunctionContext,
stack: Vec<Vec<MinecraftCommand>>,
scoreboard_ctx: ScoreboardContext,
scoreboard_constants: ScoreboardConstants,
}
Expand description
This struct is used to generate a datapack from the llir representation
Fields§
§compile_context: &'a CompileContext
The compilation configuration
llir: &'a Llir
The llir to compile
function_ctx: FunctionContext
Contains the already generated functions
stack: Vec<Vec<MinecraftCommand>>
The current stack
Commands are pushed into the last value of last context
scoreboard_ctx: ScoreboardContext
A context which keeps track of the currently used scoreboards
scoreboard_constants: ScoreboardConstants
Keeps track of all constants that are used throughout the code
Implementations§
source§impl<'a> DatapackGenerator<'a>
impl<'a> DatapackGenerator<'a>
sourcefn add_command(&mut self, command: MinecraftCommand)
fn add_command(&mut self, command: MinecraftCommand)
Adds a command to the current stack
sourcefn catch_output(&mut self, node: &Node) -> Vec<MinecraftCommand>
fn catch_output(&mut self, node: &Node) -> Vec<MinecraftCommand>
Handles the given command and returns the produced output
sourcefn handle_main_function(
&mut self,
block_ids: impl Iterator<Item = BlockId>
) -> bool
fn handle_main_function( &mut self, block_ids: impl Iterator<Item = BlockId> ) -> bool
Handles the main function
The main_id
marks the main function.
sourcefn handle_ticking_function(
&mut self,
block_ids: impl Iterator<Item = BlockId>
) -> bool
fn handle_ticking_function( &mut self, block_ids: impl Iterator<Item = BlockId> ) -> bool
Handles functions that run every tick
fn handle_extern_functions(&mut self, path: ExternItemPath, id: BlockId)
fn handle(&mut self, node: &Node)
fn handle_function(&mut self, function: &Function)
fn handle_fast_store(&mut self, fast_store: &FastStore)
fn handle_fast_store_from_result( &mut self, fast_store_from_result: &FastStoreFromResult )
fn handle_binary_operation(&mut self, binary_operation: &BinaryOperation)
fn handle_condition(&mut self, condition: &Condition)
sourcefn branch_taken_hack_required(&self, branch: &Branch) -> Option<BranchKind>
fn branch_taken_hack_required(&self, branch: &Branch) -> Option<BranchKind>
Returns whether a flag is required to make sure only the correct branch of a conditional gets run
fn handle_branch(&mut self, branch: &Branch)
fn handle_call(&mut self, call: &Call)
fn handle_execute(&mut self, execute: &ExecuteRaw)
fn handle_write(&mut self, write: &WriteMessage)
sourcefn get_condition(
&mut self,
condition: &Condition,
and_then: Option<MinecraftCommand>
) -> MinecraftCommand
fn get_condition( &mut self, condition: &Condition, and_then: Option<MinecraftCommand> ) -> MinecraftCommand
Evaluates this condition and, if it is true, calls and_then
.
Returns the command instead of adding it to the current stack.
fn get_condition_inner( &mut self, condition: &Condition, parts: &mut Vec<ExecuteComponent> )
sourcefn get_as_single_command(
&mut self,
commands: Vec<MinecraftCommand>
) -> Option<MinecraftCommand>
fn get_as_single_command( &mut self, commands: Vec<MinecraftCommand> ) -> Option<MinecraftCommand>
Converts a bunch of minecraft commands into a single command
sourcefn extend_command_by(
&mut self,
command: MinecraftCommand,
other: MinecraftCommand
) -> MinecraftCommand
fn extend_command_by( &mut self, command: MinecraftCommand, other: MinecraftCommand ) -> MinecraftCommand
If command
is a function call, pushes other
to that function
Otherwise, creates a new function that contains both command
and other
and returns a call to that