From 329d5b9f732e8b7ea3d4f15537f292e0e2b15d1c Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Fri, 13 Jun 2025 11:26:15 -0600 Subject: [PATCH] ReturnType builtin --- src/compiler.bbb | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/compiler.bbb b/src/compiler.bbb index 3d7a812..88034a0 100644 --- a/src/compiler.bbb +++ b/src/compiler.bbb @@ -3937,6 +3937,11 @@ parse_function_header = fn (module: &Module, scope: &Scope, mandate_argument_nam }; } +TypeIntrinsic = enum +{ + ReturnType, +} + parse_type = fn (module: &Module, scope: &Scope) &Type { >start_character = module.content[module.offset]; @@ -4112,13 +4117,28 @@ parse_type = fn (module: &Module, scope: &Scope) &Type #trap(); } - #trap(); } - #trap(); } else if (start_character == '#') { - #trap(); + module.offset += 1; + + >identifier = parse_identifier(module); + >intrinsic_s2e = #string_to_enum(TypeIntrinsic, identifier); + if (!intrinsic_s2e.is_valid) + { + report_error(); + } + + >intrinsic = intrinsic_s2e.enum_value; + switch (intrinsic) + { + .ReturnType => + { + >return_type = module.current_function.variable.type.content.function.base.semantic_return_type; + return return_type; + }, + } } else { @@ -12984,6 +13004,8 @@ names: [_][]u8 = "indirect", "indirect_struct", "indirect_varargs", + "ret_c_bool", + "return_type_builtin", ]; [export] main = fn [cc(c)] (argument_count: u32, argv: &&u8, envp: &&u8) s32