• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_AS_EXPRESSION_H
17 #define ES2PANDA_IR_TS_AS_EXPRESSION_H
18 
19 #include <ir/astDump.h>
20 #include <ir/expression.h>
21 
22 namespace panda::es2panda::compiler {
23 class PandaGen;
24 }  // namespace panda::es2panda::compiler
25 
26 namespace panda::es2panda::checker {
27 class Checker;
28 class Type;
29 }  // namespace panda::es2panda::checker
30 
31 namespace panda::es2panda::ir {
32 
33 class TSAsExpression : public Expression {
34 public:
TSAsExpression(Expression * expression,Expression * typeAnnotation,bool isConst)35     explicit TSAsExpression(Expression *expression, Expression *typeAnnotation, bool isConst)
36         : Expression(AstNodeType::TS_AS_EXPRESSION),
37           expression_(expression),
38           typeAnnotation_(typeAnnotation),
39           isConst_(isConst)
40     {
41     }
42 
Expr()43     const Expression *Expr() const
44     {
45         return expression_;
46     }
47 
Expr()48     Expression *Expr()
49     {
50         return expression_;
51     }
52 
TypeAnnotation()53     const Expression *TypeAnnotation() const
54     {
55         return typeAnnotation_;
56     }
57 
IsConst()58     bool IsConst() const
59     {
60         return isConst_;
61     }
62 
63     void Iterate(const NodeTraverser &cb) const override;
64     void Dump(ir::AstDumper *dumper) const override;
65     void Compile(compiler::PandaGen *pg) const override;
66     checker::Type *Check(checker::Checker *checker) const override;
67     void UpdateSelf(const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder) override;
68 
69 private:
70     Expression *expression_;
71     Expression *typeAnnotation_;
72     bool isConst_;
73 };
74 }  // namespace panda::es2panda::ir
75 
76 #endif
77