use std::fs;
use crate::instruction::Inst;
#[allow(dead_code)]
pub fn load_program_from_json(path: &str) -> Result<Vec<Inst>, String> {
let json_str = fs::read_to_string(path)
.map_err(|e| format!("Failed to read file: {}", e))?;
let program: Vec<Inst> = serde_json::from_str(&json_str)
.map_err(|e| format!("Failed to parse JSON: {}", e))?;
Ok(program)
}
#[allow(dead_code)]
pub fn get_asm(ir: Vec<Inst>, output: &str) -> Result<(), Box<dyn std::error::Error>>{
let str = serde_json::to_string_pretty(&ir)?;
fs::write(output, str)?;
Ok(())
}