Implement ES6 Symbol.hasInstance, iterator, toStringTag, toPrimitive and built-ins (#46)

* Implement Array.from
* Disable part of ES6-shim due to wrong implementation

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
김승현/Tizen Platform Lab(SR)/Engineer/삼성전자 2018-01-19 15:20:27 +09:00 committed by 양지윤/Tizen Platform Lab(SR)/Engineer/삼성전자
commit e66f512b32
61 changed files with 1407 additions and 419 deletions

View file

@ -17,6 +17,7 @@
#include "Escargot.h"
#include "GlobalObject.h"
#include "Context.h"
#include "VMInstance.h"
#include "WeakMapObject.h"
#include "IteratorObject.h"
#include "ToStringRecursionPreventer.h"
@ -39,7 +40,7 @@ Value builtinWeakMapConstructor(ExecutionState& state, Value thisValue, size_t a
}
// If iterable is either undefined or null, let iter be undefined.
Value adder;
IteratorObject* iter = nullptr;
Object* iter = nullptr;
if (iterable.isUndefinedOrNull()) {
iterable = Value();
} else {
@ -65,7 +66,7 @@ Value builtinWeakMapConstructor(ExecutionState& state, Value thisValue, size_t a
// Repeat
while (true) {
// Let next be ? IteratorStep(iter).
auto next = iter->advance(state);
auto next = iter->iteratorNext(state);
// If next is false(done is true), return map.
if (next.second) {
return map;
@ -167,6 +168,9 @@ void GlobalObject::installWeakMap(ExecutionState& state)
m_weakMapPrototype->defineOwnPropertyThrowsException(state, ObjectPropertyName(state.context()->staticStrings().set),
ObjectPropertyDescriptor(new FunctionObject(state, NativeFunctionInfo(state.context()->staticStrings().set, builtinWeakMapSet, 2, nullptr, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
m_weakMapPrototype->defineOwnPropertyThrowsException(state, ObjectPropertyName(state, Value(state.context()->vmInstance()->globalSymbols().toStringTag)),
ObjectPropertyDescriptor(Value(state.context()->staticStrings().WeakMap.string()), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::ConfigurablePresent)));
m_weakMap->setFunctionPrototype(state, m_weakMapPrototype);
defineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().WeakMap),
ObjectPropertyDescriptor(m_weakMap, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));