fn vm_print_asm(args: &ArgMatches) {
    let function_name = args.value_of("function").unwrap();
    let file_name = args.value_of("bytecode").unwrap();

    if let Some(_) = args.value_of("architecture") {
        todo!("print-asm arch option")
    }

    let mut module_loader = ModuleLoader::from_module(std_module());
    let id = module_loader.load_module(file_name).unwrap();
    let module = module_loader
        .get_by_id(id)
        .expect("missing module")
        .expect("missing impl");

    let func = match module.get_function_by_name(function_name) {
        Some(r) => r,
        None => panic!("No such function: {}", function_name)
    };

    let mut state = JITState::default();
    JITEngine::compile(&mut state, &module, func);
    let bytes = JITEngine::get_function_bytes(&mut state, func);

    // Use iced_x86 to decompile
    use iced_x86::{Decoder, Formatter, Instruction, NasmFormatter};

    let mut decoder = Decoder::new(64, bytes, 0);
    let mut formatter = NasmFormatter::new();
    let mut instruction = Instruction::default();
    let mut output = String::new();
    while decoder.can_decode() {
        decoder.decode_out(&mut instruction);
        output.clear();
        formatter.format(&instruction, &mut output);
        print!("{:08X} ", instruction.ip());
        println!("{}", output);
    }
}
/// Prints a compiled function in assembly format.
///
/// The function is specified by the `function` command line argument.
/// The module is specified by the `bytecode` command line argument.
///
/// Arguments: 
/// * `args`: Command line arguments
Prints a compiled function in assembly format.
The function is specified by the `function` command line argument.
The module is specified by the `bytecode` command line argument.

`args`: Command line arguments
Prints a compiled function in assembly format . The function is specified by the ` function ` command line argument . The module is specified by the ` bytecode ` command line argument . ` args ` : Command line arguments
fn vm_print_asm(args: &ArgMatches) {
    let function_name = args.value_of("function").unwrap();
    let file_name = args.value_of("bytecode").unwrap();
    if let Some(_) = args.value_of("architecture") {
        todo!("print-asm arch option")
    }
    let mut module_loader = ModuleLoader::from_module(std_module());
    let id = module_loader.load_module(file_name).unwrap();
    let module = module_loader
        .get_by_id(id)
        .expect("missing module")
        .expect("missing impl");
    let func = match module.get_function_by_name(function_name) {
        Some(r) => r,
        None => panic!("No such function: {}", function_name)
    };
    let mut state = JITState::default();
    JITEngine::compile(&mut state, &module, func);
    let bytes = JITEngine::get_function_bytes(&mut state, func);
    // Use iced_x86 to decompile
    use iced_x86::{Decoder, Formatter, Instruction, NasmFormatter};
    let mut decoder = Decoder::new(64, bytes, 0);
    let mut formatter = NasmFormatter::new();
    let mut instruction = Instruction::default();
    let mut output = String::new();
    while decoder.can_decode() {
        decoder.decode_out(&mut instruction);
        output.clear();
        formatter.format(&instruction, &mut output);
        print!("{:08X} ", instruction.ip());
        println!("{}", output);
    }
}
fn vm_print_asm ( args : & ArgMatches ) { let function_name = args . value_of ( " " ) . unwrap ( ) ; let file_name = args . value_of ( " " ) . unwrap ( ) ; if let Some ( _ ) = args . value_of ( " " ) { todo ! ( " " ) } let mut module_loader = ModuleLoader :: from_module ( std_module ( ) ) ; let id = module_loader . load_module ( file_name ) . unwrap ( ) ; let module = module_loader . get_by_id ( id ) . expect ( " " ) . expect ( " " ) ; let func = match module . get_function_by_name ( function_name ) { Some ( r ) => r , None => panic ! ( " " function_name ) } ; let mut state = JITState :: default ( ) ; JITEngine :: compile ( & mut state , & module , func ) ; let bytes = JITEngine :: get_function_bytes ( & mut state , func ) ; // Use iced_x86 to decompile use iced_x86 :: { Decoder , Formatter , Instruction , NasmFormatter } ; let mut decoder = Decoder :: new ( 64 , bytes , 0 ) ; let mut formatter = NasmFormatter :: new ( ) ; let mut instruction = Instruction :: default ( ) ; let mut output = String :: new ( ) ; while decoder . can_decode ( ) { decoder . decode_out ( & mut instruction ) ; output . clear ( ) ; formatter . format ( & instruction , & mut output ) ; print ! ( " " instruction ip ( ) ) ; println ! ( " " output ) ; } }
Prints a compiled function in assembly format.
Prints a compiled function in assembly format .
args
&ArgMatches
args
&ArgMatches