Skip to content

Commit

Permalink
Meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-M-Lucas committed Jul 27, 2024
1 parent 2fb1146 commit f39ebc3
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 80 deletions.
58 changes: 13 additions & 45 deletions .idea/workspace.xml

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

73 changes: 58 additions & 15 deletions build/out.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,45 @@ section .text
main:
push rbp
mov rbp, rsp
mov qword [rbp-8], 13
mov qword [rbp-32], 190
mov qword [rbp-24], 6
mov qword [rbp-16], 8
mov qword [rbp-16], 3
mov qword [rbp-8], 4
mov rax, rbp
add rax, -32
add rax, -16
mov qword [rbp-24], rax
mov rax, qword [rbp-24]
mov qword [rbp-32], rax
sub rsp, 32
call _3
add rsp, 32
mov rax, rbp
add rax, -16
mov qword [rbp-32], rax
mov rax, qword [rbp-32]
mov qword [rbp-40], rax
sub rsp, 40
call _4
add rsp, 40
mov rax, rbp
add rax, -16
mov qword [rbp-40], rax
mov rax, qword [rbp-40]
mov qword [rbp-48], rax
sub rsp, 48
call _4
call _3
add rsp, 48
mov rax, rbp
add rax, -8
mov qword [rbp-48], rax
mov rax, qword [rbp-24]
mov rax, qword [rbp-16]
mov qword [rbp-56], rax
mov rax, qword [rbp-48]
mov rdx, qword [rbp-56]
add qword [rax], rdx
mov rax, qword [rbp-8]
mov qword [rbp-64], rax
mov rax, qword [rbp-64]
mov rax, qword [rbp-56]
add rax, qword [rbp-64]
mov qword [rbp-48], rax
mov rax, qword [rbp-48]
leave
ret


_4:
_3:
push rbp
mov rbp, rsp
mov rdx, qword [rbp+16]
Expand All @@ -46,6 +57,38 @@ _4:
extern printf
call printf
add rsp, 8
mov rdx, qword [rbp+16]
add rdx, 8
mov rax, qword [rdx+0]
mov qword [rbp-16], rax
mov rdi, __8_fstr
mov rsi, [rbp-16]
mov al, 0
sub rsp, 16
extern printf
call printf
add rsp, 16

leave
ret

_4:
push rbp
mov rbp, rsp
mov rax, rbp
add rax, 16
mov qword [rbp-8], rax
mov qword [rbp-16], 1
mov rax, qword [rbp-8]
mov rdx, qword [rbp-16]
add qword [rax], rdx
mov rax, rbp
add rax, 24
mov qword [rbp-24], rax
mov qword [rbp-32], 1
mov rax, qword [rbp-24]
mov rdx, qword [rbp-32]
add qword [rax], rdx

leave
ret
Expand Down
Binary file modified build/out.o
Binary file not shown.
Binary file modified build/out.out
Binary file not shown.
37 changes: 17 additions & 20 deletions main.why
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
struct StructA {
a: int,
b: StructB
}

struct StructB {
struct MyStruct {
a: int,
b: int
}

impl StructA {
fn test(&self) {
impl MyStruct {
fn print(&self) {
printi(self.a);
printi(self.b);
}

fn increment(&self) {
self.a += 1;
self.b += 1;
}
}

fn main() -> int {
let y: int = 13;

let x: StructA = StructA {
a: 190,
b: StructB {
a: 6,
b: 8
}
let x: MyStruct = MyStruct {
a: 3,
b: 4
};

x.test();
x.print();
x.increment();
x.print();

y += x.b.a;
return y;
}
return x.a + x.b;
}

0 comments on commit f39ebc3

Please sign in to comment.