// Expects the *end* offset of the jump instruction
Expects the *end* offset of the jump instruction
Expects the * end * offset of the jump instruction
fn calc_jump_offset(jump_end_offset: usize, target: usize) -> CompileResult<JumpOffset> {
        // inefficent, but this is compile time so that's okay
        let target = i128::try_from(target).unwrap();
        let jump_site = i128::try_from(jump_end_offset).unwrap();
        if let Ok(offset) = i16::try_from(target - jump_site) {
            return Ok(JumpOffset::Short(offset));
        }
        if let Ok(offset) = i32::try_from(target - jump_site) {
            return Ok(JumpOffset::Long(offset));
        }
        Err(ErrorKind::InternalLimit("could not calculate jump offset").into())
    }
fn calc_jump_offset ( jump_end_offset : usize , target : usize ) -> CompileResult < JumpOffset > { // inefficent, but this is compile time so that's okay let target = i128 :: try_from ( target ) . unwrap ( ) ; let jump_site = i128 :: try_from ( jump_end_offset ) . unwrap ( ) ; if let Ok ( offset ) = i16 :: try_from ( target - jump_site ) { return Ok ( JumpOffset :: Short ( offset ) ) ; } if let Ok ( offset ) = i32 :: try_from ( target - jump_site ) { return Ok ( JumpOffset :: Long ( offset ) ) ; } Err ( ErrorKind :: InternalLimit ( " " ) . into ( ) ) }
Expects the *end* offset of the jump instruction
Expects the * end * offset of the jump instruction
jump_end_offset
usize
target
usize