@@ -44,10 +44,6 @@ enum NockCommand {
44 #[arg(value_name = "FILE.nock")]
44 #[arg(value_name = "FILE.nock")]
45 gate: PathBuf,
45 gate: PathBuf,
48− #[arg(value_name = "FILE.nock")]
52 #[arg(value_name = "FILE.nock")]
48 #[arg(value_name = "FILE.nock")]
53 nock: PathBuf,
49 nock: PathBuf,
@@ -87,13 +83,6 @@ fn main() -> Result<(), std::io::Error> {
88 println!("{hash}");
84 println!("{hash}");
90− NockCommand::EvalGate { gate } => {
91− let gate = read_nock(&gate).unwrap();
93− let result = eval_pulled_gate(&mut generate_interpreter_context(), gate).unwrap();
95− println!("{result}");
97 NockCommand::Eval { nock } => {
86 NockCommand::Eval { nock } => {
98 let nock = read_nock(&nock).unwrap();
87 let nock = read_nock(&nock).unwrap();
@@ -155,40 +144,41 @@ fn new_spinner(txt: String) -> Spinner {
157fn compile(root: PathBuf, output: PathBuf) -> Result<(), std::io::Error> {
146fn compile(root: PathBuf, output: PathBuf) -> Result<(), std::io::Error> {
158− println!("reaming");
147+ let mut spinner = new_spinner(format!("Loading Hoon compiler"));
160− let ream_nock = include_bytes!("../res/ream.nock");
161− let ream_gate = cue_bytes(ream_nock);
163− let root_source = read_file(&root)?;
149+ let mut ctx = generate_interpreter_context();
151+ let hoon_nock = cue_bytes(include_bytes!("../res/hoon.nock"));
152+ let (hoon_type, hoon) = hoon_nock.as_cell().unwrap();
153+ let ride = cue_bytes(include_bytes!("../res/ride.nock"));
154+ let comb = cue_bytes(include_bytes!("../res/comb.nock"));
156+ spinner.update_text(format!("Compiling {root:#?}"));
158+ let root_source = read_file(&root)?;
165− slam_pulled_gate(
160+ let target = slam_pulled_gate(
166− &mut generate_interpreter_context(),
161+ &mut ctx,
167− &ream_gate,
162+ &ride,
168 &Rc::new(Noun::Atom(Atom::from_bytes_le(&root_source))),
165 &Rc::new(Noun::Atom(Atom::from_bytes_le(&root_source))),
170− .unwrap()
168+ .unwrap();
173− println!("Loading hoon/hoon");
170+ let (_target_type, target_nock) = target.as_cell().unwrap();
175− let ast = {
172+ spinner.update_text(format!("Combining Nock formulas"));
176− let hoon_hoon_ast_nock = include_bytes!("../res/hoon-hoon-ast.nock");
173+
177− let hoon_hoon_ast = cue_bytes(hoon_hoon_ast_nock);
174+ let nock = slam_pulled_gate(&mut ctx, &comb, &cell(hoon, target_nock)).unwrap();
179− &Rc::new(Noun::Atom(Atom::from_bytes_le(b"tsgl"))),
176+ spinner.update_text(format!("Writing output to {output:#?}"));
180− &cell(&hoon_hoon_ast, &root_ast),
184− println!("minting");
178+ let mut output_file = File::create(output.clone())?;
179+ File::write_all(&mut output_file, &jam_to_bytes(&nock)).unwrap();
186− let mint_gate = cue_bytes(include_bytes!("../res/mint.nock"));
181+ spinner.success(&*format!("Compiled {output:#?} successfully"));
188− slam_pulled_gate(&mut generate_interpreter_context(), &mint_gate, &ast).unwrap();
189− let (_type, nock) = minted_ast.as_cell().unwrap();
191− let mut output_file = File::create(output)?;
192− File::write_all(&mut output_file, &jam_to_bytes(nock)).unwrap();