arkcompiler_ets_runtime/ecmascript/js_dataview.cpp
linxiang 4a082f4f0b use full-path for all headers.
Signed-off-by: linxiang <linxiang8@huawei.com>
Change-Id: I20b5cf6245799839362b1999d3d9fb6955bf609a
2022-07-25 20:32:55 +08:00

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