arkcompiler_ets_runtime/ecmascript/weak_vector-inl.h
wengchangcheng 839f39e500 modify ACCESSOR for EcmaString and TaggedArray
Signed-off-by: wengchangcheng <wengchangcheng@huawei.com>
Change-Id: I2995dc75ed34e8eb2bf249f2cced62ec9d91250e
2022-01-17 11:51:50 +08:00

61 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.
*/
#ifndef ECMASCRIPT_WEAK_VECTOR_INL_H
#define ECMASCRIPT_WEAK_VECTOR_INL_H
#include "weak_vector.h"
#include "tagged_array-inl.h"
namespace panda::ecmascript {
uint32_t WeakVector::GetEnd() const
{
return TaggedArray::Get(END_INDEX).GetArrayLength();
}
bool WeakVector::Full() const
{
return GetEnd() == GetCapacity();
}
bool WeakVector::Empty() const
{
return GetEnd() == 0;
}
uint32_t WeakVector::GetCapacity() const
{
return TaggedArray::GetLength() - ELEMENTS_START_INDEX;
}
JSTaggedValue WeakVector::Get(uint32_t index) const
{
ASSERT(index < GetCapacity());
return TaggedArray::Get(VectorToArrayIndex(index));
}
void WeakVector::Set(const JSThread *thread, uint32_t index, JSTaggedValue value)
{
ASSERT(index < GetCapacity());
TaggedArray::Set(thread, VectorToArrayIndex(index), value);
}
void WeakVector::SetEnd(const JSThread *thread, uint32_t end)
{
ASSERT(end <= GetCapacity());
TaggedArray::Set(thread, END_INDEX, JSTaggedValue(end));
}
} // namespace panda::ecmascript
#endif // ECMASCRIPT_WEAK_VECTOR_INL_H