implement String.prototype.match, parseInt

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
seonghyun kim 2016-12-14 18:54:46 +09:00
commit c22735e9b3
9 changed files with 276 additions and 22 deletions

View file

@ -293,4 +293,22 @@ ArrayObject* RegExpObject::createRegExpMatchedArray(ExecutionState& state, const
}
return arr;
}
void RegExpObject::pushBackToRegExpMatchedArray(ExecutionState& state, ArrayObject* array, size_t& index, const size_t limit, const RegexMatchResult& result, String* str)
{
for (unsigned i = 0; i < result.m_matchResults.size(); i++) {
for (unsigned j = 0; j < result.m_matchResults[i].size(); j++) {
if (i == 0 && j == 0)
continue;
if (std::numeric_limits<unsigned>::max() == result.m_matchResults[i][j].m_start) {
array->defineOwnPropertyThrowsException(state, ObjectPropertyName(state, Value(index++)), ObjectPropertyDescriptorForDefineOwnProperty(Value(), ObjectPropertyDescriptorForDefineOwnProperty::AllPresent));
} else {
array->defineOwnPropertyThrowsException(state, ObjectPropertyName(state, Value(index++)), ObjectPropertyDescriptorForDefineOwnProperty(str->subString(result.m_matchResults[i][j].m_start, result.m_matchResults[i][j].m_end), ObjectPropertyDescriptorForDefineOwnProperty::AllPresent));
}
if (index == limit)
return;
}
}
}
}