1 /* 2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ES2PANDA_COMPILER_CHECKER_TYPES_ETS_NULLISH_TYPE_H 17 #define ES2PANDA_COMPILER_CHECKER_TYPES_ETS_NULLISH_TYPE_H 18 19 #include "checker/types/type.h" 20 #include "ir/astNode.h" 21 22 namespace ark::es2panda::checker { 23 24 class ETSNullType : public Type { 25 public: ETSNullType()26 ETSNullType() : Type(TypeFlag::ETS_NULL) {} 27 28 void Identical(TypeRelation *relation, Type *other) override; 29 void AssignmentTarget(TypeRelation *relation, Type *source) override; 30 bool AssignmentSource(TypeRelation *relation, Type *target) override; 31 void Compare(TypeRelation *relation, Type *other) override; 32 void Cast(TypeRelation *relation, Type *target) override; 33 void CastTarget(TypeRelation *relation, Type *source) override; 34 35 void ToString(std::stringstream &ss, bool precise) const override; 36 void ToAssemblerType(std::stringstream &ss) const override; 37 void ToDebugInfoType([[maybe_unused]] std::stringstream &ss) const override; 38 39 Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; 40 ResolveConditionExpr()41 std::tuple<bool, bool> ResolveConditionExpr() const override 42 { 43 return {IsConstantType(), false}; 44 } 45 }; 46 47 class ETSUndefinedType : public Type { 48 public: ETSUndefinedType()49 ETSUndefinedType() : Type(TypeFlag::ETS_UNDEFINED) {} 50 51 void Identical(TypeRelation *relation, Type *other) override; 52 void AssignmentTarget(TypeRelation *relation, Type *source) override; 53 bool AssignmentSource(TypeRelation *relation, Type *target) override; 54 void Compare(TypeRelation *relation, Type *other) override; 55 void Cast(TypeRelation *relation, Type *target) override; 56 void CastTarget(TypeRelation *relation, Type *source) override; 57 58 void ToString(std::stringstream &ss, bool precise) const override; 59 void ToAssemblerType(std::stringstream &ss) const override; 60 void ToDebugInfoType([[maybe_unused]] std::stringstream &ss) const override; 61 62 Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; 63 ResolveConditionExpr()64 std::tuple<bool, bool> ResolveConditionExpr() const override 65 { 66 return {IsConstantType(), false}; 67 } 68 }; 69 70 } // namespace ark::es2panda::checker 71 72 #endif 73