diff --git a/src/classic/clvm_tools/cmds.rs b/src/classic/clvm_tools/cmds.rs index af507310..72dba212 100644 --- a/src/classic/clvm_tools/cmds.rs +++ b/src/classic/clvm_tools/cmds.rs @@ -30,6 +30,7 @@ use crate::classic::clvm::sexp::{enlist, proper_list, sexp_as_bin}; use crate::classic::clvm::OPERATORS_LATEST_VERSION; use crate::classic::clvm_tools::binutils::{assemble_from_ir, disassemble, disassemble_with_kw}; use crate::classic::clvm_tools::clvmc::write_sym_output; +use crate::classic::clvm_tools::comp_input::{get_disassembly_ver, RunAndCompileInputData}; use crate::classic::clvm_tools::debug::check_unused; use crate::classic::clvm_tools::debug::{ program_hash_from_program_env_cons, start_log_after, trace_pre_eval, trace_to_table, @@ -54,12 +55,9 @@ use crate::compiler::cldb::{ }; use crate::compiler::cldb_hierarchy::{HierarchialRunner, HierarchialStepResult, RunPurpose}; use crate::compiler::clvm::start_step; -use crate::compiler::compiler::{compile_file, DefaultCompilerOpts}; +use crate::compiler::compiler::DefaultCompilerOpts; use crate::compiler::comptypes::{CompileErr, CompilerOpts}; -use crate::compiler::debug::build_symbol_table_mut; -use crate::compiler::dialect::detect_modern; use crate::compiler::frontend::frontend; -use crate::compiler::optimize::maybe_finalize_program_via_classic_optimizer; use crate::compiler::preprocessor::gather_dependencies; use crate::compiler::prims; use crate::compiler::runtypes::RunFailure; @@ -510,13 +508,15 @@ pub fn cldb_hierarchy(args: CldbHierarchyArgs) -> Vec>, location: Option, c: &str| { + let mut parse_error = BTreeMap::new(); + if let Some(l) = location { + parse_error.insert( + "Error-Location".to_string(), + YamlElement::String(l.to_string()), + ); + }; + parse_error.insert("Error".to_string(), YamlElement::String(c.to_string())); + output.push(parse_error.clone()); + println!("{}", yamlette_string(output)); + }; let parsed_args: HashMap = match parser.parse_args(&arg_vec) { Err(e) => { @@ -594,25 +602,6 @@ pub fn cldb(args: &[String]) { Ok(pa) => pa, }; - if let Some(ArgumentValue::ArgArray(v)) = parsed_args.get("include") { - for p in v { - if let ArgumentValue::ArgString(_, s) = p { - search_paths.push(s.to_string()); - } - } - } - - if let Some(ArgumentValue::ArgString(file, path_or_code)) = parsed_args.get("path_or_code") { - input_file.clone_from(file); - input_program = path_or_code.to_string(); - } - - if let Some(ArgumentValue::ArgString(_, s)) = parsed_args.get("env") { - parsed_args_result = s.to_string(); - } - - let mut allocator = Allocator::new(); - let symbol_table = parsed_args .get("symbol_table") .and_then(|jstring| match jstring { @@ -624,80 +613,50 @@ pub fn cldb(args: &[String]) { _ => None, }); + let parsed = match RunAndCompileInputData::new(&mut allocator, &parsed_args) { + Ok(r) => r, + Err(e) => { + println!("FAIL: {e}"); + return; + } + }; + let only_print = parsed_args.get("only_print").map(|_| true).unwrap_or(false); let favor_hex = parsed_args.get("favor_hex").map(|_| true).unwrap_or(false); - let do_optimize = parsed_args - .get("optimize") - .map(|x| matches!(x, ArgumentValue::ArgBool(true))) - .unwrap_or_else(|| false); let runner = Rc::new(DefaultProgramRunner::new()); - let use_filename = input_file - .clone() - .unwrap_or_else(|| "*command*".to_string()); - let opts = Rc::new(DefaultCompilerOpts::new(&use_filename)) - .set_optimize(do_optimize) - .set_search_paths(&search_paths); let mut use_symbol_table = symbol_table.unwrap_or_default(); - let mut output = Vec::new(); let res = match parsed_args.get("hex") { Some(ArgumentValue::ArgBool(true)) => hex_to_modern_sexp( &mut allocator, &use_symbol_table, prog_srcloc.clone(), - &input_program, + &parsed.program.content, ) .map_err(|_| CompileErr(prog_srcloc, "Failed to parse hex".to_string())), - _ => { - // don't clobber a symbol table brought in via -y unless we're - // compiling here. - let unopt_res = compile_file( - &mut allocator, - runner.clone(), - opts.clone(), - &input_program, - &mut use_symbol_table, - ); - unopt_res.and_then(|x| { - maybe_finalize_program_via_classic_optimizer( - &mut allocator, - runner.clone(), - opts, - false, - &x, - ) - }) - } + _ => parsed.compile_modern(&mut allocator, &mut use_symbol_table), }; let program = match res { Ok(r) => r, Err(c) => { - let mut parse_error = BTreeMap::new(); - parse_error.insert( - "Error-Location".to_string(), - YamlElement::String(c.0.to_string()), - ); - parse_error.insert("Error".to_string(), YamlElement::String(c.1)); - output.push(parse_error.clone()); - println!("{}", yamlette_string(&output)); + errorize(&mut output, Some(c.0.clone()), &c.1); return; } }; - match parsed_args.get("hex") { + let env_loc = Srcloc::start("*args*"); + let env = match parsed_args.get("hex") { Some(ArgumentValue::ArgBool(true)) => { match hex_to_modern_sexp( &mut allocator, &HashMap::new(), args_srcloc, - &parsed_args_result, + &parsed.args.content, ) { - Ok(r) => { - args = r; - } + Ok(r) => r, Err(p) => { let mut parse_error = BTreeMap::new(); parse_error.insert("Error".to_string(), YamlElement::String(p.to_string())); @@ -707,10 +666,13 @@ pub fn cldb(args: &[String]) { } } } - _ => match parse_sexp(Srcloc::start("*arg*"), parsed_args_result.bytes()) { + + _ => match parse_sexp(env_loc.clone(), parsed.args.content.bytes()) { Ok(r) => { if !r.is_empty() { - args = r[0].clone(); + r[0].clone() + } else { + Rc::new(sexp::SExp::Nil(env_loc)) } } Err(c) => { @@ -731,10 +693,16 @@ pub fn cldb(args: &[String]) { for p in prims::prims().iter() { prim_map.insert(p.0.clone(), Rc::new(p.1.clone())); } - let program_lines: Rc> = - Rc::new(input_program.lines().map(|x| x.to_string()).collect()); + let program_lines: Rc> = Rc::new( + parsed + .program + .content + .lines() + .map(|x| x.to_string()) + .collect(), + ); let cldbenv = CldbRunEnv::new( - input_file.clone(), + parsed.program.path.clone(), program_lines.clone(), Box::new(CldbNoOverride::new_symbols(use_symbol_table.clone())), ); @@ -743,11 +711,11 @@ pub fn cldb(args: &[String]) { let result = cldb_hierarchy(CldbHierarchyArgs { runner, prim_map: Rc::new(prim_map), - input_file_name: input_file, + input_file_name: parsed.program.path.clone(), lines: program_lines, symbol_table: Rc::new(use_symbol_table), prog: program, - args, + args: env, flags: if favor_hex { FAVOR_HEX } else { 0 }, }); @@ -757,7 +725,7 @@ pub fn cldb(args: &[String]) { return; } - let step = start_step(program, args); + let step = start_step(program, env); let mut cldbrun = CldbRun::new(runner, Rc::new(prim_map), Box::new(cldbenv), step); if favor_hex { cldbrun.set_flags(FAVOR_HEX); @@ -931,15 +899,9 @@ fn perform_preprocessing( Ok(()) } -fn get_disassembly_ver(p: &HashMap) -> Option { - if let Some(ArgumentValue::ArgInt(x)) = p.get("operators_version") { - return Some(*x as usize); - } - - None -} - pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, default_stage: u32) { + let mut allocator = Allocator::new(); + let props = TArgumentParserProps { description: "Execute a clvm script.".to_string(), prog: format!("clvm_tools {tool_name}"), @@ -1122,6 +1084,14 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul return; } + let parsed = match RunAndCompileInputData::new(&mut allocator, &parsed_args) { + Ok(r) => r, + Err(e) => { + stdout.write_str(&format!("FAIL: {e}\n")); + return; + } + }; + let empty_map = HashMap::new(); let keywords = match parsed_args.get("no_keywords") { Some(ArgumentValue::ArgBool(_b)) => &empty_map, @@ -1134,47 +1104,8 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul // more info). let extra_symbol_info = parsed_args.get("extra_syms").map(|_| true).unwrap_or(false); - // Get name of included file so we can use it to initialize the compiler's - // runner, which contains operators used at compile time in clvm to update - // symbols. This is the only means we have of communicating with the - // compilation process from this level. - let mut input_file = None; - let mut input_program = "()".to_string(); - - if let Some(ArgumentValue::ArgString(file, path_or_code)) = parsed_args.get("path_or_code") { - input_file.clone_from(file); - input_program = path_or_code.to_string(); - } - - let reported_input_file = input_file - .as_ref() - .cloned() - .unwrap_or_else(|| "*command*".to_string()); - - let search_paths = if let Some(ArgumentValue::ArgArray(v)) = parsed_args.get("include") { - v.iter() - .filter_map(|p| { - if let ArgumentValue::ArgString(_, s) = p { - Some(s.to_string()) - } else { - None - } - }) - .collect() - } else { - Vec::new() - }; - - let mut allocator = Allocator::new(); - - let input_serialized = None; - let mut input_sexp: Option = None; - let time_start = SystemTime::now(); - let mut time_read_hex = SystemTime::now(); - let mut time_assemble = SystemTime::now(); - - let mut input_args = "()".to_string(); + let time_read_hex = SystemTime::now(); if let ( Some(ArgumentValue::ArgBool(true)), @@ -1184,7 +1115,7 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul parsed_args.get("path_or_code"), ) { if let Some(filename) = &file { - let opts = DefaultCompilerOpts::new(filename).set_search_paths(&search_paths); + let opts = DefaultCompilerOpts::new(filename).set_search_paths(&parsed.search_paths); match gather_dependencies(opts, filename, file_content) { Err(e) => { @@ -1203,100 +1134,21 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul return; } - if let Some(ArgumentValue::ArgString(file, path_or_code)) = parsed_args.get("env") { - input_file.clone_from(file); - input_args = path_or_code.to_string(); - } - - let special_runner = - run_program_for_search_paths(&reported_input_file, &search_paths, extra_symbol_info); + let special_runner = run_program_for_search_paths( + &parsed.use_filename(), + &parsed.search_paths, + extra_symbol_info, + ); // Ensure we know the user's wishes about the disassembly version here. special_runner.set_operators_version(get_disassembly_ver(&parsed_args)); let dpr = special_runner.clone(); let run_program = special_runner; - match parsed_args.get("hex") { - Some(_) => { - let assembled_serialized = Bytes::new_validated(Some(UnvalidatedBytesFromType::Hex( - input_program.to_string(), - ))); - - let env_serialized = if input_args.is_empty() { - Bytes::new_validated(Some(UnvalidatedBytesFromType::Hex("80".to_string()))) - } else { - Bytes::new_validated(Some(UnvalidatedBytesFromType::Hex(input_args))) - }; - - let ee = match env_serialized { - Ok(x) => x, - Err(e) => { - stdout.write_str(&format!("FAIL: {e}\n")); - return; - } - }; - time_read_hex = SystemTime::now(); - - let mut prog_stream = Stream::new(Some(match assembled_serialized { - Ok(x) => x, - Err(e) => { - stdout.write_str(&format!("FAIL: {e}\n")); - return; - } - })); - - let input_prog_sexp = sexp_from_stream( - &mut allocator, - &mut prog_stream, - Box::new(SimpleCreateCLVMObject {}), - ) - .map(|x| Some(x.1)) - .unwrap(); - - let mut arg_stream = Stream::new(Some(ee)); - let input_arg_sexp = sexp_from_stream( - &mut allocator, - &mut arg_stream, - Box::new(SimpleCreateCLVMObject {}), - ) - .map(|x| Some(x.1)) - .unwrap(); - if let (Some(ip), Some(ia)) = (input_prog_sexp, input_arg_sexp) { - input_sexp = allocator.new_pair(ip, ia).ok(); - } - } - _ => { - let src_sexp; - if let Some(ArgumentValue::ArgString(f, content)) = parsed_args.get("path_or_code") { - match read_ir(content) { - Ok(s) => { - input_program.clone_from(content); - input_file.clone_from(f); - src_sexp = s; - } - Err(e) => { - stdout.write_str(&format!("FAIL: {e}\n")); - return; - } - } - } else { - stdout.write_str(&format!("FAIL: {}\n", "non-string argument")); - return; - } - - let assembled_sexp = assemble_from_ir(&mut allocator, Rc::new(src_sexp)).unwrap(); - let mut parsed_args_result = "()".to_string(); - - if let Some(ArgumentValue::ArgString(_f, s)) = parsed_args.get("env") { - parsed_args_result = s.to_string(); - } - - let env_ir = read_ir(&parsed_args_result).unwrap(); - let env = assemble_from_ir(&mut allocator, Rc::new(env_ir)).unwrap(); - time_assemble = SystemTime::now(); + let time_assemble = SystemTime::now(); - input_sexp = allocator.new_pair(assembled_sexp, env).ok(); - } - } + let input_sexp = allocator + .new_pair(parsed.program.parsed, parsed.args.parsed) + .ok(); // Symbol table related checks: should one be loaded, should one be saved. // This code is confusingly woven due to 'run' and 'brun' serving many roles. @@ -1334,9 +1186,8 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul .unwrap_or(false); // Dialect is now not overall optional. - let dialect = input_sexp.map(|i| detect_modern(&mut allocator, i)); let mut stderr_output = |s: String| { - if dialect.as_ref().and_then(|d| d.stepping).is_some() { + if parsed.dialect.stepping.is_some() { eprintln!("{s}"); } else { stdout.write_str(&s); @@ -1344,9 +1195,9 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul }; if do_check_unused { - let opts = - Rc::new(DefaultCompilerOpts::new(&reported_input_file)).set_search_paths(&search_paths); - match check_unused(opts, &input_program) { + let opts = Rc::new(DefaultCompilerOpts::new(&parsed.use_filename())) + .set_search_paths(&parsed.search_paths); + match check_unused(opts, &parsed.program.content) { Ok((success, output)) => { stderr_output(output); if !success { @@ -1360,70 +1211,43 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul } } - let symbol_table_output = parsed_args - .get("symbol_output_file") - .and_then(|s| { - if let ArgumentValue::ArgString(_, v) = s { - Some(v.clone()) - } else { - None - } - }) - .unwrap_or_else(|| "main.sym".to_string()); - // In testing: short circuit for modern compilation. - if let Some(stepping) = dialect.as_ref().and_then(|d| d.stepping) { - let do_optimize = parsed_args - .get("optimize") - .map(|x| matches!(x, ArgumentValue::ArgBool(true))) - .unwrap_or_else(|| false); - let runner = Rc::new(DefaultProgramRunner::new()); - let use_filename = input_file.unwrap_or_else(|| "*command*".to_string()); - let opts = Rc::new(DefaultCompilerOpts::new(&use_filename)) - .set_dialect(dialect.unwrap_or_default()) - .set_optimize(do_optimize || stepping > 22) - .set_search_paths(&search_paths) - .set_frontend_opt(stepping == 22) - .set_disassembly_ver(get_disassembly_ver(&parsed_args)); - let mut symbol_table = HashMap::new(); - + if parsed.dialect.stepping.is_some() { // Short circuit preprocessing display. if parsed_args.contains_key("preprocess") { - if let Err(e) = perform_preprocessing(stdout, opts, &use_filename, &input_program) { + if let Err(e) = perform_preprocessing( + stdout, + parsed.opts.clone(), + &parsed.use_filename(), + &parsed.program.content, + ) { stdout.write_str(&format!("{}: {}", e.0, e.1)); } return; } - let unopt_res = compile_file( - &mut allocator, - runner.clone(), - opts.clone(), - &input_program, - &mut symbol_table, - ); - let res = unopt_res.and_then(|x| { - maybe_finalize_program_via_classic_optimizer( - &mut allocator, - runner, - opts, - do_optimize, - &x, - ) - }); + let mut symbol_table = HashMap::new(); + let res = parsed + .compile_modern(&mut allocator, &mut symbol_table) + .and_then(|r| { + write_sym_output(&symbol_table, &parsed.symbol_table_output).map_err(|e| { + CompileErr( + Srcloc::start(&parsed.use_filename()), + format!("writing symbols: {e:?}"), + ) + })?; + + Ok(r) + }); match res { Ok(r) => { stdout.write_str(&r.to_string()); - - build_symbol_table_mut(&mut symbol_table, &r); - write_sym_output(&symbol_table, &symbol_table_output).expect("writing symbols"); } Err(c) => { stdout.write_str(&format!("{}: {}", c.0, c.1)); } } - return; } @@ -1513,16 +1337,6 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul .unwrap_or_else(|| 0); let max_cost = max(0, max_cost); - if input_sexp.is_none() { - input_sexp = sexp_from_stream( - &mut allocator, - &mut Stream::new(input_serialized), - Box::new(SimpleCreateCLVMObject {}), - ) - .map(|x| Some(x.1)) - .unwrap(); - }; - // Part 2 of doing pre_eval: Have a thing that receives the messages and // performs some action. let log_entries_clone = log_entries.clone(); @@ -1653,7 +1467,7 @@ pub fn launch_tool(stdout: &mut Stream, args: &[String], tool_name: &str, defaul let compile_sym_out = dpr.get_compiles(); if !compile_sym_out.is_empty() { - write_sym_output(&compile_sym_out, &symbol_table_output).ok(); + write_sym_output(&compile_sym_out, &parsed.symbol_table_output).ok(); } stdout.write_str(&format!("{output}\n")); diff --git a/src/classic/clvm_tools/comp_input.rs b/src/classic/clvm_tools/comp_input.rs new file mode 100644 index 00000000..3216b253 --- /dev/null +++ b/src/classic/clvm_tools/comp_input.rs @@ -0,0 +1,226 @@ +use std::collections::HashMap; +use std::rc::Rc; + +use clvmr::{Allocator, NodePtr}; + +use crate::classic::clvm::__type_compatibility__::{Bytes, Stream, UnvalidatedBytesFromType}; +use crate::classic::clvm::serialize::{sexp_from_stream, SimpleCreateCLVMObject}; +use crate::classic::platform::argparse::ArgumentValue; + +use crate::classic::clvm_tools::binutils::assemble_from_ir; +use crate::classic::clvm_tools::ir::reader::read_ir; +use crate::classic::clvm_tools::stages::stage_0::DefaultProgramRunner; + +use crate::compiler::compiler::{compile_file, DefaultCompilerOpts}; +use crate::compiler::comptypes::{CompileErr, CompilerOpts}; +use crate::compiler::debug::build_symbol_table_mut; +use crate::compiler::dialect::{detect_modern, AcceptedDialect}; +use crate::compiler::optimize::maybe_finalize_program_via_classic_optimizer; +use crate::compiler::sexp; + +pub fn get_disassembly_ver(p: &HashMap) -> Option { + if let Some(ArgumentValue::ArgInt(x)) = p.get("operators_version") { + return Some(*x as usize); + } + + None +} + +fn get_string_and_filename_with_default( + parsed_args: &HashMap, + argument: &str, + default: Option<&str>, +) -> Option<(Option, String)> { + if let Some(ArgumentValue::ArgString(path, content)) = parsed_args.get(argument) { + Some((path.clone(), content.to_string())) + } else { + default.map(|p| (None, p.to_string())) + } +} + +pub struct ParsedInputPathOrCode { + pub path: Option, + pub content: String, + pub parsed: NodePtr, +} + +impl ParsedInputPathOrCode { + pub fn use_filename(&self) -> String { + self.path.clone().unwrap_or_else(|| "*command*".to_string()) + } +} + +pub fn parse_tool_input_sexp( + allocator: &mut Allocator, + argument: &str, + parsed_args: &HashMap, + default_hex: Option<&str>, + default_sexp: Option<&str>, +) -> Result { + match parsed_args.get("hex") { + Some(_) => { + let (path, sexp_text) = if let Some(r) = + get_string_and_filename_with_default(parsed_args, argument, default_hex) + { + r + } else { + return Err("missing argument {argument}".to_string()); + }; + + let use_sexp_text = if sexp_text.is_empty() { + default_hex.unwrap_or_default() + } else { + &sexp_text + } + .to_string(); + + let sexp_serialized = + Bytes::new_validated(Some(UnvalidatedBytesFromType::Hex(use_sexp_text.clone()))) + .map_err(|e| format!("{e:?}"))?; + + let mut prog_stream = Stream::new(Some(sexp_serialized)); + + sexp_from_stream( + allocator, + &mut prog_stream, + Box::new(SimpleCreateCLVMObject {}), + ) + .map(|x| ParsedInputPathOrCode { + path, + content: use_sexp_text, + parsed: x.1, + }) + .map_err(|e| format!("{e:?}")) + } + _ => { + let (path, use_sexp_text) = if let Some(r) = + get_string_and_filename_with_default(parsed_args, argument, default_sexp) + { + r + } else { + return Err(format!("missing argument {argument}")); + }; + + read_ir(&use_sexp_text) + .map_err(|e| format!("{e:?}")) + .and_then(|v| { + Ok(ParsedInputPathOrCode { + path, + content: use_sexp_text, + parsed: assemble_from_ir(allocator, Rc::new(v)) + .map_err(|e| format!("{e:?}"))?, + }) + }) + } + } +} + +pub struct RunAndCompileInputData { + pub program: ParsedInputPathOrCode, + pub args: ParsedInputPathOrCode, + pub dialect: AcceptedDialect, + pub opts: Rc, + pub do_optimize: bool, + pub search_paths: Vec, + pub symbol_table_output: String, +} + +impl RunAndCompileInputData { + pub fn new( + allocator: &mut Allocator, + parsed_args: &HashMap, + ) -> Result { + let program = parse_tool_input_sexp(allocator, "path_or_code", parsed_args, None, None)?; + let args = parse_tool_input_sexp(allocator, "env", parsed_args, Some("80"), Some("()"))?; + let dialect = detect_modern(allocator, program.parsed); + + let do_optimize = parsed_args + .get("optimize") + .map(|x| matches!(x, ArgumentValue::ArgBool(true))) + .unwrap_or_else(|| false); + + let search_paths = if let Some(ArgumentValue::ArgArray(v)) = parsed_args.get("include") { + v.iter() + .filter_map(|p| { + if let ArgumentValue::ArgString(_, s) = p { + Some(s.to_string()) + } else { + None + } + }) + .collect() + } else { + Vec::new() + }; + + let mut opts: Rc = + Rc::new(DefaultCompilerOpts::new(&program.use_filename())) + .set_dialect(dialect.clone()) + .set_search_paths(&search_paths) + .set_optimize(do_optimize) + .set_disassembly_ver(get_disassembly_ver(parsed_args)); + + if let Some(stepping) = dialect.stepping { + opts = opts + .set_optimize(do_optimize || stepping > 22) + .set_frontend_opt(stepping == 22); + } + + let symbol_table_output = parsed_args + .get("symbol_output_file") + .and_then(|s| { + if let ArgumentValue::ArgString(_, v) = s { + Some(v.clone()) + } else { + None + } + }) + .unwrap_or_else(|| "main.sym".to_string()); + + Ok(RunAndCompileInputData { + program, + args, + dialect, + do_optimize, + search_paths, + opts, + symbol_table_output, + }) + } + + pub fn use_filename(&self) -> String { + self.program + .path + .clone() + .unwrap_or_else(|| "*command*".to_string()) + } + + pub fn compile_modern( + &self, + allocator: &mut Allocator, + symbol_table: &mut HashMap, + ) -> Result, CompileErr> { + let runner = Rc::new(DefaultProgramRunner::new()); + + let unopt_res = compile_file( + allocator, + runner.clone(), + self.opts.clone(), + &self.program.content, + symbol_table, + ); + let res = unopt_res.and_then(|x| { + maybe_finalize_program_via_classic_optimizer( + allocator, + runner, + self.opts.clone(), + self.do_optimize, + &x, + ) + })?; + + build_symbol_table_mut(symbol_table, &res); + + Ok(res) + } +} diff --git a/src/classic/clvm_tools/mod.rs b/src/classic/clvm_tools/mod.rs index a5bd8846..9bbdfbe5 100644 --- a/src/classic/clvm_tools/mod.rs +++ b/src/classic/clvm_tools/mod.rs @@ -1,6 +1,7 @@ pub mod binutils; pub mod clvmc; pub mod cmds; +pub mod comp_input; pub mod curry; pub mod debug; pub mod ir; diff --git a/src/tests/compiler/cldb.rs b/src/tests/compiler/cldb.rs index c22074a2..0c6e7e2f 100644 --- a/src/tests/compiler/cldb.rs +++ b/src/tests/compiler/cldb.rs @@ -334,7 +334,6 @@ impl ExpectFailure { impl StepOfCldbViewer for ExpectFailure { fn show(&mut self, _step: &RunStep, output: Option>) -> bool { - eprintln!("{:?}", output); if let Some(o) = output { if let Some(_) = o.get("Failure") { let did_throw = o.get("Operator") == Some(&"8".to_string());