-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert-M-Lucas
committed
Jul 27, 2024
1 parent
a9a9030
commit d3a4bec
Showing
19 changed files
with
237 additions
and
131 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
.idea/shelf/Uncommitted_changes_before_Update_at_27_07_2024,_23_06_[Changes]/shelved.patch
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,15 @@ | ||
struct MyStruct { | ||
a: int, | ||
b: int | ||
struct LL { | ||
has_node: bool, | ||
first: &Node | ||
} | ||
|
||
impl MyStruct { | ||
fn print(&self) { | ||
printi(*self.a); | ||
printi(*self.b); | ||
} | ||
|
||
fn increment(&self) { | ||
self.a += 1; | ||
self.b += 1; | ||
} | ||
struct Node { | ||
val: int, | ||
has_next: bool, | ||
next: &Node | ||
} | ||
|
||
fn main() -> int { | ||
let x: MyStruct = MyStruct { | ||
a: 3, | ||
b: 4 | ||
}; | ||
let y: &int = x.a; | ||
|
||
x.print(); | ||
x.increment(); | ||
y += 2; | ||
x.print(); | ||
|
||
return 7; | ||
let r: LL = LL { has_node: false, first: Node::null() }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use crate::root::assembler::assembly_builder::AssemblyBuilder; | ||
use crate::root::compiler::local_variable_table::LocalVariableTable; | ||
use crate::root::name_resolver::name_resolvers::GlobalDefinitionTable; | ||
use crate::root::shared::common::{AddressedTypeRef, TypeRef}; | ||
|
||
pub fn heap_alloc(t: TypeRef, global_table: &mut GlobalDefinitionTable, local_variable_table: &mut LocalVariableTable) -> (String, AddressedTypeRef) { | ||
let size = global_table.get_size(&t).0; | ||
let sz = local_variable_table.stack_size().0; | ||
let output = global_table.add_local_variable_unnamed_base(t.plus_one_indirect(), local_variable_table); | ||
|
||
(format!(" mov rdi, {size} | ||
sub rsp, {sz} | ||
extern malloc | ||
call malloc | ||
sub rsp, {sz} | ||
mov qword {}, rax\n", output.local_address()), output) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod utils; | ||
pub mod heap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.