Improve --irrun option to print byte size value

This commit is contained in:
Chunmyong Park
2020-06-10 02:45:57 +00:00
parent 5101b294b6
commit 9ca05ba893
2 changed files with 13 additions and 7 deletions

View File

@@ -116,7 +116,13 @@ fn compile_ir(
if matches.is_present("irrun") {
let result = ir::interp(input, Vec::new()).unwrap();
println!("[result] {:?}", result);
let (value, width, is_signed) = result.get_int().expect("non-integer value occurs");
assert_eq!(width, 32);
assert!(is_signed);
// When obtain status from `gcc` executable process, status value is truncated to byte size.
// So, we also truncate result value to byte size before printing it.
println!("[result] {:?}", value as u8);
return;
}