1 /*
2 * Copyright 2016 WebAssembly Community Group participants
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 #include "src/binary.h"
18
19 namespace wabt {
20
GetSectionOrder(BinarySection sec)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;
30 }
31 }
32
GetSectionName(BinarySection sec)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;
42 }
43 }
44
45 const char* NameSubsectionName[] = {
46 "module",
47 "function",
48 "local",
49 "label",
50 "type",
51 "table",
52 "memory",
53 "global",
54 "elemseg",
55 "dataseg",
56 };
57
GetNameSectionSubsectionName(NameSectionSubsection subsec)58 const char* GetNameSectionSubsectionName(NameSectionSubsection subsec) {
59 return NameSubsectionName[size_t(subsec)];
60 }
61
62 } // namespace wabt
63