-
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 19, 2024
1 parent
add622f
commit fb9bb67
Showing
16 changed files
with
332 additions
and
85 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
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,5 +1,8 @@ | ||
fn main() -> int { | ||
printb(true); | ||
let a: bool = true; | ||
&a = !a; | ||
|
||
printb(a); | ||
|
||
return 2; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use unique_type_id::UniqueTypeId; | ||
use crate::root::builtin::{BuiltinInlineFunction, InlineFunctionGenerator, f_id}; | ||
use crate::root::builtin::types::bool::BoolType; | ||
use crate::root::builtin::types::bool::printb::PrintB; | ||
use crate::root::builtin::types::int::IntType; | ||
use crate::root::name_resolver::resolve_function_signatures::FunctionSignature; | ||
|
||
use crate::root::shared::common::{FunctionID, LocalAddress, TypeID}; | ||
|
||
#[derive(UniqueTypeId)] | ||
#[UniqueTypeIdType = "u16"] | ||
pub struct BoolNot; | ||
|
||
impl BuiltinInlineFunction for BoolNot { | ||
fn id(&self) -> FunctionID { | ||
f_id(BoolNot::unique_type_id().0) | ||
} | ||
|
||
fn name(&self) -> &'static str { | ||
"p_not" | ||
} | ||
|
||
fn signature(&self) -> FunctionSignature { | ||
FunctionSignature::new_inline_builtin( | ||
true, | ||
&[("lhs", BoolType::id().immediate())], | ||
Some(BoolType::id().immediate()) | ||
) | ||
} | ||
|
||
fn inline(&self) -> InlineFunctionGenerator { | ||
|args: &[LocalAddress], return_into, gt, sz| -> String { | ||
|
||
let jmp_false = gt.get_unique_tag(PrintB::id()); | ||
let jmp_end = gt.get_unique_tag(PrintB::id()); | ||
|
||
let lhs = args[0]; | ||
let return_into = return_into.unwrap(); | ||
format!( | ||
" mov al, byte {lhs} | ||
cmp al, 0 | ||
jz {jmp_false} | ||
mov byte {return_into}, 0 | ||
jmp {jmp_end} | ||
{jmp_false}: | ||
mov byte {return_into}, 1 | ||
{jmp_end}: | ||
") | ||
} | ||
} | ||
|
||
fn parent_type(&self) -> Option<TypeID> { | ||
Some(BoolType::id()) | ||
} | ||
} |
Oops, something went wrong.