Skip to content

Commit

Permalink
Added imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-M-Lucas committed Aug 6, 2024
1 parent 6f261bb commit dcb10f9
Show file tree
Hide file tree
Showing 10 changed files with 372 additions and 25 deletions.
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.
13 changes: 3 additions & 10 deletions main.why
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
use linked_list;

struct Test {
a: int
}

impl Test {
fn static() {

}
}

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

return 8;
}
2 changes: 2 additions & 0 deletions src/root/errors/parser_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub enum ParseError {
Expected(String),
#[error("Failed parsing {0}")]
NomErrorKind(String),
#[error("Failed to open file [{0}]")]
FailedToOpenFile(String)
}

pub fn create_custom_error(e: String, l: Span) -> nom::Err<ErrorTree> {
Expand Down
6 changes: 3 additions & 3 deletions src/root/parser/handle_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::root::parser::location::Location;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
use crate::root::parser::parse_toplevel::TopLevelTokens;

pub fn handle_error<'a>(
res: ParseResult<'a, Span<'a>, Vec<TopLevelTokens>>,
) -> Result<(Span<'a>, Vec<TopLevelTokens>), WErr> {
pub fn handle_error<A, B>(
res: ParseResult<A, B>,
) -> Result<(A, B), WErr> {
match res {
Ok(v) => Ok(v),
Err(e) => match &e {
Expand Down
22 changes: 22 additions & 0 deletions src/root/parser/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ use color_print::cformat;
use nom::InputTake;
use crate::root::parser::parse::Span;

pub enum ToLocation<'a> {
Location(Location),
Span(Span<'a>)
}

impl<'a> ToLocation<'a> {
pub fn from_location(location: Location) -> ToLocation<'a> {
ToLocation::Location(location)
}

pub fn from_span(span: Span<'a>) -> ToLocation<'a> {
ToLocation::Span(span)
}

pub fn to_location(self) -> Location {
match self {
ToLocation::Location(location) => location,
ToLocation::Span(s) => Location::from_span(&s)
}
}
}

#[derive(Debug, Clone, Hash)]
struct InnerLocation {
/// Path of file
Expand Down
Loading

0 comments on commit dcb10f9

Please sign in to comment.