rusty-jvm 0.5.0

An implementation of a Java Virtual Machine (JVM).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::vm::error::Result;
use crate::vm::heap::heap::with_heap_write_lock;
use rand::rand_core::OsRng;
use rand::TryRngCore;

pub(crate) fn native_generate_seed_wrp(args: &[i32]) -> Result<Vec<i32>> {
    let byte_array_ref = args[0];
    let ret = native_generate_seed(byte_array_ref)?;
    Ok(vec![if ret { 1 } else { 0 }])
}

fn native_generate_seed(byte_array_ref: i32) -> Result<bool> {
    with_heap_write_lock(|h| {
        let mut raw_data = h.get_entire_raw_data_mut(byte_array_ref)?;
        OsRng.try_fill_bytes(raw_data.as_mut_slice())?;
        Ok(true)
    })
}