src/compiler.c
// Patch all placeholder ops in the current code to jumps to the current location
Patch all placeholder ops in the current code to jumps to the current location
Patch all placeholder ops in the current code to jumps to the current location
static void _patch_jumps(int from_location, OpCode patch_code) {
    int i = from_location;
    chunk_t *chunk = &_current->function->chunk;
    while ( i < chunk->count) {
        if ( chunk->code[i] == patch_code ) {
            chunk->code[i] = OP_JUMP;
            _patch_jump(i+1);
            i += 3;
        } else {
            i += 1 + l_op_get_arg_size_bytes(chunk->code, chunk->constants.values, i);
        }
    }
}
static void _patch_jumps ( int from_location , OpCode patch_code ) { int i = from_location ; chunk_t * chunk = & _current -> function -> chunk ; while ( i < chunk -> count ) { if ( chunk -> code [ i ] == patch_code ) { chunk -> code [ i ] = OP_JUMP ; _patch_jump ( i + 1 ) ; i += 3 ; } else { i += 1 + l_op_get_arg_size_bytes ( chunk -> code , chunk -> constants . values , i ) ; } } }
Patch all placeholder ops in the current code to jumps to the current location
Patch all placeholder ops in the current code to jumps to the current location
// if a break op code is found // update it to a jump // and patch the current location // otherwise skip forward in the chunk using the operation type appropriate size