• 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_TYPE_CONVERSION_H_
16 #define SRC_SEM_TYPE_CONVERSION_H_
17 
18 #include "src/sem/call_target.h"
19 
20 namespace tint {
21 namespace sem {
22 
23 /// TypeConversion is the CallTarget for a type conversion (cast).
24 class TypeConversion : public Castable<TypeConversion, CallTarget> {
25  public:
26   /// Constructor
27   /// @param type the target type of the cast
28   /// @param parameter the type cast parameter
29   TypeConversion(const sem::Type* type, const sem::Parameter* parameter);
30 
31   /// Destructor
32   ~TypeConversion() override;
33 
34   /// @returns the cast source type
Source()35   const sem::Type* Source() const { return Parameters()[0]->Type(); }
36 
37   /// @returns the cast target type
Target()38   const sem::Type* Target() const { return ReturnType(); }
39 };
40 
41 }  // namespace sem
42 }  // namespace tint
43 
44 #endif  // SRC_SEM_TYPE_CONVERSION_H_
45