pub struct Compiler<'a> {
pub implicit_return: bool,
pub errors: Vec<String>,
pub registry: &'a SymbolRegistry,
/* private fields */
}Expand description
Code generator that transforms parsed AST into bytecode instructions.
Fields§
§implicit_return: bool§errors: Vec<String>§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>
Sourcepub fn compile_checked(
&mut self,
script: &ScriptDeclaration,
label: &Path,
diagnostics: &mut DiagnosticsCollector,
) -> Option<CompiledScript>
pub fn compile_checked( &mut self, script: &ScriptDeclaration, label: &Path, diagnostics: &mut DiagnosticsCollector, ) -> Option<CompiledScript>
Checked emission for hosts that need structured errors rather than a partially generated script. The source label is never opened.
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.