1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
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
16 #include "ecmascript/message_string.h"
17
18 #include <array>
19
20 #include "libpandabase/macros.h"
21
22 namespace panda::ecmascript {
23 // NOLINTNEXTLINE(fuchsia-statically-constructed-objects)
24 static std::array<std::string, MessageString::MAX_MESSAGE_COUNT> g_messageString = {
25 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
26 #define DEF_COMMON_MESSAGE(name, string) (string),
27 COMMON_MESSAGE_STRING_LIST(DEF_COMMON_MESSAGE)
28 #undef DEF_COMMON_MESSAGE
29 #define DEF_ASM_INTERPRETER_STUB_MESSAGE(name) #name,
30 ASM_INTERPRETER_BC_STUB_LIST(DEF_ASM_INTERPRETER_STUB_MESSAGE, DEF_ASM_INTERPRETER_STUB_MESSAGE,
31 DEF_ASM_INTERPRETER_STUB_MESSAGE)
32 ASM_INTERPRETER_SECOND_BC_STUB_ID_LIST(DEF_ASM_INTERPRETER_STUB_MESSAGE)
33 ASM_INTERPRETER_BC_HELPER_STUB_LIST(DEF_ASM_INTERPRETER_STUB_MESSAGE)
34 #define DEF_ASM_INTERPRETER_STUB_MESSAGE_DYN(name, ...) DEF_ASM_INTERPRETER_STUB_MESSAGE(name)
35 ASM_INTERPRETER_BC_PROFILER_STUB_LIST(DEF_ASM_INTERPRETER_STUB_MESSAGE_DYN)
36 #undef DEF_ASM_INTERPRETER_STUB_MESSAGE_DYN
37 #define DEF_BUILTINS_STUB_MESSAGE(name) "Builtins Stub "#name,
38 BUILTINS_STUB_LIST(DEF_BUILTINS_STUB_MESSAGE)
39 #undef DEF_BUILTINS_STUB_MESSAGE
40 RUNTIME_ASM_STUB_LIST(DEF_ASM_INTERPRETER_STUB_MESSAGE)
41 #undef DEF_ASM_INTERPRETER_STUB_MESSAGE
42 #define DEF_ISHEAPOBJECT_MESSAGE(name) #name"DebugCheck IR:line:%d",
43 DEBUG_CHECK_MESSAGE_STRING_LIST(DEF_ISHEAPOBJECT_MESSAGE)
44 #undef DEF_ISHEAPOBJECT_MESSAGE
45 };
46
GetMessageString(int id)47 const std::string& MessageString::GetMessageString(int id)
48 {
49 ASSERT(id < MessageString::MAX_MESSAGE_COUNT);
50 return g_messageString[id];
51 }
52 } // namespace panda::ecmascript
53