summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2025-10-14 20:40:39 +1300
committerBen Bridle <ben@derelict.engineering>2025-10-14 21:05:05 +1300
commit981bb70e5077bd30ef85a0092117a875dcc614fc (patch)
tree45e614de74d17071ca1e68098df4d32266df85a3 /src/bin
parentace5677f87c2bc042d8d5e807ccea9ddcd828c9e (diff)
downloadtorque-asm-981bb70e5077bd30ef85a0092117a875dcc614fc.zip
Implement new intermediate stage
Massive improvement. Label references can be used anywhere in the program, with the program being assembled repeatedly until all labels have stabilised. The bytecode stage will just be a tiny stage tacked onto the end, rather than the old bytecode stage that would resolve labels and expressions.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/tq.rs57
1 files changed, 32 insertions, 25 deletions
diff --git a/src/bin/tq.rs b/src/bin/tq.rs
index 9ac2587..2afe8ec 100644
--- a/src/bin/tq.rs
+++ b/src/bin/tq.rs
@@ -31,7 +31,7 @@ fn main() {
let no_libs = args.get("no-libs").as_bool();
let no_project_libs = args.get("no-project-libs").as_bool();
let no_env_libs = args.get("no-env-libs").as_bool();
- let format = Format::from_str(args.get("format").as_str());
+ // let format = Format::from_str(args.get("format").as_str());
let width = args.get("width").as_u32_opt();
let dry_run = args.get("dry-run").as_bool();
let print_tree = args.get("tree").as_bool();
@@ -138,9 +138,9 @@ Output formats:
std::process::exit(1);
});
- if !dry_run && format == Format::Source {
- write_bytes_and_exit(merged_source.as_bytes(), destination.as_ref());
- }
+ // if !dry_run && format == Format::Source {
+ // write_bytes_and_exit(merged_source.as_bytes(), destination.as_ref());
+ // }
// -----------------------------------------------------------------------
@@ -169,29 +169,36 @@ Output formats:
}
};
- let segments = match parse_bytecode(intermediate, width) {
- Ok(segments) => segments,
- Err(errors) => {
- report_bytecode_errors(&errors, &merged_source);
- std::process::exit(1);
- }
- };
+ // TODO
+ println!("INTERMEDIATE:");
+ for token in &intermediate {
+ print_intermediate_token(1, token);
+ }
+ println!();
+ // let segments = match parse_bytecode(intermediate, width) {
+ // Ok(segments) => segments,
+ // Err(errors) => {
+ // report_bytecode_errors(&errors, &merged_source);
+ // std::process::exit(1);
+ // }
+ // };
- if !dry_run {
- let result = match format {
- Format::Cmd => format_cmd(&segments),
- Format::Debug => format_debug(&segments),
- Format::Inhx => format_inhx(&segments),
- Format::Inhx32 => format_inhx32(&segments),
- Format::Raw => format_raw(&segments, width),
- Format::Source => unreachable!("Source output is handled before full assembly"),
- };
- match result {
- Ok(bytes) => write_bytes_and_exit(&bytes, destination.as_ref()),
- Err(error) => report_format_error(&error, format, &merged_source),
- }
- }
+
+ // if !dry_run {
+ // let result = match format {
+ // Format::Cmd => format_cmd(&segments),
+ // Format::Debug => format_debug(&segments),
+ // Format::Inhx => format_inhx(&segments),
+ // Format::Inhx32 => format_inhx32(&segments),
+ // Format::Raw => format_raw(&segments, width),
+ // Format::Source => unreachable!("Source output is handled before full assembly"),
+ // };
+ // match result {
+ // Ok(bytes) => write_bytes_and_exit(&bytes, destination.as_ref()),
+ // Err(error) => report_format_error(&error, format, &merged_source),
+ // }
+ // }
}