1 /** 2 * Copyright (c) 2021 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_IR_TS_NAMED_TUPLE_MEMBER_TYPE_H 17 #define ES2PANDA_IR_TS_NAMED_TUPLE_MEMBER_TYPE_H 18 19 #include "ir/typeNode.h" 20 21 namespace panda::es2panda::ir { 22 class TSNamedTupleMember : public TypeNode { 23 public: TSNamedTupleMember(Expression * label,TypeNode * elementType,bool optional)24 explicit TSNamedTupleMember(Expression *label, TypeNode *elementType, bool optional) 25 : TypeNode(AstNodeType::TS_NAMED_TUPLE_MEMBER), label_(label), elementType_(elementType), optional_(optional) 26 { 27 } 28 Label()29 const Expression *Label() const 30 { 31 return label_; 32 } 33 ElementType()34 TypeNode *ElementType() 35 { 36 return elementType_; 37 } 38 ElementType()39 const TypeNode *ElementType() const 40 { 41 return elementType_; 42 } 43 IsOptional()44 bool IsOptional() const 45 { 46 return optional_; 47 } 48 49 void TransformChildren(const NodeTransformer &cb) override; 50 void Iterate(const NodeTraverser &cb) const override; 51 void Dump(ir::AstDumper *dumper) const override; 52 void Dump(ir::SrcDumper *dumper) const override; 53 void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; 54 void Compile(compiler::ETSGen *etsg) const override; 55 checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; 56 checker::Type *Check([[maybe_unused]] checker::ETSChecker *checker) override; 57 Accept(ASTVisitorT * v)58 void Accept(ASTVisitorT *v) override 59 { 60 v->Accept(this); 61 } 62 63 private: 64 Expression *label_; 65 TypeNode *elementType_; 66 bool optional_; 67 }; 68 } // namespace panda::es2panda::ir 69 70 #endif 71