| // Copyright 2020 The Dawn & Tint Authors |
| // |
| // Redistribution and use in source and binary forms, with or without |
| // modification, are permitted provided that the following conditions are met: |
| // |
| // 1. Redistributions of source code must retain the above copyright notice, this |
| // list of conditions and the following disclaimer. |
| // |
| // 2. Redistributions in binary form must reproduce the above copyright notice, |
| // this list of conditions and the following disclaimer in the documentation |
| // and/or other materials provided with the distribution. |
| // |
| // 3. Neither the name of the copyright holder nor the names of its |
| // contributors may be used to endorse or promote products derived from |
| // this software without specific prior written permission. |
| // |
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| |
| //////////////////////////////////////////////////////////////////////////////// |
| // File generated by 'tools/src/cmd/gen' using the template: |
| // src/tint/lang/core/address_space.cc.tmpl |
| // |
| // To regenerate run: './tools/run gen' |
| // |
| // Do not modify this file directly |
| //////////////////////////////////////////////////////////////////////////////// |
| |
| #include "src/tint/lang/core/address_space.h" |
| |
| namespace tint::core { |
| |
| /// ParseAddressSpace parses a AddressSpace from a string. |
| /// @param str the string to parse |
| /// @returns the parsed enum, or AddressSpace::kUndefined if the string could not be parsed. |
| AddressSpace ParseAddressSpace(std::string_view str) { |
| if (str == "__in") { |
| return AddressSpace::kIn; |
| } |
| if (str == "__out") { |
| return AddressSpace::kOut; |
| } |
| if (str == "function") { |
| return AddressSpace::kFunction; |
| } |
| if (str == "pixel_local") { |
| return AddressSpace::kPixelLocal; |
| } |
| if (str == "private") { |
| return AddressSpace::kPrivate; |
| } |
| if (str == "push_constant") { |
| return AddressSpace::kPushConstant; |
| } |
| if (str == "storage") { |
| return AddressSpace::kStorage; |
| } |
| if (str == "uniform") { |
| return AddressSpace::kUniform; |
| } |
| if (str == "workgroup") { |
| return AddressSpace::kWorkgroup; |
| } |
| return AddressSpace::kUndefined; |
| } |
| |
| std::string_view ToString(AddressSpace value) { |
| switch (value) { |
| case AddressSpace::kUndefined: |
| return "undefined"; |
| case AddressSpace::kIn: |
| return "__in"; |
| case AddressSpace::kOut: |
| return "__out"; |
| case AddressSpace::kFunction: |
| return "function"; |
| case AddressSpace::kHandle: |
| return "handle"; |
| case AddressSpace::kPixelLocal: |
| return "pixel_local"; |
| case AddressSpace::kPrivate: |
| return "private"; |
| case AddressSpace::kPushConstant: |
| return "push_constant"; |
| case AddressSpace::kStorage: |
| return "storage"; |
| case AddressSpace::kUniform: |
| return "uniform"; |
| case AddressSpace::kWorkgroup: |
| return "workgroup"; |
| } |
| return "<unknown>"; |
| } |
| |
| } // namespace tint::core |