Bug 1882714 [wpt PR 44850] - Update wpt metadata, a=testonly
[gecko.git] / third_party / wasm2c / src / binary.cc
blobd4938a193929ad64b70ae9667f7b9922eb75811d
1 /*
2 * Copyright 2016 WebAssembly Community Group participants
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "wabt/binary.h"
19 namespace wabt {
21 BinarySectionOrder GetSectionOrder(BinarySection sec) {
22 switch (sec) {
23 #define V(Name, name, code) \
24 case BinarySection::Name: \
25 return BinarySectionOrder::Name;
26 WABT_FOREACH_BINARY_SECTION(V)
27 #undef V
28 default:
29 WABT_UNREACHABLE;
33 const char* GetSectionName(BinarySection sec) {
34 switch (sec) {
35 #define V(Name, name, code) \
36 case BinarySection::Name: \
37 return #Name;
38 WABT_FOREACH_BINARY_SECTION(V)
39 #undef V
40 default:
41 WABT_UNREACHABLE;
45 // clang-format off
46 const char* NameSubsectionName[] = {
47 "module",
48 "function",
49 "local",
50 "label",
51 "type",
52 "table",
53 "memory",
54 "global",
55 "elemseg",
56 "dataseg",
57 "tag",
59 // clang-format on
61 const char* GetNameSectionSubsectionName(NameSectionSubsection subsec) {
62 static_assert(WABT_ENUM_COUNT(NameSectionSubsection) ==
63 WABT_ARRAY_SIZE(NameSubsectionName),
64 "Malformed ExprTypeName array");
65 return NameSubsectionName[size_t(subsec)];
68 } // namespace wabt