Skip to content

Commit

Permalink
Merge pull request #3 from Robert-M-Lucas/dev
Browse files Browse the repository at this point in the history
Imports
  • Loading branch information
Robert-M-Lucas authored Aug 6, 2024
2 parents 964019b + 843edb1 commit 1ff5ac7
Show file tree
Hide file tree
Showing 42 changed files with 993 additions and 550 deletions.

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

133 changes: 41 additions & 92 deletions .idea/workspace.xml

Large diffs are not rendered by default.

275 changes: 273 additions & 2 deletions build/out.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,281 @@ section .text
main:
push rbp
mov rbp, rsp
mov qword [rbp-8], 3
mov qword [rbp-16], 8
sub rsp, 24
call _10
add rsp, 24
mov rax, qword [rbp-24]
mov qword [rbp-8], rax
mov rax, rbp
add rax, -8
mov qword [rbp-32], rax
mov qword [rbp-40], 12
mov rax, qword [rbp-40]
mov qword [rbp-64], rax
mov rax, qword [rbp-32]
mov qword [rbp-72], rax
sub rsp, 72
call _11
add rsp, 72
mov rax, rbp
add rax, -8
mov qword [rbp-64], rax
mov rax, qword [rbp-64]
mov qword [rbp-72], rax
sub rsp, 72
call _12
add rsp, 72
mov qword [rbp-72], 8
mov rax, qword [rbp-72]
leave
ret


_10:
push rbp
mov rbp, rsp
mov qword [rbp+16], 0
leave
ret


_11:
push rbp
mov rbp, rsp
mov rax, [rbp+16]
add rax, 0
mov qword [rbp-17], rax
mov rdx, qword [rbp-17]
mov rax, qword [rdx+0]
mov qword [rbp-9], rax
mov rax, qword [rbp-9]
cmp rax, 0
jz __36_12
mov byte [rbp-1], 0
jmp __36_13
__36_12:
mov byte [rbp-1], 1
__36_13:
cmp byte [rbp-1], 0
jz _11_15
mov rax, [rbp+16]
add rax, 0
mov qword [rbp-25], rax
mov rax, qword [rbp+24]
mov qword [rbp-41], rax
mov rax, qword [rbp-41]
mov qword [rbp-57], rax
sub rsp, 57
call _13
add rsp, 57
mov rax, qword [rbp-49]
mov qword [rbp-33], rax
mov rdx, qword [rbp-25]
mov rax, qword [rbp-33]
mov qword [rdx+0], rax
jmp _11_14
_11_15:
mov rax, [rbp+16]
add rax, 0
mov qword [rbp-25], rax
mov rdx, qword [rbp-25]
mov rax, qword [rdx+0]
mov qword [rbp-33], rax
mov rax, qword [rbp+24]
mov qword [rbp-41], rax
mov rax, qword [rbp-41]
mov qword [rbp-65], rax
mov rax, qword [rbp-33]
mov qword [rbp-73], rax
sub rsp, 73
call _14
add rsp, 73
_11_16:
_11_14:

leave
ret

_12:
push rbp
mov rbp, rsp
mov rax, [rbp+16]
add rax, 0
mov qword [rbp-18], rax
mov rdx, qword [rbp-18]
mov rax, qword [rdx+0]
mov qword [rbp-10], rax
mov rax, qword [rbp-10]
cmp rax, 0
jz __36_0
mov byte [rbp-2], 0
jmp __36_1
__36_0:
mov byte [rbp-2], 1
__36_1:
mov al, byte [rbp-2]
cmp al, 0
jz __23_2
mov byte [rbp-1], 0
jmp __23_3
__23_2:
mov byte [rbp-1], 1
__23_3:
cmp byte [rbp-1], 0
jz _12_4
mov rax, [rbp+16]
add rax, 0
mov qword [rbp-26], rax
mov rdx, qword [rbp-26]
mov rax, qword [rdx+0]
mov qword [rbp-34], rax
mov rax, qword [rbp-34]
mov qword [rbp-42], rax
sub rsp, 42
call _15
add rsp, 42
_12_5:
_12_4:

leave
ret

_13:
push rbp
mov rbp, rsp
mov rax, qword [rbp+16]
mov qword [rbp-16], rax
mov qword [rbp-8], 0
mov rdi, 16
sub rsp, 16
extern malloc
call malloc
add rsp, 16
mov qword [rbp-24], rax
mov rdx, qword [rbp-24]
mov rax, qword [rbp-16]
mov qword [rdx+0], rax
mov rax, qword [rbp-8]
mov qword [rdx+8], rax
mov rax, qword [rbp-24]
mov qword [rbp+24], rax
leave
ret


_14:
push rbp
mov rbp, rsp
mov rax, [rbp+16]
add rax, 8
mov qword [rbp-17], rax
mov rdx, qword [rbp-17]
mov rax, qword [rdx+0]
mov qword [rbp-9], rax
mov rax, qword [rbp-9]
cmp rax, 0
jz __36_17
mov byte [rbp-1], 0
jmp __36_18
__36_17:
mov byte [rbp-1], 1
__36_18:
cmp byte [rbp-1], 0
jz _14_20
mov rax, [rbp+16]
add rax, 8
mov qword [rbp-25], rax
mov rax, qword [rbp+24]
mov qword [rbp-41], rax
mov rax, qword [rbp-41]
mov qword [rbp-57], rax
sub rsp, 57
call _13
add rsp, 57
mov rax, qword [rbp-49]
mov qword [rbp-33], rax
mov rdx, qword [rbp-25]
mov rax, qword [rbp-33]
mov qword [rdx+0], rax
jmp _14_19
_14_20:
mov rax, [rbp+16]
add rax, 8
mov qword [rbp-25], rax
mov rdx, qword [rbp-25]
mov rax, qword [rdx+0]
mov qword [rbp-33], rax
mov rax, qword [rbp+24]
mov qword [rbp-41], rax
mov rax, qword [rbp-41]
mov qword [rbp-65], rax
mov rax, qword [rbp-33]
mov qword [rbp-73], rax
sub rsp, 73
call _14
add rsp, 73
_14_21:
_14_19:

leave
ret

_15:
push rbp
mov rbp, rsp
mov rax, [rbp+16]
add rax, 0
mov qword [rbp-16], rax
mov rdx, qword [rbp-16]
mov rax, qword [rdx+0]
mov qword [rbp-8], rax
mov rdi, __8_fstr
mov rsi, [rbp-8]
mov al, 0
sub rsp, 16
extern printf
call printf
add rsp, 16
mov rax, [rbp+16]
add rax, 8
mov qword [rbp-34], rax
mov rdx, qword [rbp-34]
mov rax, qword [rdx+0]
mov qword [rbp-26], rax
mov rax, qword [rbp-26]
cmp rax, 0
jz __36_6
mov byte [rbp-18], 0
jmp __36_7
__36_6:
mov byte [rbp-18], 1
__36_7:
mov al, byte [rbp-18]
cmp al, 0
jz __23_8
mov byte [rbp-17], 0
jmp __23_9
__23_8:
mov byte [rbp-17], 1
__23_9:
cmp byte [rbp-17], 0
jz _15_10
mov rax, [rbp+16]
add rax, 8
mov qword [rbp-42], rax
mov rdx, qword [rbp-42]
mov rax, qword [rdx+0]
mov qword [rbp-50], rax
mov rax, qword [rbp-50]
mov qword [rbp-58], rax
sub rsp, 58
call _15
add rsp, 58
_15_11:
_15_10:

leave
ret

section .data_readonly
__8_fstr db `Integer: %ld\n`,0
Binary file modified build/out.o
Binary file not shown.
Binary file modified build/out.out
Binary file not shown.
14 changes: 0 additions & 14 deletions linked_list.why
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,4 @@ impl Node {
self.next.print();
};
}
}

fn main() -> int {
let r: LL = LL::new();
r.add(2);
r.add(3);
r.add(2);
r.add(4);
r.add(7);
r.add(8);
r.add(4);
r.print();

return 0;
}
13 changes: 4 additions & 9 deletions main.why
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
struct Test {
a: int
}

impl Test {
fn static() {
use linked_list;

}
}

fn main() -> int {
let x: Test = Test { a: 3 };
let x: LL = LL::new();
x.add(12);
x.print();

return 8;
}
21 changes: 6 additions & 15 deletions src/root.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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;
use crate::root::parser::parse::parse;
use crate::root::runner::{assemble, link_gcc, run};
use crate::time;
use clap::Parser;
Expand All @@ -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;
Expand Down Expand Up @@ -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!("<g,bold>Completed [{:?}] - {} bytes</>", end, size);

if args.build {
Expand All @@ -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!("<g,bold>Done!</>");
Ok(())
Expand Down
Loading

0 comments on commit 1ff5ac7

Please sign in to comment.