-
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
Jun 16, 2024
1 parent
6e668e4
commit 133922f
Showing
23 changed files
with
505 additions
and
141 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,146 @@ | ||
global main | ||
|
||
section .text | ||
section .text | ||
|
||
_1: | ||
main: | ||
push rbp | ||
mov rbp, rsp | ||
mov qword [rbp-8], 3 | ||
mov rax, qword [rbp-8] | ||
mov qword [rbp-16], rax | ||
push 0 | ||
mov rdi, __10_fstr | ||
mov rsi, [rbp-16] | ||
mov al, 0 | ||
sub rsp, 16 | ||
extern printf | ||
call printf | ||
add rsp, 16 | ||
mov rax, qword [rbp-8] | ||
mov qword [rbp-24], rax | ||
push 0 | ||
mov rdi, __10_fstr | ||
mov rsi, [rbp-24] | ||
mov al, 0 | ||
sub rsp, 24 | ||
extern printf | ||
call printf | ||
add rsp, 24 | ||
mov rax, qword [rbp-8] | ||
mov qword [rbp-32], rax | ||
push 0 | ||
mov rdi, __10_fstr | ||
mov rsi, [rbp-32] | ||
mov al, 0 | ||
sub rsp, 32 | ||
extern printf | ||
call printf | ||
add rsp, 32 | ||
mov rax, qword [rbp-8] | ||
mov qword [rbp-40], rax | ||
push 0 | ||
mov rdi, __10_fstr | ||
mov rsi, [rbp-40] | ||
mov al, 0 | ||
sub rsp, 40 | ||
extern printf | ||
call printf | ||
add rsp, 40 | ||
mov rax, qword [rbp-8] | ||
mov qword [rbp-48], rax | ||
push 0 | ||
mov rdi, __10_fstr | ||
mov rsi, [rbp-48] | ||
mov al, 0 | ||
sub rsp, 48 | ||
extern printf | ||
call printf | ||
add rsp, 48 | ||
mov rax, qword [rbp-8] | ||
mov qword [rbp-56], rax | ||
push 0 | ||
mov rdi, __10_fstr | ||
mov rsi, [rbp-56] | ||
mov al, 0 | ||
sub rsp, 56 | ||
extern printf | ||
call printf | ||
add rsp, 56 | ||
mov rax, qword [rbp-8] | ||
mov qword [rbp-64], rax | ||
push 0 | ||
mov rdi, __10_fstr | ||
mov rsi, [rbp-64] | ||
mov al, 0 | ||
sub rsp, 64 | ||
extern printf | ||
call printf | ||
add rsp, 64 | ||
mov rax, qword [rbp-8] | ||
mov qword [rbp-72], rax | ||
push 0 | ||
mov rdi, __10_fstr | ||
mov rsi, [rbp-72] | ||
mov al, 0 | ||
sub rsp, 72 | ||
extern printf | ||
call printf | ||
add rsp, 72 | ||
mov rax, qword [rbp-8] | ||
mov qword [rbp-88], rax | ||
mov rax, qword [rbp-88] | ||
mov qword [rbp-104], rax | ||
sub rsp, 104 | ||
call _2 | ||
add rsp, 104 | ||
mov rax, qword [rbp-96] | ||
mov qword [rbp-80], rax | ||
mov rax, qword [rbp-80] | ||
leave | ||
ret | ||
|
||
_2: | ||
push rbp | ||
mov rbp, rsp | ||
mov qword [rbp-8], 0 | ||
mov rax, qword [rbp+16] | ||
mov qword [rbp-16], rax | ||
mov rax, qword [rbp-16] | ||
mov qword [rbp-32], rax | ||
sub rsp, 32 | ||
call _1 | ||
add rsp, 32 | ||
mov rax, qword [rbp-24] | ||
mov qword [rbp-8], rax | ||
mov qword [rbp-32], 1 | ||
mov rax, qword [rbp-8] | ||
sub rax, qword [rbp-16] | ||
add rax, qword [rbp-32] | ||
mov qword [rbp+24], rax | ||
leave | ||
ret | ||
|
||
main: | ||
_1: | ||
push rbp | ||
mov rbp, rsp | ||
mov qword [rbp-8], -12 | ||
mov rax, qword [rbp-8] | ||
mov qword [rbp-24], rax | ||
mov rax, qword [rbp-24] | ||
mov qword [rbp-40], rax | ||
sub rsp, 40 | ||
call _1 | ||
add rsp, 40 | ||
mov rax, qword [rbp-32] | ||
mov rax, qword [rbp+16] | ||
mov qword [rbp-8], rax | ||
mov rax, qword [rbp+16] | ||
mov qword [rbp-16], rax | ||
mov rax, qword [rbp-16] | ||
leave | ||
ret | ||
mov rax, qword [rbp-8] | ||
add rax, qword [rbp-16] | ||
mov qword [rbp+24], rax | ||
leave | ||
ret | ||
|
||
section .data | ||
__10_fstr db `Integer: %d\n`,0 |
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,11 +1,21 @@ | ||
impl int { | ||
fn p_sub(self) -> Self { | ||
return 0 - self; | ||
} | ||
fn test_two(a: int) -> int { | ||
return a + a; | ||
} | ||
|
||
fn test(a: int) -> int { | ||
return test_two(a) + 1; | ||
} | ||
|
||
fn main() -> int { | ||
let x: int = -12; | ||
return -x; | ||
let x: int = 3; | ||
printi(x); | ||
printi(x); | ||
printi(x); | ||
printi(x); | ||
printi(x); | ||
printi(x); | ||
printi(x); | ||
printi(x); | ||
return test(x); | ||
} | ||
|
Empty file.
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,22 +1,35 @@ | ||
pub mod int; | ||
pub mod types; | ||
pub mod functions; | ||
|
||
use crate::root::builtin::int::{IntType, register_int}; | ||
use crate::root::builtin::types::int::register_int; | ||
use crate::root::compiler::global_tracker::GlobalTracker; | ||
use crate::root::errors::WErr; | ||
use crate::root::name_resolver::name_resolvers::{GlobalDefinitionTable}; | ||
use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; | ||
use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; | ||
use crate::root::shared::common::{ByteSize, FunctionID, LocalAddress, TypeID}; | ||
use crate::root::shared::types::Type; | ||
|
||
pub fn register_builtin(global_table: &mut GlobalDefinitionTable) { | ||
register_int(global_table); | ||
} | ||
|
||
pub type InlineFunctionGenerator = fn(&[LocalAddress], Option<LocalAddress>) -> String; | ||
pub type InlineFunctionGenerator = fn(&[LocalAddress], Option<LocalAddress>, &mut GlobalTracker, ByteSize) -> String; | ||
|
||
const fn f_id(id: u16) -> FunctionID { | ||
FunctionID(-(id as isize) - 1) | ||
} | ||
|
||
const fn t_id(id: u16) -> TypeID { | ||
TypeID(-(id as isize) - 1) | ||
} | ||
|
||
pub trait BuiltinInlineFunction { | ||
fn id(&self) -> FunctionID; | ||
fn name(&self) -> &'static str; | ||
fn signature(&self) -> FunctionSignature; | ||
fn inline(&self) -> InlineFunctionGenerator; | ||
fn requirements(&self) -> Option<Vec<String>> { | ||
None | ||
} | ||
fn parent_type(&self) -> Option<TypeID>; | ||
} |
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.