• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
19 namespace panda::ecmascript {
20 // NOLINTNEXTLINE(fuchsia-statically-constructed-objects)
21 static std::array<std::string, MessageString::MAX_MESSAGE_COUNT> g_messageString = {
22 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
23 #define DEF_COMMON_MESSAGE(name, string) (string),
24     COMMON_MESSAGE_STRING_LIST(DEF_COMMON_MESSAGE)
25 #undef DEF_COMMON_MESSAGE
26 #define DEF_ASM_INTERPRETER_STUB_MESSAGE(name) #name,
27     ASM_INTERPRETER_BC_STUB_LIST(DEF_ASM_INTERPRETER_STUB_MESSAGE, DEF_ASM_INTERPRETER_STUB_MESSAGE,
28                                  DEF_ASM_INTERPRETER_STUB_MESSAGE)
29     ASM_INTERPRETER_SECOND_BC_STUB_ID_LIST(DEF_ASM_INTERPRETER_STUB_MESSAGE)
30     ASM_INTERPRETER_BC_HELPER_STUB_LIST(DEF_ASM_INTERPRETER_STUB_MESSAGE)
31 #define DEF_ASM_INTERPRETER_STUB_MESSAGE_DYN(name, ...) DEF_ASM_INTERPRETER_STUB_MESSAGE(name)
32     ASM_INTERPRETER_BC_PROFILER_STUB_LIST(DEF_ASM_INTERPRETER_STUB_MESSAGE_DYN)
33 #undef DEF_ASM_INTERPRETER_STUB_MESSAGE_DYN
34 #define DEF_BUILTINS_STUB_MESSAGE(name) "Builtins Stub "#name,
35 #define DEF_BUILTINS_STUB_MESSAGE_DYN(name, type, ...) "Builtins Stub "#type#name,
36     BUILTINS_STUB_LIST(DEF_BUILTINS_STUB_MESSAGE, DEF_BUILTINS_STUB_MESSAGE_DYN, DEF_BUILTINS_STUB_MESSAGE)
37 #undef DEF_BUILTINS_STUB_MESSAGE_DYN
38 #undef DEF_BUILTINS_STUB_MESSAGE
39     RUNTIME_ASM_STUB_LIST(DEF_ASM_INTERPRETER_STUB_MESSAGE)
40 #undef DEF_ASM_INTERPRETER_STUB_MESSAGE
41 #define DEF_ISHEAPOBJECT_MESSAGE(name) #name"DebugCheck IR:line:%d",
42     DEBUG_CHECK_MESSAGE_STRING_LIST(DEF_ISHEAPOBJECT_MESSAGE)
43 #undef DEF_ISHEAPOBJECT_MESSAGE
44 };
45 
GetMessageString(int id)46 const std::string& MessageString::GetMessageString(int id)
47 {
48     ASSERT(id < MessageString::MAX_MESSAGE_COUNT);
49     return g_messageString[id];
50 }
51 }  // namespace panda::ecmascript
52