on master help sign in
hello
0178c1aiko
nock/hello.hoonnew file+1
@@ -0,0 +1 @@
1+|=(x=@t (crip (weld "Hello, " (trip x))))
nock/hello.nocknew file

Binary file not shown.

nock/make.nockdeleted

No changes to the content.

nock/mint.nockdeleted

No changes to the content.

nock/one.hoondeleted−1
@@ -1 +0,0 @@
1−=> ~ ~+ |=(@ 'Hello')
nock/one.nockdeleted−1
@@ -1 +0,0 @@
1−�d �mem���pq x������
nock/res/hoon-hoon-ast.nockdeleted

Binary file not shown.

nock/res/hoon.nocknew file

Binary file not shown.

nock/res/make.nockdeleted

Binary file not shown.

nock/res/mint.nockdeleted

Binary file not shown.

nock/res/ream.nockdeleted

Binary file not shown.

nock/src/main.rs+28−38
@@ -44,10 +44,6 @@ enum NockCommand {
44 #[arg(value_name = "FILE.nock")]
44 #[arg(value_name = "FILE.nock")]
45 gate: PathBuf,
45 gate: PathBuf,
46 },
46 },
47− EvalGate {
48− #[arg(value_name = "FILE.nock")]
49− gate: PathBuf,
50− },
51 Eval {
47 Eval {
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> {
87
83
88 println!("{hash}");
84 println!("{hash}");
89 }
85 }
90− NockCommand::EvalGate { gate } => {
91− let gate = read_nock(&gate).unwrap();
92−
93− let result = eval_pulled_gate(&mut generate_interpreter_context(), gate).unwrap();
94−
95− println!("{result}");
96− }
97 NockCommand::Eval { nock } => {
86 NockCommand::Eval { nock } => {
98 let nock = read_nock(&nock).unwrap();
87 let nock = read_nock(&nock).unwrap();
99
88
@@ -155,40 +144,41 @@ fn new_spinner(txt: String) -> Spinner {
155}
144}
156
145
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"));
159− let root_ast = {
160− let ream_nock = include_bytes!("../res/ream.nock");
161− let ream_gate = cue_bytes(ream_nock);
162
148
163− let root_source = read_file(&root)?;
149+ let mut ctx = generate_interpreter_context();
164
150
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"));
155+
156+ spinner.update_text(format!("Compiling {root:#?}"));
157+
158+ let root_source = read_file(&root)?;
159+
165− slam_pulled_gate(
160+ let target = slam_pulled_gate(
166− &mut generate_interpreter_context(),
161+ &mut ctx,
167− &ream_gate,
162+ &ride,
163+ &cell(
164+ hoon_type,
168 &Rc::new(Noun::Atom(Atom::from_bytes_le(&root_source))),
165 &Rc::new(Noun::Atom(Atom::from_bytes_le(&root_source))),
169− )
166+ ),
167+ )
170− .unwrap()
168+ .unwrap();
171− };
172
169
173− println!("Loading hoon/hoon");
170+ let (_target_type, target_nock) = target.as_cell().unwrap();
174
171
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();
178− cell(
175+
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),
181− )
182− };
183
177
184− println!("minting");
178+ let mut output_file = File::create(output.clone())?;
179+ File::write_all(&mut output_file, &jam_to_bytes(&nock)).unwrap();
185
180
186− let mint_gate = cue_bytes(include_bytes!("../res/mint.nock"));
181+ spinner.success(&*format!("Compiled {output:#?} successfully"));
187− let minted_ast =
188− slam_pulled_gate(&mut generate_interpreter_context(), &mint_gate, &ast).unwrap();
189− let (_type, nock) = minted_ast.as_cell().unwrap();
190
182
191− let mut output_file = File::create(output)?;
192− File::write_all(&mut output_file, &jam_to_bytes(nock)).unwrap();
193 Ok(())
183 Ok(())
194}
184}