ALWAYS_INLINE static MapData* getMapData(CallFrame* callFrame, JSValue thisValue) { if (!thisValue.isObject()) { throwVMError(callFrame, createNotAnObjectError(callFrame, thisValue)); return 0; } JSMap* map = jsDynamicCast<JSMap*>(thisValue); if (!map) { throwTypeError(callFrame, ASCIILiteral("Map operation called on non-Map object")); return 0; } return map->mapData(); }
ALWAYS_INLINE static JSSet* getSet(CallFrame* callFrame, JSValue thisValue) { if (!thisValue.isObject()) { throwVMError(callFrame, createNotAnObjectError(callFrame, thisValue)); return nullptr; } JSSet* set = jsDynamicCast<JSSet*>(thisValue); if (!set) { throwTypeError(callFrame, ASCIILiteral("Set operation called on non-Set object")); return nullptr; } return set; }
ALWAYS_INLINE static JSSet* getSet(CallFrame* callFrame, JSValue thisValue) { VM& vm = callFrame->vm(); auto scope = DECLARE_THROW_SCOPE(vm); if (UNLIKELY(!thisValue.isCell())) { throwVMError(callFrame, scope, createNotAnObjectError(callFrame, thisValue)); return nullptr; } if (LIKELY(thisValue.asCell()->type() == JSSetType)) return jsCast<JSSet*>(thisValue); throwTypeError(callFrame, scope, ASCIILiteral("Set operation called on non-Set object")); return nullptr; }
JSObject* JSValue::toObjectSlowCase(ExecState* exec, JSGlobalObject* globalObject) const { VM& vm = exec->vm(); auto scope = DECLARE_THROW_SCOPE(vm); ASSERT(!isCell()); if (isInt32() || isDouble()) return constructNumber(exec, globalObject, asValue()); if (isTrue() || isFalse()) return constructBooleanFromImmediateBoolean(exec, globalObject, asValue()); ASSERT(isUndefinedOrNull()); throwException(exec, scope, createNotAnObjectError(exec, *this)); return nullptr; }
ALWAYS_INLINE static JSMap* getMap(CallFrame* callFrame, JSValue thisValue) { VM& vm = callFrame->vm(); auto scope = DECLARE_THROW_SCOPE(vm); if (UNLIKELY(!thisValue.isCell())) { throwVMError(callFrame, scope, createNotAnObjectError(callFrame, thisValue)); return nullptr; } auto* map = jsDynamicCast<JSMap*>(vm, thisValue.asCell()); if (LIKELY(map)) return map; throwTypeError(callFrame, scope, "Map operation called on non-Map object"_s); return nullptr; }
JSObject* JSValue::synthesizePrototype(ExecState* exec) const { VM& vm = exec->vm(); auto scope = DECLARE_THROW_SCOPE(vm); if (isCell()) { if (isString()) return exec->lexicalGlobalObject()->stringPrototype(); ASSERT(isSymbol()); return exec->lexicalGlobalObject()->symbolPrototype(); } if (isNumber()) return exec->lexicalGlobalObject()->numberPrototype(); if (isBoolean()) return exec->lexicalGlobalObject()->booleanPrototype(); ASSERT(isUndefinedOrNull()); throwException(exec, scope, createNotAnObjectError(exec, *this)); return nullptr; }