Skip to content

Commit

Permalink
Bugfix int <-> long converting
Browse files Browse the repository at this point in the history
  • Loading branch information
hextriclosan committed Oct 12, 2024
1 parent 5d1062f commit 8ac9707
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ fn get_long(locals_opt: Option<Vec<i32>>) -> i64 {
let low = two[0];
let high = two[1];

((high as i64) << 32) | (low as i64)
let high_i64 = (high as i64) << 32;
let low_i64 = low as u32 as i64;

high_i64 | low_i64
}

fn get_float(locals: Option<Vec<i32>>) -> f32 {
Expand Down
7 changes: 3 additions & 4 deletions vm/src/execution_engine/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,13 +728,12 @@ impl Engine {
println!("IINC -> {current_val} + {const_val} = {new_val}");
}
I2L => {
let low = stack_frame.pop();
let value = stack_frame.pop() as i64;

stack_frame.push(low);
stack_frame.push(0);
stack_frame.push_i64(value);

stack_frame.incr_pc();
println!("I2L -> {low}L");
println!("I2L -> {value}L");
}
I2F => {
let value = stack_frame.pop() as f32;
Expand Down
4 changes: 2 additions & 2 deletions vm/src/system_native/system.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub(crate) fn current_time_millis_wrp(_args: &[i32]) -> Vec<i32> {
let millis = current_time_millis();

let low = millis as i32;
let high = (millis >> 32) as i32;
let high = ((millis >> 32) & 0xFFFFFFFF) as i32;
let low = (millis & 0xFFFFFFFF) as i32;

vec![high, low]
}
Expand Down

0 comments on commit 8ac9707

Please sign in to comment.