pub struct Compiler<'a> {
pub registry: &'a SymbolRegistry,
/* private fields */
}Expand description
Code generator that transforms parsed AST into bytecode instructions.
Fields§
§registry: &'a SymbolRegistryBorrowed read-only during code generation, so many Compilers can share
one registry across threads (each thread builds its own scratch state).
Implementations§
Source§impl<'a> Compiler<'a>
impl<'a> Compiler<'a>
pub fn new(registry: &'a 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<'a> Freeze for Compiler<'a>
impl<'a> RefUnwindSafe for Compiler<'a>
impl<'a> Send for Compiler<'a>
impl<'a> Sync for Compiler<'a>
impl<'a> Unpin for Compiler<'a>
impl<'a> UnsafeUnpin for Compiler<'a>
impl<'a> UnwindSafe for Compiler<'a>
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