File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77//! A VM translator that parses Hack VM commands and generates Hack assembly.
88//! Based on the nand2tetris course.
99
10+ #![ expect(
11+ unused_crate_dependencies,
12+ clippy:: module_name_repetitions,
13+ clippy:: missing_errors_doc,
14+ reason = "error_set is not in use yet"
15+ ) ]
16+ #![ allow( clippy:: missing_docs_in_private_items, reason = "todo later" ) ]
17+
1018extern crate alloc;
1119
1220use alloc:: vec;
Original file line number Diff line number Diff line change @@ -385,21 +385,11 @@ impl Display for StackManipulation {
385385/// Branching instructions.
386386#[ derive( Debug , Clone , Hash ) ]
387387pub ( crate ) enum Branching {
388- /// TODO: DOC.
389- Label {
390- /// TODO: DOC.
391- symbol : Symbol ,
392- } ,
393- /// TODO: DOC.
394- GoTo {
395- /// TODO: DOC.
396- symbol : Symbol ,
397- } ,
398- /// TODO: DOC.
399- IfGoTo {
400- /// TODO: DOC.
401- symbol : Symbol ,
402- } ,
388+ Label { symbol : Symbol } ,
389+
390+ GoTo { symbol : Symbol } ,
391+
392+ IfGoTo { symbol : Symbol } ,
403393}
404394
405395impl Branching {
@@ -457,21 +447,10 @@ impl Display for Branching {
457447/// Functional instructions.
458448#[ derive( Debug , Clone , Hash ) ]
459449pub ( crate ) enum Functional {
460- /// TODO: DOC.
461- Function {
462- /// TODO: DOC.
463- symbol : Symbol ,
464- /// TODO: DOC.
465- value : Constant ,
466- } ,
467- /// TODO: DOC.
468- Call {
469- /// TODO: DOC.
470- symbol : Symbol ,
471- /// TODO: DOC.
472- value : Constant ,
473- } ,
474- /// TODO: DOC.
450+ Function { symbol : Symbol , value : Constant } ,
451+
452+ Call { symbol : Symbol , value : Constant } ,
453+
475454 Return ,
476455}
477456
Original file line number Diff line number Diff line change @@ -18,19 +18,19 @@ pub(crate) enum Segment {
1818 /// Constant is for constants. You can push a constant on to the stack, but
1919 /// you can't pop something off the stack into constant.
2020 Constant ,
21- /// TODO: DOC.
21+
2222 Local ,
23- /// TODO: DOC.
23+
2424 Argument ,
25- /// TODO: DOC.
25+
2626 This ,
27- /// TODO: DOC.
27+
2828 That ,
29- /// TODO: DOC.
29+
3030 Static ,
31- /// TODO: DOC.
31+
3232 Temp ,
33- /// TODO: DOC.
33+
3434 Pointer ,
3535}
3636
@@ -265,6 +265,10 @@ impl Translator {
265265 . to_vec ( )
266266 }
267267 Segment :: Temp => {
268+ #[ expect(
269+ clippy:: arithmetic_side_effects,
270+ reason = "todo: revisit"
271+ ) ]
268272 let address: u16 = i. literal_representation ( ) + Self :: TEMP_BASE ;
269273 if ( Self :: TEMP_BASE ..=Self :: TEMP_MAX ) . contains ( & address) {
270274 [
@@ -386,6 +390,10 @@ impl Translator {
386390 . to_vec ( )
387391 }
388392 Segment :: Temp => {
393+ #[ expect(
394+ clippy:: arithmetic_side_effects,
395+ reason = "todo: revisit"
396+ ) ]
389397 let address = i. literal_representation ( ) + Self :: TEMP_BASE ;
390398 if ( Self :: TEMP_BASE ..=Self :: TEMP_MAX ) . contains ( & address) {
391399 [
Original file line number Diff line number Diff line change 77//! A VM translator that parses Hack VM commands and generates Hack assembly.
88//! Based on the nand2tetris course.
99
10+ #![ expect( unused_crate_dependencies, reason = "error_set is not in use yet" ) ]
11+
1012use std:: { env, process} ;
1113
1214use hack_vm_translator:: { Config , run} ;
You can’t perform that action at this time.
0 commit comments