SymbolPrototype.cpp [plain text]
#include "config.h"
#include "SymbolPrototype.h"
#include "Error.h"
#include "JSCInlines.h"
namespace JSC {
static EncodedJSValue JSC_HOST_CALL symbolProtoFuncToString(ExecState*);
static EncodedJSValue JSC_HOST_CALL symbolProtoFuncValueOf(ExecState*);
}
#include "SymbolPrototype.lut.h"
namespace JSC {
const ClassInfo SymbolPrototype::s_info = { "Symbol", &Base::s_info, &symbolPrototypeTable, CREATE_METHOD_TABLE(SymbolPrototype) };
SymbolPrototype::SymbolPrototype(VM& vm, Structure* structure)
: Base(vm, structure)
{
}
void SymbolPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
}
bool SymbolPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot &slot)
{
return getStaticFunctionSlot<Base>(exec, symbolPrototypeTable, jsCast<SymbolPrototype*>(object), propertyName, slot);
}
EncodedJSValue JSC_HOST_CALL symbolProtoFuncToString(ExecState* exec)
{
JSValue thisValue = exec->thisValue();
Symbol* symbol = nullptr;
if (thisValue.isSymbol())
symbol = asSymbol(thisValue);
else if (!thisValue.isObject())
return throwVMTypeError(exec);
else {
JSObject* thisObject = asObject(thisValue);
if (!thisObject->inherits(SymbolObject::info()))
return throwVMTypeError(exec);
symbol = asSymbol(jsCast<SymbolObject*>(thisObject)->internalValue());
}
return JSValue::encode(jsNontrivialString(exec, symbol->descriptiveString()));
}
EncodedJSValue JSC_HOST_CALL symbolProtoFuncValueOf(ExecState* exec)
{
JSValue thisValue = exec->thisValue();
if (thisValue.isSymbol())
return JSValue::encode(thisValue);
if (!thisValue.isObject())
return throwVMTypeError(exec);
JSObject* thisObject = asObject(thisValue);
if (!thisObject->inherits(SymbolObject::info()))
return throwVMTypeError(exec);
return JSValue::encode(jsCast<SymbolObject*>(thisObject)->internalValue());
}
}