blob: c73eba918cbceddb57968de2610dec56b6780fc8 [file] [log] [blame]
Austin Engcc2516a2023-10-17 20:57:54 +00001// Copyright 2023 The Dawn & Tint Authors
Ben Claytonedc51ab2023-08-08 07:58:19 +00002//
Austin Engcc2516a2023-10-17 20:57:54 +00003// Redistribution and use in source and binary forms, with or without
4// modification, are permitted provided that the following conditions are met:
Ben Claytonedc51ab2023-08-08 07:58:19 +00005//
Austin Engcc2516a2023-10-17 20:57:54 +00006// 1. Redistributions of source code must retain the above copyright notice, this
7// list of conditions and the following disclaimer.
Ben Claytonedc51ab2023-08-08 07:58:19 +00008//
Austin Engcc2516a2023-10-17 20:57:54 +00009// 2. Redistributions in binary form must reproduce the above copyright notice,
10// this list of conditions and the following disclaimer in the documentation
11// and/or other materials provided with the distribution.
12//
13// 3. Neither the name of the copyright holder nor the names of its
14// contributors may be used to endorse or promote products derived from
15// this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Ben Claytonedc51ab2023-08-08 07:58:19 +000027
28#include "src/tint/lang/core/binary_op.h"
29
30namespace tint::core {
31
32std::string_view ToString(BinaryOp value) {
33 switch (value) {
34 case BinaryOp::kAnd:
35 return "&";
36 case BinaryOp::kOr:
37 return "|";
38 case BinaryOp::kXor:
39 return "^";
40 case BinaryOp::kLogicalAnd:
41 return "&&";
42 case BinaryOp::kLogicalOr:
43 return "||";
44 case BinaryOp::kEqual:
45 return "==";
46 case BinaryOp::kNotEqual:
47 return "!=";
48 case BinaryOp::kLessThan:
49 return "<";
50 case BinaryOp::kGreaterThan:
51 return ">";
52 case BinaryOp::kLessThanEqual:
53 return "<=";
54 case BinaryOp::kGreaterThanEqual:
55 return ">=";
56 case BinaryOp::kShiftLeft:
57 return "<<";
58 case BinaryOp::kShiftRight:
59 return ">>";
60 case BinaryOp::kAdd:
61 return "+";
62 case BinaryOp::kSubtract:
63 return "-";
64 case BinaryOp::kMultiply:
65 return "*";
66 case BinaryOp::kDivide:
67 return "/";
68 case BinaryOp::kModulo:
69 return "%";
70 }
71 return "<unknown>";
72}
73
74} // namespace tint::core