13af6ab5fSopenharmony_ci/* 23af6ab5fSopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 33af6ab5fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 43af6ab5fSopenharmony_ci * you may not use this file except in compliance with the License. 53af6ab5fSopenharmony_ci * You may obtain a copy of the License at 63af6ab5fSopenharmony_ci * 73af6ab5fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 83af6ab5fSopenharmony_ci * 93af6ab5fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 103af6ab5fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 113af6ab5fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 123af6ab5fSopenharmony_ci * See the License for the specific language governing permissions and 133af6ab5fSopenharmony_ci * limitations under the License. 143af6ab5fSopenharmony_ci */ 153af6ab5fSopenharmony_ci 163af6ab5fSopenharmony_ci#include "condition.h" 173af6ab5fSopenharmony_ci 183af6ab5fSopenharmony_ci#include "compiler/core/pandagen.h" 193af6ab5fSopenharmony_ci#include "compiler/core/ETSGen.h" 203af6ab5fSopenharmony_ci#include "ir/expressions/assignmentExpression.h" 213af6ab5fSopenharmony_ci#include "ir/expressions/binaryExpression.h" 223af6ab5fSopenharmony_ci#include "ir/expressions/callExpression.h" 233af6ab5fSopenharmony_ci#include "ir/expressions/unaryExpression.h" 243af6ab5fSopenharmony_ci 253af6ab5fSopenharmony_cinamespace ark::es2panda::compiler { 263af6ab5fSopenharmony_cibool Condition::CompileBinaryExpr(PandaGen *pg, const ir::BinaryExpression *binExpr, Label *falseLabel) 273af6ab5fSopenharmony_ci{ 283af6ab5fSopenharmony_ci switch (binExpr->OperatorType()) { 293af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_EQUAL: 303af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: 313af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_STRICT_EQUAL: 323af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_NOT_STRICT_EQUAL: 333af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_LESS_THAN: 343af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL: 353af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_GREATER_THAN: 363af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: { 373af6ab5fSopenharmony_ci // This is a special case 383af6ab5fSopenharmony_ci // These operators are expressed via cmp instructions and the following 393af6ab5fSopenharmony_ci // if-else branches. Condition also expressed via cmp instruction and 403af6ab5fSopenharmony_ci // the following if-else. 413af6ab5fSopenharmony_ci // the goal of this method is to merge these two sequences of instructions. 423af6ab5fSopenharmony_ci RegScope rs(pg); 433af6ab5fSopenharmony_ci VReg lhs = pg->AllocReg(); 443af6ab5fSopenharmony_ci 453af6ab5fSopenharmony_ci binExpr->Left()->Compile(pg); 463af6ab5fSopenharmony_ci pg->StoreAccumulator(binExpr, lhs); 473af6ab5fSopenharmony_ci binExpr->Right()->Compile(pg); 483af6ab5fSopenharmony_ci pg->Condition(binExpr, binExpr->OperatorType(), lhs, falseLabel); 493af6ab5fSopenharmony_ci return true; 503af6ab5fSopenharmony_ci } 513af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_LOGICAL_AND: { 523af6ab5fSopenharmony_ci binExpr->Left()->Compile(pg); 533af6ab5fSopenharmony_ci pg->ToBoolean(binExpr); 543af6ab5fSopenharmony_ci pg->BranchIfFalse(binExpr, falseLabel); 553af6ab5fSopenharmony_ci 563af6ab5fSopenharmony_ci binExpr->Right()->Compile(pg); 573af6ab5fSopenharmony_ci pg->ToBoolean(binExpr); 583af6ab5fSopenharmony_ci pg->BranchIfFalse(binExpr, falseLabel); 593af6ab5fSopenharmony_ci return true; 603af6ab5fSopenharmony_ci } 613af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_LOGICAL_OR: { 623af6ab5fSopenharmony_ci auto *endLabel = pg->AllocLabel(); 633af6ab5fSopenharmony_ci 643af6ab5fSopenharmony_ci binExpr->Left()->Compile(pg); 653af6ab5fSopenharmony_ci pg->ToBoolean(binExpr); 663af6ab5fSopenharmony_ci pg->BranchIfTrue(binExpr, endLabel); 673af6ab5fSopenharmony_ci 683af6ab5fSopenharmony_ci binExpr->Right()->Compile(pg); 693af6ab5fSopenharmony_ci pg->ToBoolean(binExpr); 703af6ab5fSopenharmony_ci pg->BranchIfFalse(binExpr, falseLabel); 713af6ab5fSopenharmony_ci pg->SetLabel(binExpr, endLabel); 723af6ab5fSopenharmony_ci return true; 733af6ab5fSopenharmony_ci } 743af6ab5fSopenharmony_ci default: { 753af6ab5fSopenharmony_ci break; 763af6ab5fSopenharmony_ci } 773af6ab5fSopenharmony_ci } 783af6ab5fSopenharmony_ci return false; 793af6ab5fSopenharmony_ci} 803af6ab5fSopenharmony_ci 813af6ab5fSopenharmony_civoid Condition::Compile(PandaGen *pg, const ir::Expression *expr, Label *falseLabel) 823af6ab5fSopenharmony_ci{ 833af6ab5fSopenharmony_ci if (expr->IsBinaryExpression()) { 843af6ab5fSopenharmony_ci if (CompileBinaryExpr(pg, expr->AsBinaryExpression(), falseLabel)) { 853af6ab5fSopenharmony_ci return; 863af6ab5fSopenharmony_ci } 873af6ab5fSopenharmony_ci } else if (expr->IsUnaryExpression() && 883af6ab5fSopenharmony_ci expr->AsUnaryExpression()->OperatorType() == lexer::TokenType::PUNCTUATOR_EXCLAMATION_MARK) { 893af6ab5fSopenharmony_ci expr->AsUnaryExpression()->Argument()->Compile(pg); 903af6ab5fSopenharmony_ci 913af6ab5fSopenharmony_ci pg->Negate(expr); 923af6ab5fSopenharmony_ci pg->BranchIfFalse(expr, falseLabel); 933af6ab5fSopenharmony_ci return; 943af6ab5fSopenharmony_ci } 953af6ab5fSopenharmony_ci 963af6ab5fSopenharmony_ci // General case including some binExpr i.E.(a+b) 973af6ab5fSopenharmony_ci expr->Compile(pg); 983af6ab5fSopenharmony_ci pg->ToBoolean(expr); 993af6ab5fSopenharmony_ci pg->BranchIfFalse(expr, falseLabel); 1003af6ab5fSopenharmony_ci} 1013af6ab5fSopenharmony_ci 1023af6ab5fSopenharmony_ciCondition::Result Condition::CheckConstantExpr(ETSGen *etsg, const ir::Expression *expr) 1033af6ab5fSopenharmony_ci{ 1043af6ab5fSopenharmony_ci const auto resultingExpression = [](const ir::Expression *e) { 1053af6ab5fSopenharmony_ci if (e->IsBinaryExpression() && e->AsBinaryExpression()->IsLogicalExtended()) { 1063af6ab5fSopenharmony_ci return e->AsBinaryExpression()->Result(); 1073af6ab5fSopenharmony_ci } 1083af6ab5fSopenharmony_ci if (e->IsAssignmentExpression() && e->AsAssignmentExpression()->IsLogicalExtended()) { 1093af6ab5fSopenharmony_ci return e->AsAssignmentExpression()->Result(); 1103af6ab5fSopenharmony_ci } 1113af6ab5fSopenharmony_ci return e; 1123af6ab5fSopenharmony_ci }(expr); 1133af6ab5fSopenharmony_ci if (resultingExpression == nullptr) { 1143af6ab5fSopenharmony_ci return Result::UNKNOWN; 1153af6ab5fSopenharmony_ci } 1163af6ab5fSopenharmony_ci 1173af6ab5fSopenharmony_ci if (etsg->Checker()->IsNullLikeOrVoidExpression(resultingExpression)) { 1183af6ab5fSopenharmony_ci return Result::CONST_FALSE; 1193af6ab5fSopenharmony_ci } 1203af6ab5fSopenharmony_ci 1213af6ab5fSopenharmony_ci auto exprRes = resultingExpression->TsType()->ResolveConditionExpr(); 1223af6ab5fSopenharmony_ci if (std::get<0>(exprRes)) { 1233af6ab5fSopenharmony_ci return std::get<1>(exprRes) ? Result::CONST_TRUE : Result::CONST_FALSE; 1243af6ab5fSopenharmony_ci } 1253af6ab5fSopenharmony_ci 1263af6ab5fSopenharmony_ci return Result::UNKNOWN; 1273af6ab5fSopenharmony_ci} 1283af6ab5fSopenharmony_ci 1293af6ab5fSopenharmony_civoid Condition::CompileLogicalOrExpr(ETSGen *etsg, const ir::BinaryExpression *binExpr, Label *falseLabel) 1303af6ab5fSopenharmony_ci{ 1313af6ab5fSopenharmony_ci auto ttctx = TargetTypeContext(etsg, binExpr->OperationType()); 1323af6ab5fSopenharmony_ci RegScope rs(etsg); 1333af6ab5fSopenharmony_ci VReg lhs = etsg->AllocReg(); 1343af6ab5fSopenharmony_ci VReg rhs = etsg->AllocReg(); 1353af6ab5fSopenharmony_ci auto *returnLeftLabel = etsg->AllocLabel(); 1363af6ab5fSopenharmony_ci auto *returnRightTrueLabel = etsg->AllocLabel(); 1373af6ab5fSopenharmony_ci auto *returnRightFalseLabel = etsg->AllocLabel(); 1383af6ab5fSopenharmony_ci 1393af6ab5fSopenharmony_ci binExpr->Left()->Compile(etsg); 1403af6ab5fSopenharmony_ci etsg->ApplyConversionAndStoreAccumulator(binExpr->Left(), lhs, binExpr->OperationType()); 1413af6ab5fSopenharmony_ci etsg->ResolveConditionalResultIfTrue(binExpr->Left(), returnLeftLabel); 1423af6ab5fSopenharmony_ci etsg->BranchIfTrue(binExpr, returnLeftLabel); 1433af6ab5fSopenharmony_ci 1443af6ab5fSopenharmony_ci binExpr->Right()->Compile(etsg); 1453af6ab5fSopenharmony_ci etsg->ApplyConversionAndStoreAccumulator(binExpr->Right(), rhs, binExpr->OperationType()); 1463af6ab5fSopenharmony_ci etsg->ResolveConditionalResultIfFalse(binExpr->Right(), returnRightFalseLabel); 1473af6ab5fSopenharmony_ci etsg->BranchIfFalse(binExpr, returnRightFalseLabel); 1483af6ab5fSopenharmony_ci etsg->LoadAccumulator(binExpr, rhs); 1493af6ab5fSopenharmony_ci etsg->Branch(binExpr, returnRightTrueLabel); 1503af6ab5fSopenharmony_ci 1513af6ab5fSopenharmony_ci etsg->SetLabel(binExpr, returnRightFalseLabel); 1523af6ab5fSopenharmony_ci etsg->LoadAccumulator(binExpr, rhs); 1533af6ab5fSopenharmony_ci etsg->Branch(binExpr, falseLabel); 1543af6ab5fSopenharmony_ci etsg->SetLabel(binExpr, returnLeftLabel); 1553af6ab5fSopenharmony_ci etsg->LoadAccumulator(binExpr, lhs); 1563af6ab5fSopenharmony_ci etsg->SetLabel(binExpr, returnRightTrueLabel); 1573af6ab5fSopenharmony_ci} 1583af6ab5fSopenharmony_ci 1593af6ab5fSopenharmony_civoid Condition::CompileLogicalAndExpr(ETSGen *etsg, const ir::BinaryExpression *binExpr, Label *falseLabel) 1603af6ab5fSopenharmony_ci{ 1613af6ab5fSopenharmony_ci auto ttctx = TargetTypeContext(etsg, binExpr->OperationType()); 1623af6ab5fSopenharmony_ci RegScope rs(etsg); 1633af6ab5fSopenharmony_ci VReg lhs = etsg->AllocReg(); 1643af6ab5fSopenharmony_ci VReg rhs = etsg->AllocReg(); 1653af6ab5fSopenharmony_ci auto *returnLeftLabel = etsg->AllocLabel(); 1663af6ab5fSopenharmony_ci auto *returnRightTrueLabel = etsg->AllocLabel(); 1673af6ab5fSopenharmony_ci auto *returnRightFalseLabel = etsg->AllocLabel(); 1683af6ab5fSopenharmony_ci 1693af6ab5fSopenharmony_ci binExpr->Left()->Compile(etsg); 1703af6ab5fSopenharmony_ci etsg->ApplyConversionAndStoreAccumulator(binExpr->Left(), lhs, binExpr->OperationType()); 1713af6ab5fSopenharmony_ci etsg->ResolveConditionalResultIfFalse(binExpr->Left(), returnLeftLabel); 1723af6ab5fSopenharmony_ci etsg->BranchIfFalse(binExpr, returnLeftLabel); 1733af6ab5fSopenharmony_ci 1743af6ab5fSopenharmony_ci binExpr->Right()->Compile(etsg); 1753af6ab5fSopenharmony_ci etsg->ApplyConversionAndStoreAccumulator(binExpr->Right(), rhs, binExpr->OperationType()); 1763af6ab5fSopenharmony_ci etsg->ResolveConditionalResultIfFalse(binExpr->Right(), returnRightFalseLabel); 1773af6ab5fSopenharmony_ci etsg->BranchIfFalse(binExpr, returnRightFalseLabel); 1783af6ab5fSopenharmony_ci etsg->LoadAccumulator(binExpr, rhs); 1793af6ab5fSopenharmony_ci etsg->Branch(binExpr, returnRightTrueLabel); 1803af6ab5fSopenharmony_ci 1813af6ab5fSopenharmony_ci etsg->SetLabel(binExpr, returnLeftLabel); 1823af6ab5fSopenharmony_ci etsg->LoadAccumulator(binExpr, lhs); 1833af6ab5fSopenharmony_ci etsg->Branch(binExpr, falseLabel); 1843af6ab5fSopenharmony_ci etsg->SetLabel(binExpr, returnRightFalseLabel); 1853af6ab5fSopenharmony_ci etsg->LoadAccumulator(binExpr, rhs); 1863af6ab5fSopenharmony_ci etsg->Branch(binExpr, falseLabel); 1873af6ab5fSopenharmony_ci etsg->SetLabel(binExpr, returnRightTrueLabel); 1883af6ab5fSopenharmony_ci} 1893af6ab5fSopenharmony_ci 1903af6ab5fSopenharmony_cibool Condition::CompileBinaryExprForBigInt(ETSGen *etsg, const ir::BinaryExpression *expr, Label *falseLabel) 1913af6ab5fSopenharmony_ci{ 1923af6ab5fSopenharmony_ci if ((expr->Left()->TsType() == nullptr) || (expr->Right()->TsType() == nullptr)) { 1933af6ab5fSopenharmony_ci return false; 1943af6ab5fSopenharmony_ci } 1953af6ab5fSopenharmony_ci 1963af6ab5fSopenharmony_ci if (!expr->Left()->TsType()->IsETSBigIntType()) { 1973af6ab5fSopenharmony_ci return false; 1983af6ab5fSopenharmony_ci } 1993af6ab5fSopenharmony_ci 2003af6ab5fSopenharmony_ci if (!expr->Right()->TsType()->IsETSBigIntType()) { 2013af6ab5fSopenharmony_ci return false; 2023af6ab5fSopenharmony_ci } 2033af6ab5fSopenharmony_ci 2043af6ab5fSopenharmony_ci std::string_view signature = compiler::Signatures::ANY; 2053af6ab5fSopenharmony_ci switch (expr->OperatorType()) { 2063af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_LESS_THAN: 2073af6ab5fSopenharmony_ci signature = compiler::Signatures::BUILTIN_BIGINT_OPERATOR_LESS_THAN; 2083af6ab5fSopenharmony_ci break; 2093af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL: 2103af6ab5fSopenharmony_ci signature = compiler::Signatures::BUILTIN_BIGINT_OPERATOR_LESS_THAN_EQUAL; 2113af6ab5fSopenharmony_ci break; 2123af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_GREATER_THAN: 2133af6ab5fSopenharmony_ci signature = compiler::Signatures::BUILTIN_BIGINT_OPERATOR_GREATER_THAN; 2143af6ab5fSopenharmony_ci break; 2153af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: 2163af6ab5fSopenharmony_ci signature = compiler::Signatures::BUILTIN_BIGINT_OPERATOR_GREATER_THAN_EQUAL; 2173af6ab5fSopenharmony_ci break; 2183af6ab5fSopenharmony_ci default: 2193af6ab5fSopenharmony_ci // Other operations are handled in the CompileBinaryExpr function 2203af6ab5fSopenharmony_ci return false; 2213af6ab5fSopenharmony_ci } 2223af6ab5fSopenharmony_ci 2233af6ab5fSopenharmony_ci auto ttctx = TargetTypeContext(etsg, expr->OperationType()); 2243af6ab5fSopenharmony_ci RegScope rs(etsg); 2253af6ab5fSopenharmony_ci VReg lhs = etsg->AllocReg(); 2263af6ab5fSopenharmony_ci expr->Left()->Compile(etsg); 2273af6ab5fSopenharmony_ci etsg->ApplyConversionAndStoreAccumulator(expr->Left(), lhs, expr->OperationType()); 2283af6ab5fSopenharmony_ci expr->Right()->Compile(etsg); 2293af6ab5fSopenharmony_ci etsg->ApplyConversion(expr->Right(), expr->OperationType()); 2303af6ab5fSopenharmony_ci compiler::VReg rhs = etsg->AllocReg(); 2313af6ab5fSopenharmony_ci etsg->StoreAccumulator(expr, rhs); 2323af6ab5fSopenharmony_ci etsg->CallBigIntBinaryComparison(expr, lhs, rhs, signature); 2333af6ab5fSopenharmony_ci etsg->BranchIfFalse(expr, falseLabel); 2343af6ab5fSopenharmony_ci 2353af6ab5fSopenharmony_ci return true; 2363af6ab5fSopenharmony_ci} 2373af6ab5fSopenharmony_ci 2383af6ab5fSopenharmony_civoid Condition::CompileInstanceofExpr(ETSGen *etsg, const ir::BinaryExpression *binExpr, Label *falseLabel) 2393af6ab5fSopenharmony_ci{ 2403af6ab5fSopenharmony_ci ASSERT(binExpr->OperatorType() == lexer::TokenType::KEYW_INSTANCEOF); 2413af6ab5fSopenharmony_ci binExpr->Compile(etsg); 2423af6ab5fSopenharmony_ci etsg->BranchIfFalse(binExpr, falseLabel); 2433af6ab5fSopenharmony_ci} 2443af6ab5fSopenharmony_ci 2453af6ab5fSopenharmony_cibool Condition::CompileBinaryExpr(ETSGen *etsg, const ir::BinaryExpression *binExpr, Label *falseLabel) 2463af6ab5fSopenharmony_ci{ 2473af6ab5fSopenharmony_ci if (CompileBinaryExprForBigInt(etsg, binExpr, falseLabel)) { 2483af6ab5fSopenharmony_ci return true; 2493af6ab5fSopenharmony_ci } 2503af6ab5fSopenharmony_ci 2513af6ab5fSopenharmony_ci switch (binExpr->OperatorType()) { 2523af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_EQUAL: 2533af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: 2543af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_LESS_THAN: 2553af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL: 2563af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_GREATER_THAN: 2573af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: { 2583af6ab5fSopenharmony_ci auto ttctx = TargetTypeContext(etsg, binExpr->OperationType()); 2593af6ab5fSopenharmony_ci 2603af6ab5fSopenharmony_ci RegScope rs(etsg); 2613af6ab5fSopenharmony_ci VReg lhs = etsg->AllocReg(); 2623af6ab5fSopenharmony_ci 2633af6ab5fSopenharmony_ci binExpr->CompileOperands(etsg, lhs); 2643af6ab5fSopenharmony_ci etsg->Condition(binExpr, binExpr->OperatorType(), lhs, falseLabel); 2653af6ab5fSopenharmony_ci return true; 2663af6ab5fSopenharmony_ci } 2673af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_LOGICAL_AND: { 2683af6ab5fSopenharmony_ci CompileLogicalAndExpr(etsg, binExpr, falseLabel); 2693af6ab5fSopenharmony_ci return true; 2703af6ab5fSopenharmony_ci } 2713af6ab5fSopenharmony_ci case lexer::TokenType::PUNCTUATOR_LOGICAL_OR: { 2723af6ab5fSopenharmony_ci CompileLogicalOrExpr(etsg, binExpr, falseLabel); 2733af6ab5fSopenharmony_ci return true; 2743af6ab5fSopenharmony_ci } 2753af6ab5fSopenharmony_ci case lexer::TokenType::KEYW_INSTANCEOF: { 2763af6ab5fSopenharmony_ci CompileInstanceofExpr(etsg, binExpr, falseLabel); 2773af6ab5fSopenharmony_ci return true; 2783af6ab5fSopenharmony_ci } 2793af6ab5fSopenharmony_ci default: { 2803af6ab5fSopenharmony_ci break; 2813af6ab5fSopenharmony_ci } 2823af6ab5fSopenharmony_ci } 2833af6ab5fSopenharmony_ci return false; 2843af6ab5fSopenharmony_ci} 2853af6ab5fSopenharmony_ci 2863af6ab5fSopenharmony_civoid Condition::Compile(ETSGen *etsg, const ir::Expression *expr, Label *falseLabel) 2873af6ab5fSopenharmony_ci{ 2883af6ab5fSopenharmony_ci if (expr->IsBinaryExpression()) { 2893af6ab5fSopenharmony_ci if (CompileBinaryExpr(etsg, expr->AsBinaryExpression(), falseLabel)) { 2903af6ab5fSopenharmony_ci return; 2913af6ab5fSopenharmony_ci } 2923af6ab5fSopenharmony_ci } else if (expr->IsUnaryExpression() && 2933af6ab5fSopenharmony_ci expr->AsUnaryExpression()->OperatorType() == lexer::TokenType::PUNCTUATOR_EXCLAMATION_MARK) { 2943af6ab5fSopenharmony_ci expr->AsUnaryExpression()->Argument()->Compile(etsg); 2953af6ab5fSopenharmony_ci etsg->ApplyConversion(expr->AsUnaryExpression()->Argument(), etsg->Checker()->GlobalETSBooleanType()); 2963af6ab5fSopenharmony_ci etsg->ResolveConditionalResultIfTrue(expr, falseLabel); 2973af6ab5fSopenharmony_ci etsg->BranchIfTrue(expr, falseLabel); 2983af6ab5fSopenharmony_ci return; 2993af6ab5fSopenharmony_ci } 3003af6ab5fSopenharmony_ci ASSERT(expr->TsType()->IsConditionalExprType()); 3013af6ab5fSopenharmony_ci expr->Compile(etsg); 3023af6ab5fSopenharmony_ci etsg->ApplyConversion(expr, etsg->Checker()->GlobalETSBooleanType()); 3033af6ab5fSopenharmony_ci etsg->ResolveConditionalResultIfFalse(expr, falseLabel); 3043af6ab5fSopenharmony_ci etsg->BranchIfFalse(expr, falseLabel); 3053af6ab5fSopenharmony_ci} 3063af6ab5fSopenharmony_ci} // namespace ark::es2panda::compiler 307