1. re-implement Object::defineOwnProperty

2. implement String.prototype.match, replace

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
seonghyun kim 2016-12-14 16:08:50 +09:00
commit 64a56ae946
22 changed files with 677 additions and 256 deletions

View file

@ -16,10 +16,10 @@ StringObject::StringObject(ExecutionState& state, String* value)
void StringObject::setStringData(ExecutionState& state, String* data)
{
m_primitiveValue = data;
defineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().length), ObjectPropertyDescriptorForDefineOwnProperty(Value(data->length()), ObjectPropertyDescriptor::NotPresent));
defineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().length), ObjectPropertyDescriptorForDefineOwnProperty(Value(data->length()), ObjectPropertyDescriptorForDefineOwnProperty::NotPresent));
}
Object::ObjectGetResult StringObject::getOwnProperty(ExecutionState& state, const ObjectPropertyName& P) ESCARGOT_OBJECT_SUBCLASS_MUST_REDEFINE
ObjectGetResult StringObject::getOwnProperty(ExecutionState& state, const ObjectPropertyName& P) ESCARGOT_OBJECT_SUBCLASS_MUST_REDEFINE
{
Value::ValueIndex idx;
if (LIKELY(P.isUIntType())) {
@ -30,7 +30,7 @@ Object::ObjectGetResult StringObject::getOwnProperty(ExecutionState& state, cons
if (LIKELY(idx != Value::InvalidIndexValue)) {
size_t strLen = m_primitiveValue->length();
if (LIKELY(idx < strLen)) {
return Object::ObjectGetResult(Value(String::fromCharCode(m_primitiveValue->charAt(idx))), false, true, false);
return ObjectGetResult(Value(String::fromCharCode(m_primitiveValue->charAt(idx))), false, true, false);
}
}
return Object::getOwnProperty(state, P);