| 6768 | } |
| 6769 | |
| 6770 | Jakt::parser::ParsedFunction Jakt::parser::Parser::parse_function(Jakt::parser::FunctionLinkage const linkage,Jakt::parser::Visibility const visibility,bool const is_comptime,bool const is_destructor,bool const is_unsafe,bool const allow_missing_body) { |
| 6771 | { |
| 6772 | Jakt::parser::ParsedFunction parsed_function = Jakt::parser::ParsedFunction(this->next_function_id++,ByteString::from_utf8_without_validation(""sv),this->empty_span(),visibility,DynamicArray<Jakt::parser::ParsedParameter>::create_with({}),DynamicArray<Jakt::parser::ParsedGenericParameter>::create_with({}),Jakt::parser::ParsedBlock(DynamicArray<NonnullRefPtr<typename Jakt::parser::ParsedStatement>>::create_with({})),Jakt::parser::ParsedType::Empty(JaktInternal::OptionalNone()),this->span(static_cast<size_t>(0ULL),static_cast<size_t>(0ULL)),false,Jakt::parser::FunctionType::Normal(),linkage,false,is_comptime,false,is_unsafe,false,false,JaktInternal::OptionalNone(),JaktInternal::OptionalNone(),JaktInternal::OptionalNone(),Jakt::parser::InlineState::Default(),false); |
| 6773 | if (is_destructor){ |
| 6774 | parsed_function.type = Jakt::parser::FunctionType::Destructor(); |
| 6775 | parsed_function.params.push(Jakt::parser::ParsedParameter(false,Jakt::parser::ParsedVariable(ByteString::from_utf8_without_validation("this"sv),Jakt::parser::ParsedType::Empty(JaktInternal::OptionalNone()),true,this->current().span()),JaktInternal::OptionalNone(),this->current().span())); |
| 6776 | } |
| 6777 | if (!is_destructor){ |
| 6778 | this->index++; |
| 6779 | } |
| 6780 | if (this->eof()){ |
| 6781 | this->error(ByteString::from_utf8_without_validation("Incomplete function definition"sv),this->current().span()); |
| 6782 | return parsed_function; |
| 6783 | } |
| 6784 | if (is_destructor){ |
| 6785 | parsed_function.name = ByteString::from_utf8_without_validation("~"sv); |
| 6786 | parsed_function.name_span = this->previous().span(); |
| 6787 | } |
| 6788 | else { |
| 6789 | Jakt::lexer::Token __jakt_tmp26 = this->current(); |
| 6790 | if (__jakt_tmp26.__jakt_init_index() == 3 /* Identifier */){ |
| 6791 | ByteString const name = __jakt_tmp26.as.Identifier.name; |
| 6792 | parsed_function.name = name; |
| 6793 | parsed_function.name_span = this->current().span(); |
| 6794 | } |
| 6795 | else { |
| 6796 | this->error(ByteString::from_utf8_without_validation("Incomplete function definition"sv),this->current().span()); |
| 6797 | return parsed_function; |
| 6798 | } |
| 6799 | |
| 6800 | } |
| 6801 | |
| 6802 | this->index++; |
| 6803 | if (!is_destructor){ |
| 6804 | parsed_function.generic_parameters = this->parse_generic_parameters(); |
| 6805 | } |
| 6806 | if (this->eof()){ |
| 6807 | this->error(ByteString::from_utf8_without_validation("Incomplete function"sv),this->current().span()); |
| 6808 | } |
| 6809 | if (!is_destructor){ |
| 6810 | Jakt::parser::ParsedFunctionParameters const fn_parameters = this->parse_function_parameters(false); |
| 6811 | parsed_function.params = fn_parameters.parameters; |
| 6812 | parsed_function.has_varargs = fn_parameters.has_varargs; |
| 6813 | } |
| 6814 | parsed_function.is_jakt_main = (parsed_function.name == ByteString::from_utf8_without_validation("main"sv)); |
| 6815 | bool can_throw = parsed_function.is_jakt_main; |
| 6816 | if (this->current().__jakt_init_index() == 102 /* Throws */){ |
| 6817 | if (is_destructor){ |
| 6818 | this->error(ByteString::from_utf8_without_validation("Destructor cannot throw"sv),this->current().span()); |
| 6819 | } |
| 6820 | else { |
| 6821 | can_throw = true; |
| 6822 | } |
| 6823 | |
| 6824 | this->index++; |
| 6825 | } |
| 6826 | parsed_function.can_throw = can_throw; |
| 6827 | if (this->current().__jakt_init_index() == 58 /* Arrow */){ |
no test coverage detected