pub struct Compiler {
pub registry: SymbolRegistry,
/* private fields */
}Expand description
Code generator that transforms parsed AST into bytecode instructions.
Fields§
§registry: SymbolRegistryImplementations§
Source§impl Compiler
impl Compiler
pub fn new(registry: SymbolRegistry) -> Self
Sourcepub fn compile_script(&mut self, script: &ScriptDeclaration) -> CompiledScript
pub fn compile_script(&mut self, script: &ScriptDeclaration) -> CompiledScript
Compile a single script declaration into bytecode.
Sourcepub fn validate_trigger_subject(
trigger: &str,
entity_name: &str,
registry: &SymbolRegistry,
) -> Option<String>
pub fn validate_trigger_subject( trigger: &str, entity_name: &str, registry: &SymbolRegistry, ) -> Option<String>
Returns Some(error message) if [trigger,entity_name] resolved a
trigger byte but failed to resolve entity_name to a real subject,
which would silently produce an unreachable script (lookup_key = -1).
Returns None for legitimate cases:
- bare
_wildcard (global trigger, no subject) _categoryform (category lookup — caller validates separately)- coord-shaped triggers (
zone,zoneexit,mapzone,mapzoneexit) - name-keyed triggers (
queue,timer,walktrigger,proc,label, …)
Sourcepub fn compute_lookup_key(
trigger: &str,
entity_name: &str,
registry: &SymbolRegistry,
) -> i32
pub fn compute_lookup_key( trigger: &str, entity_name: &str, registry: &SymbolRegistry, ) -> i32
Compute the CS2 Neptune lookup key for a script.
Formula: entity_id * 1024 + 512 + trigger_byte, or -1 if not applicable.
For global scripts (entity=“_”), returns just trigger_byte.
Auto Trait Implementations§
impl Freeze for Compiler
impl RefUnwindSafe for Compiler
impl Send for Compiler
impl Sync for Compiler
impl Unpin for Compiler
impl UnsafeUnpin for Compiler
impl UnwindSafe for Compiler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more