• 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 #include "src/ast/disable_validation_decoration.h"
16 #include "src/clone_context.h"
17 #include "src/program_builder.h"
18 
19 TINT_INSTANTIATE_TYPEINFO(tint::ast::DisableValidationDecoration);
20 
21 namespace tint {
22 namespace ast {
23 
DisableValidationDecoration(ProgramID pid,DisabledValidation val)24 DisableValidationDecoration::DisableValidationDecoration(ProgramID pid,
25                                                          DisabledValidation val)
26     : Base(pid), validation(val) {}
27 
28 DisableValidationDecoration::~DisableValidationDecoration() = default;
29 
InternalName() const30 std::string DisableValidationDecoration::InternalName() const {
31   switch (validation) {
32     case DisabledValidation::kFunctionHasNoBody:
33       return "disable_validation__function_has_no_body";
34     case DisabledValidation::kBindingPointCollision:
35       return "disable_validation__binding_point_collision";
36     case DisabledValidation::kIgnoreStorageClass:
37       return "disable_validation__ignore_storage_class";
38     case DisabledValidation::kEntryPointParameter:
39       return "disable_validation__entry_point_parameter";
40     case DisabledValidation::kIgnoreConstructibleFunctionParameter:
41       return "disable_validation__ignore_constructible_function_parameter";
42     case DisabledValidation::kIgnoreStrideDecoration:
43       return "disable_validation__ignore_stride";
44     case DisabledValidation::kIgnoreInvalidPointerArgument:
45       return "disable_validation__ignore_invalid_pointer_argument";
46   }
47   return "<invalid>";
48 }
49 
Clone(CloneContext * ctx) const50 const DisableValidationDecoration* DisableValidationDecoration::Clone(
51     CloneContext* ctx) const {
52   return ctx->dst->ASTNodes().Create<DisableValidationDecoration>(
53       ctx->dst->ID(), validation);
54 }
55 
56 }  // namespace ast
57 }  // namespace tint
58