• 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_EXPRESSION_CALL_EXPRESSION_H
17 #define ES2PANDA_IR_EXPRESSION_CALL_EXPRESSION_H
18 
19 #include <binder/variable.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 TSTypeParameterInstantiation;
34 
35 class CallExpression : public Expression {
36 public:
CallExpression(Expression * callee,ArenaVector<Expression * > && arguments,TSTypeParameterInstantiation * typeParams,bool optional)37     explicit CallExpression(Expression *callee, ArenaVector<Expression *> &&arguments,
38                             TSTypeParameterInstantiation *typeParams, bool optional)
39         : Expression(AstNodeType::CALL_EXPRESSION),
40           callee_(callee),
41           arguments_(std::move(arguments)),
42           typeParams_(typeParams),
43           optional_(optional)
44     {
45     }
46 
Callee()47     const Expression *Callee() const
48     {
49         return callee_;
50     }
51 
TypeParams()52     const TSTypeParameterInstantiation *TypeParams() const
53     {
54         return typeParams_;
55     }
56 
Arguments()57     const ArenaVector<Expression *> &Arguments() const
58     {
59         return arguments_;
60     }
61 
Arguments()62     ArenaVector<Expression *> &Arguments()
63     {
64         return arguments_;
65     }
66 
SetTypeParams(TSTypeParameterInstantiation * typeParams)67     void SetTypeParams(TSTypeParameterInstantiation *typeParams)
68     {
69         typeParams_ = typeParams;
70     }
71 
72     void Iterate(const NodeTraverser &cb) const override;
73     void Dump(ir::AstDumper *dumper) const override;
74     void Compile(compiler::PandaGen *pg) const override;
75     checker::Type *Check(checker::Checker *checker) const override;
76     void UpdateSelf(const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder) override;
77 
78 private:
79     compiler::VReg CreateSpreadArguments(compiler::PandaGen *pg) const;
80 
81     Expression *callee_;
82     ArenaVector<Expression *> arguments_;
83     TSTypeParameterInstantiation *typeParams_;
84     bool optional_;
85 };
86 
87 }  // namespace panda::es2panda::ir
88 
89 #endif
90