mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-12-03 16:31:12 +00:00
4a082f4f0b
Signed-off-by: linxiang <linxiang8@huawei.com> Change-Id: I20b5cf6245799839362b1999d3d9fb6955bf609a
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
#include "ecmascript/js_dataview.h"
|
|
|
|
#include "libpandabase/macros.h"
|
|
|
|
namespace panda::ecmascript {
|
|
uint32_t JSDataView::GetElementSize(DataViewType type)
|
|
{
|
|
uint32_t size;
|
|
switch (type) {
|
|
case DataViewType::INT8:
|
|
case DataViewType::UINT8:
|
|
case DataViewType::UINT8_CLAMPED:
|
|
size = 1;
|
|
break;
|
|
case DataViewType::INT16:
|
|
case DataViewType::UINT16:
|
|
size = 2; // 2 means the length
|
|
break;
|
|
case DataViewType::INT32:
|
|
case DataViewType::UINT32:
|
|
case DataViewType::FLOAT32:
|
|
size = 4; // 4 means the length
|
|
break;
|
|
case DataViewType::FLOAT64:
|
|
size = 8; // 8 means the length
|
|
break;
|
|
case DataViewType::BIGINT64:
|
|
case DataViewType::BIGUINT64:
|
|
size = 8; // 8 means the length
|
|
break;
|
|
default:
|
|
UNREACHABLE();
|
|
}
|
|
return size;
|
|
}
|
|
} // namespace panda::ecmascript
|