Skip to content

Commit

Permalink
Merge pull request #2 from Robert-M-Lucas/dev
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
Robert-M-Lucas authored Aug 2, 2024
2 parents bf491fc + ec10c9f commit 964019b
Show file tree
Hide file tree
Showing 57 changed files with 367 additions and 337 deletions.
90 changes: 76 additions & 14 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions main.why
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ impl Test {
fn main() -> int {
let x: Test = Test { a: 3 };

::a;

return 8;
}
4 changes: 0 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
use crate::root::parser::parse::ErrorTree;
use nom::character::complete::anychar;
use nom::{AsBytes, IResult};

mod root;

fn main() {
Expand Down
17 changes: 7 additions & 10 deletions src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,18 @@ pub fn main_args(args: Args) -> Result<(), WErr> {
link_gcc(&args.output).unwrap();
let end = t.elapsed();
// TODO: Don't unwrap
let size = format!(
"{}",
File::open(format!("{}.out", args.output))
.unwrap()
.metadata()
.unwrap()
.len()
.to_formatted_string(&Locale::en)
);
let size = File::open(format!("{}.out", args.output))
.unwrap()
.metadata()
.unwrap()
.len()
.to_formatted_string(&Locale::en);
cprintln!("<g,bold>Completed [{:?}] - {} bytes</>", end, size);

if args.build {
println!("Skipping execution")
} else {
let termsize::Size { rows, cols } = termsize::get().unwrap();
let termsize::Size { rows: _, cols } = termsize::get().unwrap();
const EXECUTING: &str = "Executing";
if cols < EXECUTING.len() as u16 || cols > 300 {
cprintln!("<s><b>Executing...</>");
Expand Down
2 changes: 1 addition & 1 deletion src/root/builtin/core/referencing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::root::compiler::assembly::utils::{copy_from_indirect, copy_from_indirect_fixed_offset};
use crate::root::compiler::assembly::utils::copy_from_indirect;
use crate::root::errors::evaluable_errors::EvalErrs;
use crate::root::errors::WErr;
use crate::root::name_resolver::name_resolvers::GlobalDefinitionTable;
Expand Down
2 changes: 1 addition & 1 deletion src/root/builtin/functions/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl BuiltinInlineFunction for ExitFunction {
}

fn inline(&self) -> InlineFunctionGenerator {
|args: &[LocalAddress], _, gt, sz| -> String {
|args: &[LocalAddress], _, _, _| -> String {
let lhs = &args[0];

// 0 us exit syscall
Expand Down
8 changes: 4 additions & 4 deletions src/root/builtin/types/bool/and.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use unique_type_id::UniqueTypeId;

use crate::root::builtin::types::bool::printb::PrintB;
use crate::root::builtin::types::bool::{bool_op_sig, BoolType};
use crate::root::builtin::types::int::IntType;
use crate::root::builtin::{f_id, BuiltinInlineFunction, InlineFunctionGenerator};
use crate::root::name_resolver::resolve_function_signatures::FunctionSignature;
use crate::root::parser::parse_parameters::SelfType;
use crate::root::shared::common::{FunctionID, LocalAddress, TypeID};
use unique_type_id::UniqueTypeId;

#[derive(UniqueTypeId)]
#[UniqueTypeIdType = "u16"]
Expand All @@ -25,7 +25,7 @@ impl BuiltinInlineFunction for BoolAnd {
}

fn inline(&self) -> InlineFunctionGenerator {
|args: &[LocalAddress], return_into, gt, sz| -> String {
|args, return_into, gt, _| -> String {
let jmp_false = gt.get_unique_tag(PrintB::id());
let jmp_end = gt.get_unique_tag(PrintB::id());

Expand Down Expand Up @@ -77,7 +77,7 @@ impl BuiltinInlineFunction for BoolAsAnd {
}

fn inline(&self) -> InlineFunctionGenerator {
|args: &[LocalAddress], _, gt, sz| -> String {
|args: &[LocalAddress], _, gt, _| -> String {
let jmp_true = gt.get_unique_tag(PrintB::id());

let lhs = args[0];
Expand Down
20 changes: 10 additions & 10 deletions src/root/builtin/types/bool/mod.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
mod and;
mod comparators;
mod not;
mod or;
mod printb;
use b_box::b;
use unique_type_id::UniqueTypeId;

use crate::root::builtin::t_id;
use crate::root::builtin::types::bool::and::{BoolAnd, BoolAsAnd};
use crate::root::builtin::types::bool::comparators::{BoolEq, BoolNE};
use crate::root::builtin::types::bool::not::BoolNot;
use crate::root::builtin::types::bool::or::{BoolAsOr, BoolOr};
use crate::root::builtin::types::bool::printb::PrintB;
use crate::root::builtin::types::int::IntType;
use crate::root::builtin::{f_id, t_id, BuiltinInlineFunction, InlineFunctionGenerator};
use crate::root::errors::WErr;
use crate::root::name_resolver::name_resolvers::GlobalDefinitionTable;
use crate::root::name_resolver::resolve_function_signatures::FunctionSignature;
use crate::root::parser::parse_function::parse_literal::{LiteralToken, LiteralTokens};
use crate::root::parser::parse_parameters::SelfType;
use crate::root::shared::common::{ByteSize, FunctionID, LocalAddress, TypeID};
use crate::root::shared::common::{ByteSize, LocalAddress, TypeID};
use crate::root::shared::types::Type;
use b_box::b;
use unique_type_id::UniqueTypeId;

mod and;
mod comparators;
mod not;
mod or;
mod printb;

fn bool_op_sig() -> FunctionSignature {
FunctionSignature::new_inline_builtin(
Expand Down
6 changes: 3 additions & 3 deletions src/root/builtin/types/bool/not.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use unique_type_id::UniqueTypeId;

use crate::root::builtin::types::bool::printb::PrintB;
use crate::root::builtin::types::bool::BoolType;
use crate::root::builtin::types::int::IntType;
use crate::root::builtin::{f_id, BuiltinInlineFunction, InlineFunctionGenerator};
use crate::root::name_resolver::resolve_function_signatures::FunctionSignature;
use crate::root::parser::parse_parameters::SelfType;
use crate::root::shared::common::{FunctionID, LocalAddress, TypeID};
use unique_type_id::UniqueTypeId;

#[derive(UniqueTypeId)]
#[UniqueTypeIdType = "u16"]
Expand All @@ -29,7 +29,7 @@ impl BuiltinInlineFunction for BoolNot {
}

fn inline(&self) -> InlineFunctionGenerator {
|args: &[LocalAddress], return_into, gt, sz| -> String {
|args: &[LocalAddress], return_into, gt, _| -> String {
let jmp_false = gt.get_unique_tag(PrintB::id());
let jmp_end = gt.get_unique_tag(PrintB::id());

Expand Down
Loading

0 comments on commit 964019b

Please sign in to comment.