| 2611 | } |
| 2612 | |
| 2613 | ErrorOr<void> Jakt::codegen::CodeGenerator::codegen_struct(Jakt::types::CheckedStruct const struct_,ByteStringBuilder& output) { |
| 2614 | { |
| 2615 | if (struct_.definition_linkage.__jakt_init_index() == 1 /* External */){ |
| 2616 | return {}; |
| 2617 | } |
| 2618 | bool struct_is_generic = false; |
| 2619 | JaktInternal::DynamicArray<ByteString> generic_parameter_names = DynamicArray<ByteString>::create_with({}); |
| 2620 | ByteStringBuilder template_parameters_builder = ByteStringBuilder::create(); |
| 2621 | ByteString template_parameters = ByteString::from_utf8_without_validation(""sv); |
| 2622 | if (!struct_.generic_parameters.is_empty()){ |
| 2623 | struct_is_generic = true; |
| 2624 | TRY((this->codegen_template_parameter_names(struct_.generic_parameters,generic_parameter_names,template_parameters_builder))); |
| 2625 | template_parameters = template_parameters_builder.to_string(); |
| 2626 | output.appendff(ByteString::from_utf8_without_validation("template <{}>"sv),template_parameters); |
| 2627 | } |
| 2628 | {auto&& __jakt_match_variant = struct_.record_type; |
| 2629 | switch(__jakt_match_variant.__jakt_init_index()) { |
| 2630 | case 1 /* Class */:{ |
| 2631 | ByteString class_name_with_generics = ByteString::from_utf8_without_validation(""sv); |
| 2632 | [](ByteString& self, ByteString rhs) -> void {{ |
| 2633 | self = (self + rhs); |
| 2634 | } |
| 2635 | } |
| 2636 | (class_name_with_generics,struct_.name_for_codegen().as_name_for_definition()); |
| 2637 | bool first = true; |
| 2638 | { |
| 2639 | JaktInternal::ArrayIterator<Jakt::types::CheckedGenericParameter> _magic = struct_.generic_parameters.iterator(); |
| 2640 | for (;;){ |
| 2641 | JaktInternal::Optional<Jakt::types::CheckedGenericParameter> const _magic_value = _magic.next(); |
| 2642 | if (!_magic_value.has_value()){ |
| 2643 | break; |
| 2644 | } |
| 2645 | Jakt::types::CheckedGenericParameter generic_parameter = _magic_value.value(); |
| 2646 | { |
| 2647 | if (!first){ |
| 2648 | [](ByteString& self, ByteString rhs) -> void {{ |
| 2649 | self = (self + rhs); |
| 2650 | } |
| 2651 | } |
| 2652 | (class_name_with_generics,ByteString::from_utf8_without_validation(", "sv)); |
| 2653 | } |
| 2654 | else { |
| 2655 | [](ByteString& self, ByteString rhs) -> void {{ |
| 2656 | self = (self + rhs); |
| 2657 | } |
| 2658 | } |
| 2659 | (class_name_with_generics,ByteString::from_utf8_without_validation("<"sv)); |
| 2660 | first = false; |
| 2661 | } |
| 2662 | |
| 2663 | [](ByteString& self, ByteString rhs) -> void {{ |
| 2664 | self = (self + rhs); |
| 2665 | } |
| 2666 | } |
| 2667 | (class_name_with_generics,TRY((this->codegen_type(generic_parameter.type_id)))); |
| 2668 | } |
| 2669 | |
| 2670 | } |
no test coverage detected