Skip to content

Commit

Permalink
Merge pull request #5 from Robert-M-Lucas/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Robert-M-Lucas authored Aug 17, 2024
2 parents 49f4fdb + 61cc3af commit 91ab77f
Show file tree
Hide file tree
Showing 30 changed files with 453 additions and 724 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

101 changes: 41 additions & 60 deletions .idea/workspace.xml

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

29 changes: 29 additions & 0 deletions build/out.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,32 @@

section .text

main:
push rbp
mov rbp, rsp
sub rsp, 0x0000000000000010
call _8
add rsp, 0x0000000000000010
mov qword [rbp-24], 0
mov rax, qword [rbp-24]
leave
ret


_8:
push rbp
mov rbp, rsp
mov qword [rbp-8], 7
mov rdi, __8_fstr
mov rsi, [rbp-8]
mov al, 0
sub rsp, 8
extern printf
call printf
add rsp, 8

leave
ret

section .data_readonly
__8_fstr db `Integer: %ld\n`,0
Binary file modified build/out.o
Binary file not shown.
Binary file added build/out.out
Binary file not shown.
20 changes: 3 additions & 17 deletions main.why
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
use std/;

import std/;

fn main() -> int {
let x: LL = LL::new();
x.push(12);
x.push(7);
x.push(8);
x.print();
printnl();

printi(x.get(1));
printnl();

printi(x.pop());
printnl();

x.print();
std::test::foo();

return 8;
return 0;
}

17 changes: 13 additions & 4 deletions src/root/compiler/compile.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#[cfg(debug_assertions)]
use itertools::Itertools;
use std::collections::HashMap;
use std::io::{stdout, Write};
use std::thread;
use std::time::{Duration, Instant};

#[cfg(debug_assertions)]
use itertools::Itertools;

use crate::root::compiler::compile_function::compile_function;
use crate::root::compiler::global_tracker::GlobalTracker;
use crate::root::errors::WErr;
Expand Down Expand Up @@ -44,6 +43,16 @@ pub fn compile(
continue; // Inline function
};

let file_id = current_function_token.location().file_id().unwrap();
global_table.scope_namespace(
file_id,
global_tracker
.path_storage()
.get_file(file_id)
.scope()
.clone(),
);

let compiled = compile_function(
current_function,
current_function_token,
Expand Down
5 changes: 3 additions & 2 deletions src/root/compiler/compile_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ pub fn compile_function(
let return_type = if fid.is_main() { None } else { return_type };

let return_type = if let Some(t) = return_type {
Some(global_table.resolve_to_type_ref(&t)?)
Some(global_table.resolve_to_type_ref(&t, None)?)
} else {
None
};

let mut param_address = LocalAddress(16);

for (param_name, param_type) in parameters {
let t = global_table.resolve_to_type_ref(&param_type)?;
let t = global_table.resolve_to_type_ref(&param_type, None)?;

local_variables.add_existing(
param_name.name().clone(),
Expand Down Expand Up @@ -121,6 +121,7 @@ fn recursively_compile_lines(
name.name().clone(),
type_name,
local_variables,
global_tracker,
)?;
contents.other(&compile_evaluable_into(
fid,
Expand Down
Loading

0 comments on commit 91ab77f

Please sign in to comment.