From a072c6e81c1091b995ab0d7dda77e8cc5c7c5f5e Mon Sep 17 00:00:00 2001 From: Robert-M-Lucas <100799838+Robert-M-Lucas@users.noreply.github.com> Date: Sat, 3 Aug 2024 00:22:31 +0100 Subject: [PATCH] Refactoring --- .idea/workspace.xml | 133 ++++++------------ src/root.rs | 19 +-- src/root/name_resolver/resolve_names.rs | 4 +- .../parser/parse_function/parse_evaluable.rs | 2 +- 4 files changed, 49 insertions(+), 109 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a09d2e1..68af405 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,64 +7,11 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { + "keyToString": { + "Cargo.Build `Run whython-8`.executor": "Run", + "Cargo.Run whython-8.executor": "Run", + "Cargo.Test whython-8.executor": "Run", + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.rust.reset.selective.auto.import": "true", + "Shell Script.Test Asm.executor": "Run", + "git-widget-placeholder": "dev", + "ignore.virus.scanning.warn.message": "true", + "last_opened_file_path": "/home/robertlucas/RustroverProjects/whython-8", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "org.rust.cargo.project.model.PROJECT_DISCOVERY": "true", + "org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "", + "org.rust.first.attach.projects": "true", + "settings.editor.selected.configurable": "language.rust.cargo.check", + "vue.rearranger.settings.migration": "true" }, - "keyToStringList": { - "com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [ - "Rust" + "keyToStringList": { + "com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [ + "Rust" ] } -}]]> +} @@ -325,15 +272,9 @@ - - - - - @@ -795,13 +744,13 @@ - - diff --git a/src/root.rs b/src/root.rs index 58c1691..cef8d05 100644 --- a/src/root.rs +++ b/src/root.rs @@ -1,6 +1,4 @@ use crate::root::parser::parse::parse; -// use crate::root::assembler::assemble::generate_assembly; -// use crate::root::name_resolver::processor::process; use crate::root::compiler::compile::compile; use crate::root::errors::WErr; use crate::root::name_resolver::resolve::resolve; @@ -19,17 +17,6 @@ use std::time::Instant; #[cfg(debug_assertions)] pub const DEBUG_ON_ERROR: bool = false; -// #[cfg(target_os = "windows")] -// use crate::root::runner::run; -// #[cfg(target_os = "windows")] -// use runner::link; -// -// #[cfg(target_os = "linux")] -// use crate::root::runner::run_wine_experimental; -// #[cfg(target_os = "linux")] -// use runner::link_gcc_experimental; -// use crate::root::parser::parse::parse; - pub mod assembler; pub mod builtin; pub mod compiler; @@ -108,13 +95,13 @@ pub fn main_args(args: Args) -> Result<(), WErr> { let t = Instant::now(); link_gcc(&args.output).unwrap(); let end = t.elapsed(); - // TODO: Don't unwrap let size = File::open(format!("{}.out", args.output)) .unwrap() .metadata() .unwrap() .len() .to_formatted_string(&Locale::en); + cprintln!("Completed [{:?}] - {} bytes", end, size); if args.build { @@ -141,6 +128,10 @@ pub fn main_args(args: Args) -> Result<(), WErr> { run(&args.output); } } + #[cfg(not(target_os = "linux"))] + { + println!("Not linking / executing as OS is not Linux"); + } cprintln!("Done!"); Ok(()) diff --git a/src/root/name_resolver/resolve_names.rs b/src/root/name_resolver/resolve_names.rs index 8a3bb74..f3d7e92 100644 --- a/src/root/name_resolver/resolve_names.rs +++ b/src/root/name_resolver/resolve_names.rs @@ -1,5 +1,5 @@ use std::collections::HashMap; - +use b_box::b; use crate::root::errors::evaluable_errors::EvalErrs; use crate::root::errors::name_resolver_errors::NRErrs; use crate::root::errors::WErr; @@ -187,7 +187,7 @@ pub fn resolve_names( } for (id, user_type) in final_types { - global_table.add_user_type(id, Box::new(user_type)); + global_table.add_user_type(id, b!(user_type)); } // (final_types, type_names, unprocessed_functions) diff --git a/src/root/parser/parse_function/parse_evaluable.rs b/src/root/parser/parse_function/parse_evaluable.rs index d1f1e2e..77b80d0 100644 --- a/src/root/parser/parse_function/parse_evaluable.rs +++ b/src/root/parser/parse_function/parse_evaluable.rs @@ -517,7 +517,7 @@ pub fn parse_evaluable<'a, 'b>( Ok(( remaining, - TempOperation::Prefix(operator.clone(), Box::new(operand)), + TempOperation::Prefix(operator.clone(), b!(operand)), )) }