/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ enum class EntrypointId : uint8_t { % Compiler::entrypoints.each_with_index do |entrypoint, index| <%= entrypoint.enum_name %> = <%= index %>, % end COUNT }; constexpr const char* GetEntrypointName(EntrypointId id) { ASSERT(id < EntrypointId::COUNT); // NOLINTNEXTLINE(modernize-avoid-c-arrays) constexpr const char* NAMES[static_cast(EntrypointId::COUNT)] = { % Compiler::entrypoints.each do |entrypoint| "<%= entrypoint.name %>", % end }; return NAMES[static_cast(id)]; } bool IsEntrypointNoreturn(EntrypointId id) { ASSERT(id < EntrypointId::COUNT); switch(id) { % Compiler::entrypoints.each do |entrypoint| case EntrypointId::<%= entrypoint.enum_name %>: return <%= entrypoint.has_property? 'no_return' %>; % end case EntrypointId::COUNT: UNREACHABLE(); } UNREACHABLE(); } size_t GetEntrypointArgsNum(EntrypointId id) { ASSERT(id < EntrypointId::COUNT); switch(id) { % Compiler::entrypoints.each do |entrypoint| case EntrypointId::<%= entrypoint.enum_name %>: return <%= entrypoint.signature.length - 1 %>; % end case EntrypointId::COUNT: UNREACHABLE(); } UNREACHABLE(); } uint32_t GetEntrypointsCrc32() { static constexpr uint32_t ENTRYPOINTS_CRC32 = <%= Compiler::entrypoints_crc32 %>; return ENTRYPOINTS_CRC32; }