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>

source

fn add_command(&mut self, command: MinecraftCommand)

Adds a command to the current stack

source

fn catch_output(&mut self, node: &Node) -> Vec<MinecraftCommand>

Handles the given command and returns the produced output

source

fn handle_main_function( &mut self, block_ids: impl Iterator<Item = BlockId> ) -> bool

Handles the main function

The main_id marks the main function.

source

fn handle_ticking_function( &mut self, block_ids: impl Iterator<Item = BlockId> ) -> bool

Handles functions that run every tick

source

fn handle_extern_functions(&mut self, path: ExternItemPath, id: BlockId)

source

fn handle(&mut self, node: &Node)

source

fn handle_function(&mut self, function: &Function)

source

fn handle_fast_store(&mut self, fast_store: &FastStore)

source

fn handle_fast_store_from_result( &mut self, fast_store_from_result: &FastStoreFromResult )

source

fn handle_binary_operation(&mut self, binary_operation: &BinaryOperation)

source

fn handle_condition(&mut self, condition: &Condition)

source

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

source

fn handle_branch(&mut self, branch: &Branch)

source

fn handle_call(&mut self, call: &Call)

source

fn handle_execute(&mut self, execute: &ExecuteRaw)

source

fn handle_write(&mut self, write: &WriteMessage)

source

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.

source

fn get_condition_inner( &mut self, condition: &Condition, parts: &mut Vec<ExecuteComponent> )

source

fn get_as_single_command( &mut self, commands: Vec<MinecraftCommand> ) -> Option<MinecraftCommand>

Converts a bunch of minecraft commands into a single command

source

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

source

pub fn new(ctx: &'a CompileContext, llir: &'a Llir) -> Self

source

pub fn build(self) -> Directory

Trait Implementations§

source§

impl<'a> Debug for DatapackGenerator<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for DatapackGenerator<'a>

§

impl<'a> !Send for DatapackGenerator<'a>

§

impl<'a> !Sync for DatapackGenerator<'a>

§

impl<'a> Unpin for DatapackGenerator<'a>

§

impl<'a> !UnwindSafe for DatapackGenerator<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.