• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Tint Authors.
2 //
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 #ifndef SRC_SEM_CALL_H_
16 #define SRC_SEM_CALL_H_
17 
18 #include <vector>
19 
20 #include "src/sem/expression.h"
21 #include "src/sem/intrinsic.h"
22 
23 namespace tint {
24 namespace sem {
25 
26 /// Call is the base class for semantic nodes that hold semantic information for
27 /// ast::CallExpression nodes.
28 class Call : public Castable<Call, Expression> {
29  public:
30   /// Constructor
31   /// @param declaration the AST node
32   /// @param target the call target
33   /// @param arguments the call arguments
34   /// @param statement the statement that owns this expression
35   /// @param constant the constant value of this expression
36   Call(const ast::CallExpression* declaration,
37        const CallTarget* target,
38        std::vector<const sem::Expression*> arguments,
39        const Statement* statement,
40        Constant constant);
41 
42   /// Destructor
43   ~Call() override;
44 
45   /// @return the target of the call
Target()46   const CallTarget* Target() const { return target_; }
47 
48   /// @return the call arguments
Arguments()49   const std::vector<const sem::Expression*>& Arguments() const {
50     return arguments_;
51   }
52 
53   /// @returns the AST node
Declaration()54   const ast::CallExpression* Declaration() const {
55     return static_cast<const ast::CallExpression*>(declaration_);
56   }
57 
58  private:
59   CallTarget const* const target_;
60   std::vector<const sem::Expression*> arguments_;
61 };
62 
63 }  // namespace sem
64 }  // namespace tint
65 
66 #endif  // SRC_SEM_CALL_H_
67