escargot/src/runtime/SymbolObject.cpp
HyukWoo Park 8fa6031fec Add DerivedObject for sub classes of Object
* check index property set in DerivedObject::defineOwnProperty method only
* index property check is removed for normal Object because PrototypeObject would check it instead

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
2022-05-11 15:59:43 +09:00

50 lines
1.8 KiB
C++

/*
* Copyright (c) 2018-present Samsung Electronics Co., Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#include "Escargot.h"
#include "SymbolObject.h"
#include "Context.h"
namespace Escargot {
SymbolObject::SymbolObject(ExecutionState& state, Symbol* value)
: SymbolObject(state, state.context()->globalObject()->symbolPrototype(), value)
{
}
SymbolObject::SymbolObject(ExecutionState& state, Object* proto, Symbol* value)
: DerivedObject(state, proto, ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER)
, m_primitiveValue(value)
{
}
void* SymbolObject::operator new(size_t size)
{
static MAY_THREAD_LOCAL bool typeInited = false;
static MAY_THREAD_LOCAL GC_descr descr;
if (!typeInited) {
GC_word obj_bitmap[GC_BITMAP_SIZE(SymbolObject)] = { 0 };
Object::fillGCDescriptor(obj_bitmap);
GC_set_bit(obj_bitmap, GC_WORD_OFFSET(SymbolObject, m_primitiveValue));
descr = GC_make_descriptor(obj_bitmap, GC_WORD_LEN(SymbolObject));
typeInited = true;
}
return GC_MALLOC_EXPLICITLY_TYPED(size, descr);
}
} // namespace Escargot