Skip to main content

luaur_compiler/methods/
compiler_patch_jump.rs

1use crate::records::compile_error::CompileError;
2use crate::records::compiler::Compiler;
3use luaur_ast::records::ast_node::AstNode;
4use luaur_ast::records::location::Location;
5
6impl Compiler {
7    pub fn patch_jump(&mut self, node: *mut AstNode, label: usize, target: usize) {
8        let ok = unsafe { (*self.bytecode).patch_jump_d(label, target) };
9        if !ok {
10            let location = unsafe { (*node).location };
11            CompileError::raise(
12                &location,
13                format_args!("Exceeded jump distance limit; simplify the code to compile"),
14            );
15        }
16    }
17}