本文整理汇总了C++中JSValue::isSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::isSymbol方法的具体用法?C++ JSValue::isSymbol怎么用?C++ JSValue::isSymbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSValue
的用法示例。
在下文中一共展示了JSValue::isSymbol方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jsTypeStringForValue
JSValue jsTypeStringForValue(VM& vm, JSGlobalObject* globalObject, JSValue v)
{
if (v.isUndefined())
return vm.smallStrings.undefinedString();
if (v.isBoolean())
return vm.smallStrings.booleanString();
if (v.isNumber())
return vm.smallStrings.numberString();
if (v.isString())
return vm.smallStrings.stringString();
if (v.isSymbol())
return vm.smallStrings.symbolString();
if (v.isObject()) {
JSObject* object = asObject(v);
// Return "undefined" for objects that should be treated
// as null when doing comparisons.
if (object->structure(vm)->masqueradesAsUndefined(globalObject))
return vm.smallStrings.undefinedString();
if (object->type() == JSFunctionType)
return vm.smallStrings.functionString();
if (object->inlineTypeFlags() & TypeOfShouldCallGetCallData) {
CallData callData;
JSObject* object = asObject(v);
if (object->methodTable(vm)->getCallData(object, callData) != CallTypeNone)
return vm.smallStrings.functionString();
}
}
return vm.smallStrings.objectString();
}
示例2: subtype
JSValue JSInjectedScriptHost::subtype(ExecState* exec)
{
if (exec->argumentCount() < 1)
return jsUndefined();
JSValue value = exec->uncheckedArgument(0);
if (value.isString())
return exec->vm().smallStrings.stringString();
if (value.isBoolean())
return exec->vm().smallStrings.booleanString();
if (value.isNumber())
return exec->vm().smallStrings.numberString();
if (value.isSymbol())
return exec->vm().smallStrings.symbolString();
JSObject* object = asObject(value);
if (object) {
if (object->isErrorInstance())
return jsNontrivialString(exec, ASCIILiteral("error"));
// Consider class constructor functions class objects.
JSFunction* function = jsDynamicCast<JSFunction*>(value);
if (function && function->isClassConstructorFunction())
return jsNontrivialString(exec, ASCIILiteral("class"));
}
if (value.inherits(JSArray::info()))
return jsNontrivialString(exec, ASCIILiteral("array"));
if (value.inherits(DirectArguments::info()) || value.inherits(ScopedArguments::info()))
return jsNontrivialString(exec, ASCIILiteral("array"));
if (value.inherits(DateInstance::info()))
return jsNontrivialString(exec, ASCIILiteral("date"));
if (value.inherits(RegExpObject::info()))
return jsNontrivialString(exec, ASCIILiteral("regexp"));
if (value.inherits(JSMap::info()))
return jsNontrivialString(exec, ASCIILiteral("map"));
if (value.inherits(JSSet::info()))
return jsNontrivialString(exec, ASCIILiteral("set"));
if (value.inherits(JSWeakMap::info()))
return jsNontrivialString(exec, ASCIILiteral("weakmap"));
if (value.inherits(JSWeakSet::info()))
return jsNontrivialString(exec, ASCIILiteral("weakset"));
if (value.inherits(JSArrayIterator::info())
|| value.inherits(JSMapIterator::info())
|| value.inherits(JSSetIterator::info())
|| value.inherits(JSStringIterator::info()))
return jsNontrivialString(exec, ASCIILiteral("iterator"));
if (value.inherits(JSInt8Array::info()) || value.inherits(JSInt16Array::info()) || value.inherits(JSInt32Array::info()))
return jsNontrivialString(exec, ASCIILiteral("array"));
if (value.inherits(JSUint8Array::info()) || value.inherits(JSUint16Array::info()) || value.inherits(JSUint32Array::info()))
return jsNontrivialString(exec, ASCIILiteral("array"));
if (value.inherits(JSFloat32Array::info()) || value.inherits(JSFloat64Array::info()))
return jsNontrivialString(exec, ASCIILiteral("array"));
return impl().subtype(exec, value);
}
示例3: runtimeTypeForValue
RuntimeType runtimeTypeForValue(JSValue value)
{
if (UNLIKELY(!value))
return TypeNothing;
if (value.isUndefined())
return TypeUndefined;
if (value.isNull())
return TypeNull;
if (value.isAnyInt())
return TypeAnyInt;
if (value.isNumber())
return TypeNumber;
if (value.isString())
return TypeString;
if (value.isBoolean())
return TypeBoolean;
if (value.isObject())
return TypeObject;
if (value.isFunction())
return TypeFunction;
if (value.isSymbol())
return TypeSymbol;
return TypeNothing;
}
示例4: encode
static EncodedJSValue JSC_HOST_CALL callStringConstructor(ExecState* exec)
{
if (!exec->argumentCount())
return JSValue::encode(jsEmptyString(exec));
JSValue argument = exec->uncheckedArgument(0);
if (argument.isSymbol())
return JSValue::encode(jsString(exec, asSymbol(argument)->descriptiveString()));
return JSValue::encode(argument.toString(exec));
}
示例5: symbolProtoFuncValueOf
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());
}
示例6: symbolConstructorKeyFor
EncodedJSValue JSC_HOST_CALL symbolConstructorKeyFor(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue symbolValue = exec->argument(0);
if (!symbolValue.isSymbol())
return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral(SymbolKeyForTypeError)));
SymbolImpl& uid = asSymbol(symbolValue)->privateName().uid();
if (!uid.symbolRegistry())
return JSValue::encode(jsUndefined());
ASSERT(uid.symbolRegistry() == &vm.symbolRegistry());
return JSValue::encode(jsString(exec, &uid));
}
示例7: symbolProtoFuncToString
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()));
}
示例8: symbolProtoFuncValueOf
EncodedJSValue JSC_HOST_CALL symbolProtoFuncValueOf(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue thisValue = exec->thisValue();
if (thisValue.isSymbol())
return JSValue::encode(thisValue);
if (!thisValue.isObject())
return throwVMTypeError(exec, scope, SymbolValueOfTypeError);
JSObject* thisObject = asObject(thisValue);
if (!thisObject->inherits(vm, SymbolObject::info()))
return throwVMTypeError(exec, scope, SymbolValueOfTypeError);
return JSValue::encode(jsCast<SymbolObject*>(thisObject)->internalValue());
}
示例9: symbolProtoFuncToString
EncodedJSValue JSC_HOST_CALL symbolProtoFuncToString(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue thisValue = exec->thisValue();
Symbol* symbol = nullptr;
if (thisValue.isSymbol())
symbol = asSymbol(thisValue);
else {
if (!thisValue.isObject())
return throwVMTypeError(exec, scope, SymbolToStringTypeError);
JSObject* thisObject = asObject(thisValue);
if (!thisObject->inherits(vm, SymbolObject::info()))
return throwVMTypeError(exec, scope, SymbolToStringTypeError);
symbol = asSymbol(jsCast<SymbolObject*>(thisObject)->internalValue());
}
return JSValue::encode(jsNontrivialString(exec, symbol->descriptiveString()));
}
示例10: printableModuleKey
static String printableModuleKey(ExecState* exec, JSValue key)
{
if (key.isString() || key.isSymbol())
return key.toPropertyKey(exec).impl();
return exec->propertyNames().emptyIdentifier.impl();
}
示例11: parseGlobalSection
void WASMModuleParser::parseGlobalSection(ExecState* exec)
{
uint32_t numberOfInternalI32GlobalVariables;
uint32_t numberOfInternalF32GlobalVariables;
uint32_t numberOfInternalF64GlobalVariables;
uint32_t numberOfImportedI32GlobalVariables;
uint32_t numberOfImportedF32GlobalVariables;
uint32_t numberOfImportedF64GlobalVariables;
READ_COMPACT_UINT32_OR_FAIL(numberOfInternalI32GlobalVariables, "Cannot read the number of internal int32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfInternalF32GlobalVariables, "Cannot read the number of internal float32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfInternalF64GlobalVariables, "Cannot read the number of internal float64 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfImportedI32GlobalVariables, "Cannot read the number of imported int32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfImportedF32GlobalVariables, "Cannot read the number of imported float32 global variables.");
READ_COMPACT_UINT32_OR_FAIL(numberOfImportedF64GlobalVariables, "Cannot read the number of imported float64 global variables.");
uint32_t numberOfGlobalVariables = numberOfInternalI32GlobalVariables + numberOfInternalF32GlobalVariables + numberOfInternalF64GlobalVariables +
numberOfImportedI32GlobalVariables + numberOfImportedF32GlobalVariables + numberOfImportedF64GlobalVariables;
Vector<WASMType>& globalVariableTypes = m_module->globalVariableTypes();
globalVariableTypes.reserveInitialCapacity(numberOfGlobalVariables);
Vector<JSWASMModule::GlobalVariable>& globalVariables = m_module->globalVariables();
globalVariables.reserveInitialCapacity(numberOfGlobalVariables);
for (uint32_t i = 0; i < numberOfInternalI32GlobalVariables; ++i) {
globalVariableTypes.uncheckedAppend(WASMType::I32);
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0));
}
for (uint32_t i = 0; i < numberOfInternalF32GlobalVariables; ++i) {
globalVariableTypes.uncheckedAppend(WASMType::F32);
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0.0f));
}
for (uint32_t i = 0; i < numberOfInternalF64GlobalVariables; ++i) {
globalVariableTypes.uncheckedAppend(WASMType::F64);
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(0.0));
}
for (uint32_t i = 0; i < numberOfImportedI32GlobalVariables; ++i) {
String importName;
READ_STRING_OR_FAIL(importName, "Cannot read the import name of an int32 global variable.");
globalVariableTypes.uncheckedAppend(WASMType::I32);
JSValue value;
getImportedValue(exec, importName, value);
PROPAGATE_ERROR();
FAIL_IF_FALSE(value.isPrimitive() && !value.isSymbol(), "\"" + importName + "\" is not a primitive or is a Symbol.");
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(value.toInt32(exec)));
}
for (uint32_t i = 0; i < numberOfImportedF32GlobalVariables; ++i) {
String importName;
READ_STRING_OR_FAIL(importName, "Cannot read the import name of a float32 global variable.");
globalVariableTypes.uncheckedAppend(WASMType::F32);
JSValue value;
getImportedValue(exec, importName, value);
PROPAGATE_ERROR();
FAIL_IF_FALSE(value.isPrimitive() && !value.isSymbol(), "\"" + importName + "\" is not a primitive or is a Symbol.");
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(static_cast<float>(value.toNumber(exec))));
}
for (uint32_t i = 0; i < numberOfImportedF64GlobalVariables; ++i) {
String importName;
READ_STRING_OR_FAIL(importName, "Cannot read the import name of a float64 global variable.");
globalVariableTypes.uncheckedAppend(WASMType::F64);
JSValue value;
getImportedValue(exec, importName, value);
PROPAGATE_ERROR();
FAIL_IF_FALSE(value.isPrimitive() && !value.isSymbol(), "\"" + importName + "\" is not a primitive or is a Symbol.");
globalVariables.uncheckedAppend(JSWASMModule::GlobalVariable(value.toNumber(exec)));
}
}