| 3997 | } |
| 3998 | |
| 3999 | ErrorOr<void> Jakt::codegen::CodeGenerator::codegen_expression(NonnullRefPtr<typename Jakt::types::CheckedExpression> const expression,ByteStringBuilder& output,bool const forward_error_with_try,bool const syntactically_self_contained) { |
| 4000 | { |
| 4001 | this->generic_inferences = expression->common.init_common.generic_inferences.value_or_lazy_evaluated_optional([&] { return this->generic_inferences; }); |
| 4002 | ScopeGuard __jakt_var_118([&] { |
| 4003 | this->generic_inferences = JaktInternal::OptionalNone(); |
| 4004 | }); |
| 4005 | {auto&& __jakt_match_variant = *expression; |
| 4006 | switch(__jakt_match_variant.__jakt_init_index()) { |
| 4007 | case 34 /* Reflect */: { |
| 4008 | auto&& __jakt_match_value = __jakt_match_variant.as.Reflect;Jakt::utility::Span const& span = __jakt_match_value.span; |
| 4009 | { |
| 4010 | Jakt::utility::panic(__jakt_format(StringView::from_string_literal("Unexpected reflect expression at {}"sv),span)); |
| 4011 | } |
| 4012 | goto __jakt_label_165;};/*case end*/ |
| 4013 | case 9 /* Range */: { |
| 4014 | auto&& __jakt_match_value = __jakt_match_variant.as.Range;JaktInternal::Optional<NonnullRefPtr<typename Jakt::types::CheckedExpression>> const& from = __jakt_match_value.from; |
| 4015 | JaktInternal::Optional<NonnullRefPtr<typename Jakt::types::CheckedExpression>> const& to = __jakt_match_value.to; |
| 4016 | Jakt::ids::TypeId const& type_id = __jakt_match_value.type_id; |
| 4017 | { |
| 4018 | NonnullRefPtr<typename Jakt::types::Type> const type = this->program->get_type(type_id); |
| 4019 | Jakt::ids::TypeId const index_type = [&]() -> Jakt::ids::TypeId { auto&& __jakt_match_variant = *type; |
| 4020 | switch(__jakt_match_variant.__jakt_init_index()) { |
| 4021 | case 20 /* GenericInstance */: { |
| 4022 | auto&& __jakt_match_value = __jakt_match_variant.as.GenericInstance;Jakt::ids::StructId const& id = __jakt_match_value.id; |
| 4023 | JaktInternal::DynamicArray<Jakt::ids::TypeId> const& args = __jakt_match_value.args; |
| 4024 | return args[static_cast<i64>(0LL)];};/*case end*/ |
| 4025 | default:{ |
| 4026 | Jakt::utility::panic(ByteString::from_utf8_without_validation("Internal error: range expression doesn't have Range type"sv)); |
| 4027 | } |
| 4028 | }/*switch end*/ |
| 4029 | |
| 4030 | }(); |
| 4031 | output.append(TRY((this->codegen_type(type_id)))); |
| 4032 | output.append(StringView::from_string_literal("{"sv)); |
| 4033 | output.append(StringView::from_string_literal("static_cast<"sv)); |
| 4034 | output.append(TRY((this->codegen_type(index_type)))); |
| 4035 | output.append(StringView::from_string_literal(">("sv)); |
| 4036 | if (from.has_value()){ |
| 4037 | TRY((this->codegen_expression(from.value(),output,true,false))); |
| 4038 | } |
| 4039 | else { |
| 4040 | output.append(StringView::from_string_literal("0LL"sv)); |
| 4041 | } |
| 4042 | |
| 4043 | output.append(StringView::from_string_literal("),static_cast<"sv)); |
| 4044 | output.append(TRY((this->codegen_type(index_type)))); |
| 4045 | output.append(StringView::from_string_literal(">("sv)); |
| 4046 | if (to.has_value()){ |
| 4047 | TRY((this->codegen_expression(to.value(),output,true,false))); |
| 4048 | } |
| 4049 | else { |
| 4050 | output.append(StringView::from_string_literal("9223372036854775807LL"sv)); |
| 4051 | } |
| 4052 | |
| 4053 | output.append(StringView::from_string_literal(")}"sv)); |
| 4054 | } |
| 4055 | goto __jakt_label_165;};/*case end*/ |
| 4056 | case 25 /* OptionalNone */:{ |
no test coverage detected