本文整理汇总了C++中JSValue函数的典型用法代码示例。如果您正苦于以下问题:C++ JSValue函数的具体用法?C++ JSValue怎么用?C++ JSValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JSValue函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: asActivation
JSValue JSActivation::argumentsGetter(ExecState*, JSValue slotBase, const Identifier&)
{
JSActivation* activation = asActivation(slotBase);
CallFrame* callFrame = CallFrame::create(reinterpret_cast<Register*>(activation->m_registers));
int argumentsRegister = activation->m_argumentsRegister;
if (JSValue arguments = callFrame->uncheckedR(argumentsRegister).jsValue())
return arguments;
int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister);
JSValue arguments = JSValue(Arguments::create(callFrame->globalData(), callFrame));
callFrame->uncheckedR(argumentsRegister) = arguments;
callFrame->uncheckedR(realArgumentsRegister) = arguments;
ASSERT(callFrame->uncheckedR(realArgumentsRegister).jsValue().inherits(&Arguments::s_info));
return callFrame->uncheckedR(realArgumentsRegister).jsValue();
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:16,代码来源:JSActivation.cpp
示例2: functionCodeBlockForFrame
static EncodedJSValue JSC_HOST_CALL functionCodeBlockForFrame(ExecState* exec)
{
if (exec->argumentCount() < 1)
return JSValue::encode(jsUndefined());
JSValue value = exec->uncheckedArgument(0);
if (!value.isUInt32())
return JSValue::encode(jsUndefined());
// We need to inc the frame number because the caller would consider
// its own frame as frame 0. Hence, we need discount the frame for this
// function.
unsigned frameNumber = value.asUInt32() + 1;
CodeBlock* codeBlock = JSDollarVMPrototype::codeBlockForFrame(exec, frameNumber);
return JSValue::encode(JSValue(bitwise_cast<double>(reinterpret_cast<uint64_t>(codeBlock))));
}
开发者ID:biddyweb,项目名称:switch-oss,代码行数:16,代码来源:JSDollarVMPrototype.cpp
示例3: addPtr
void JIT::compileCallEval(Instruction* instruction)
{
addPtr(TrustedImm32(-static_cast<ptrdiff_t>(sizeof(CallerFrameAndPC))), stackPointerRegister, regT1);
storePtr(callFrameRegister, Address(regT1, CallFrame::callerFrameOffset()));
addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, stackPointerRegister);
checkStackPointerAlignment();
callOperation(operationCallEval, regT1);
addSlowCase(branch64(Equal, regT0, TrustedImm64(JSValue::encode(JSValue()))));
sampleCodeBlock(m_codeBlock);
emitPutCallResult(instruction);
}
开发者ID:ollie314,项目名称:webkit,代码行数:16,代码来源:JITCall.cpp
示例4: DECLARE_THROW_SCOPE
JSValue JSDOMWindow::setInterval(ExecState& state)
{
VM& vm = state.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
if (UNLIKELY(state.argumentCount() < 1))
return throwException(&state, scope, createNotEnoughArgumentsError(&state));
auto* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
auto action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
RETURN_IF_EXCEPTION(scope, JSValue());
if (!action)
return jsNumber(0);
int delay = state.argument(1).toInt32(&state);
return toJS<IDLLong>(state, scope, wrapped().setInterval(WTFMove(action), delay));
}
开发者ID:ollie314,项目名称:webkit,代码行数:17,代码来源:JSDOMWindowCustom.cpp
示例5: JSString
JSValue::operator JSString() const {
HAL_JSVALUE_LOCK_GUARD;
JSValueRef exception { nullptr };
JSStringRef js_string_ref = JSValueToStringCopy(static_cast<JSContextRef>(js_context__), js_value_ref__, &exception);
if (exception) {
// If this assert fails then we need to JSStringRelease
// js_string_ref.
assert(!js_string_ref);
detail::ThrowRuntimeError("JSValue", JSValue(js_context__, exception));
}
assert(js_string_ref);
JSString js_string(js_string_ref);
JSStringRelease(js_string_ref);
return js_string;
}
开发者ID:CodexLabs,项目名称:HAL,代码行数:17,代码来源:JSValue.cpp
示例6: switch
void JSWeakValue::clear()
{
switch (m_tag) {
case WeakTypeTag::NotSet:
return;
case WeakTypeTag::Primitive:
m_value.primitive = JSValue();
return;
case WeakTypeTag::Object:
m_value.object.clear();
return;
case WeakTypeTag::String:
m_value.string.clear();
return;
}
RELEASE_ASSERT_NOT_REACHED();
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:17,代码来源:JSWeakValue.cpp
示例7: inContext
void GetByIdVariant::dumpInContext(PrintStream& out, DumpContext* context) const
{
if (!isSet()) {
out.print("<empty>");
return;
}
out.print(
"<", inContext(structureSet(), context), ", ",
"[", listDumpInContext(m_constantChecks, context), "]");
if (m_alternateBase)
out.print(", alternateBase = ", inContext(JSValue(m_alternateBase), context));
out.print(", offset = ", offset());
if (m_callLinkStatus)
out.print(", call = ", *m_callLinkStatus);
out.print(">");
}
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:17,代码来源:GetByIdVariant.cpp
示例8: reason
void Debugger::exception(CallFrame* callFrame, JSValue exception, bool hasHandler)
{
if (m_isPaused)
return;
PauseReasonDeclaration reason(*this, PausedForException);
if (m_pauseOnExceptionsState == PauseOnAllExceptions || (m_pauseOnExceptionsState == PauseOnUncaughtExceptions && !hasHandler)) {
m_pauseOnNextStatement = true;
setSteppingMode(SteppingModeEnabled);
}
m_hasHandlerForExceptionCallback = true;
m_currentException = exception;
updateCallFrameAndPauseIfNeeded(callFrame);
m_currentException = JSValue();
m_hasHandlerForExceptionCallback = false;
}
开发者ID:Vitallium,项目名称:webkit,代码行数:17,代码来源:Debugger.cpp
示例9: ENABLE
void GetByIdStatus::computeForChain(GetByIdStatus& result, CodeBlock* profiledBlock, Identifier& ident, Structure* structure)
{
#if ENABLE(JIT) && ENABLE(VALUE_PROFILER)
// Validate the chain. If the chain is invalid, then currently the best thing
// we can do is to assume that TakesSlow is true. In the future, it might be
// worth exploring reifying the structure chain from the structure we've got
// instead of using the one from the cache, since that will do the right things
// if the structure chain has changed. But that may be harder, because we may
// then end up having a different type of access altogether. And it currently
// does not appear to be worth it to do so -- effectively, the heuristic we
// have now is that if the structure chain has changed between when it was
// cached on in the baseline JIT and when the DFG tried to inline the access,
// then we fall back on a polymorphic access.
Structure* currentStructure = structure;
JSObject* currentObject = 0;
for (unsigned i = 0; i < result.m_chain.size(); ++i) {
ASSERT(!currentStructure->isDictionary());
currentObject = asObject(currentStructure->prototypeForLookup(profiledBlock));
currentStructure = result.m_chain[i];
if (currentObject->structure() != currentStructure)
return;
}
ASSERT(currentObject);
unsigned attributesIgnored;
JSCell* specificValue;
result.m_offset = currentStructure->get(
*profiledBlock->vm(), ident, attributesIgnored, specificValue);
if (currentStructure->isDictionary())
specificValue = 0;
if (!isValidOffset(result.m_offset))
return;
result.m_structureSet.add(structure);
result.m_specificValue = JSValue(specificValue);
#else
UNUSED_PARAM(result);
UNUSED_PARAM(profiledBlock);
UNUSED_PARAM(ident);
UNUSED_PARAM(structure);
UNREACHABLE_FOR_PLATFORM();
#endif
}
开发者ID:Anthony-Biget,项目名称:openjfx,代码行数:45,代码来源:GetByIdStatus.cpp
示例10: constructWeakMap
static EncodedJSValue JSC_HOST_CALL constructWeakMap(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
Structure* weakMapStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->weakMapStructure());
if (exec->hadException())
return JSValue::encode(JSValue());
JSWeakMap* weakMap = JSWeakMap::create(exec, weakMapStructure);
JSValue iterable = exec->argument(0);
if (iterable.isUndefinedOrNull())
return JSValue::encode(weakMap);
JSValue adderFunction = weakMap->JSObject::get(exec, exec->propertyNames().set);
if (exec->hadException())
return JSValue::encode(jsUndefined());
CallData adderFunctionCallData;
CallType adderFunctionCallType = getCallData(adderFunction, adderFunctionCallData);
if (adderFunctionCallType == CallType::None)
return JSValue::encode(throwTypeError(exec, scope));
forEachInIterable(exec, iterable, [&](VM& vm, ExecState* exec, JSValue nextItem) {
if (!nextItem.isObject()) {
throwTypeError(exec, scope);
return;
}
JSValue key = nextItem.get(exec, static_cast<unsigned>(0));
if (vm.exception())
return;
JSValue value = nextItem.get(exec, static_cast<unsigned>(1));
if (vm.exception())
return;
MarkedArgumentBuffer arguments;
arguments.append(key);
arguments.append(value);
call(exec, adderFunction, adderFunctionCallType, adderFunctionCallData, weakMap, arguments);
});
return JSValue::encode(weakMap);
}
开发者ID:endlessm,项目名称:WebKit,代码行数:45,代码来源:WeakMapConstructor.cpp
示例11: unmodifiedArgumentsRegister
EncodedJSValue JSLexicalEnvironment::argumentsGetter(ExecState*, JSObject* slotBase, EncodedJSValue, PropertyName)
{
JSLexicalEnvironment* lexicalEnvironment = jsCast<JSLexicalEnvironment*>(slotBase);
CallFrame* callFrame = CallFrame::create(reinterpret_cast<Register*>(lexicalEnvironment->m_registers));
return JSValue::encode(jsUndefined());
VirtualRegister argumentsRegister = callFrame->codeBlock()->argumentsRegister();
if (JSValue arguments = callFrame->uncheckedR(argumentsRegister.offset()).jsValue())
return JSValue::encode(arguments);
int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister).offset();
JSValue arguments = JSValue(Arguments::create(callFrame->vm(), callFrame));
callFrame->uncheckedR(argumentsRegister.offset()) = arguments;
callFrame->uncheckedR(realArgumentsRegister) = arguments;
ASSERT(callFrame->uncheckedR(realArgumentsRegister).jsValue().inherits(Arguments::info()));
return JSValue::encode(callFrame->uncheckedR(realArgumentsRegister).jsValue());
}
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:18,代码来源:JSLexicalEnvironment.cpp
示例12: if
void AbstractValue::setType(Graph& graph, SpeculatedType type)
{
SpeculatedType cellType = type & SpecCell;
if (cellType) {
if (!(cellType & ~SpecString))
m_structure = graph.m_vm.stringStructure.get();
else if (isSymbolSpeculation(cellType))
m_structure = graph.m_vm.symbolStructure.get();
else
m_structure.makeTop();
m_arrayModes = ALL_ARRAY_MODES;
} else {
m_structure.clear();
m_arrayModes = 0;
}
m_type = type;
m_value = JSValue();
checkConsistency();
}
开发者ID:rhythmkay,项目名称:webkit,代码行数:19,代码来源:DFGAbstractValue.cpp
示例13: addPtr
void JIT::compileCallEval(Instruction* instruction)
{
addPtr(TrustedImm32(-static_cast<ptrdiff_t>(sizeof(CallerFrameAndPC))), stackPointerRegister, regT1);
callOperationNoExceptionCheck(operationCallEval, regT1);
Jump noException = emitExceptionCheck(InvertedExceptionCheck);
addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, stackPointerRegister);
exceptionCheck(jump());
noException.link(this);
addSlowCase(branch64(Equal, regT0, TrustedImm64(JSValue::encode(JSValue()))));
addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, stackPointerRegister);
checkStackPointerAlignment();
sampleCodeBlock(m_codeBlock);
emitPutCallResult(instruction);
}
开发者ID:Wrichik1999,项目名称:webkit,代码行数:19,代码来源:JITCall.cpp
示例14: jsUndefined
JSValue JSActivation::argumentsGetter(ExecState*, JSValue slotBase, PropertyName)
{
JSActivation* activation = jsCast<JSActivation*>(slotBase);
if (activation->isTornOff())
return jsUndefined();
CallFrame* callFrame = CallFrame::create(reinterpret_cast<Register*>(activation->m_registers));
int argumentsRegister = callFrame->codeBlock()->argumentsRegister();
if (JSValue arguments = callFrame->uncheckedR(argumentsRegister).jsValue())
return arguments;
int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister);
JSValue arguments = JSValue(Arguments::create(callFrame->vm(), callFrame));
callFrame->uncheckedR(argumentsRegister) = arguments;
callFrame->uncheckedR(realArgumentsRegister) = arguments;
ASSERT(callFrame->uncheckedR(realArgumentsRegister).jsValue().inherits(Arguments::info()));
return callFrame->uncheckedR(realArgumentsRegister).jsValue();
}
开发者ID:KnightSwarm,项目名称:WebKitTi,代码行数:19,代码来源:JSActivation.cpp
示例15: operationGetByValCell
EncodedJSValue DFG_OPERATION operationGetByValCell(ExecState* exec, JSCell* base, EncodedJSValue encodedProperty)
{
JSValue property = JSValue::decode(encodedProperty);
if (property.isUInt32())
return getByVal(exec, base, property.asUInt32());
if (property.isDouble()) {
double propertyAsDouble = property.asDouble();
uint32_t propertyAsUInt32 = static_cast<uint32_t>(propertyAsDouble);
if (propertyAsUInt32 == propertyAsDouble)
return getByVal(exec, base, propertyAsUInt32);
} else if (property.isString()) {
if (JSValue result = base->fastGetOwnProperty(exec, asString(property)->value(exec)))
return JSValue::encode(result);
}
Identifier ident(exec, property.toString(exec));
return JSValue::encode(JSValue(base).get(exec, ident));
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:19,代码来源:DFGOperations.cpp
示例16: functionCodeBlockForFrame
static EncodedJSValue JSC_HOST_CALL functionCodeBlockForFrame(ExecState* exec)
{
if (exec->argumentCount() < 1)
return JSValue::encode(jsUndefined());
JSValue value = exec->uncheckedArgument(0);
if (!value.isUInt32())
return JSValue::encode(jsUndefined());
// We need to inc the frame number because the caller would consider
// its own frame as frame 0. Hence, we need discount the frame for this
// function.
unsigned frameNumber = value.asUInt32() + 1;
CodeBlock* codeBlock = JSDollarVMPrototype::codeBlockForFrame(exec, frameNumber);
// Though CodeBlock is a JSCell, it is not safe to return it directly back to JS code
// as it is an internal type that the JS code cannot handle. Hence, we first encode the
// CodeBlock* as a double token (which is safe for JS code to handle) before returning it.
return JSValue::encode(JSValue(bitwise_cast<double>(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(codeBlock)))));
}
开发者ID:mjparme,项目名称:openjdk-jfx,代码行数:19,代码来源:JSDollarVMPrototype.cpp
示例17: JSValue
bool GetByIdVariant::attemptToMerge(const GetByIdVariant& other)
{
if (m_alternateBase != other.m_alternateBase)
return false;
if (m_offset != other.m_offset)
return false;
if (m_callLinkStatus || other.m_callLinkStatus)
return false;
if (!areCompatible(m_constantChecks, other.m_constantChecks))
return false;
if (m_specificValue != other.m_specificValue)
m_specificValue = JSValue();
mergeInto(other.m_constantChecks, m_constantChecks);
m_structureSet.merge(other.m_structureSet);
return true;
}
开发者ID:sdujq,项目名称:webkit,代码行数:19,代码来源:GetByIdVariant.cpp
示例18: clear
void AbstractValue::filterValueByType()
{
// We could go further, and ensure that if the futurePossibleStructure contravenes
// the value, then we could clear both of those things. But that's unlikely to help
// in any realistic scenario, so we don't do it. Simpler is better.
if (!!m_type) {
// The type is still non-empty. It may be that the new type renders
// the value empty because it contravenes the constant value we had.
if (m_value && !validateType(m_value))
clear();
return;
}
// The type has been rendered empty. That means that the value must now be invalid,
// as well.
ASSERT(!m_value || !validateType(m_value));
m_value = JSValue();
}
开发者ID:KnightSwarm,项目名称:WebKitTi,代码行数:19,代码来源:DFGAbstractValue.cpp
示例19: JSObjectMakeFunction
JSObjectRef JSFunction::MakeFunction(const JSContext& js_context, const JSString& body, const std::vector<JSString>& parameter_names, const JSString& function_name, const JSString& source_url, int starting_line_number) {
JSValueRef exception { nullptr };
JSStringRef source_url_ref = (source_url.length() > 0) ? static_cast<JSStringRef>(source_url) : nullptr;
JSObjectRef js_object_ref = nullptr;
if (!parameter_names.empty()) {
std::vector<JSStringRef> parameter_name_array = detail::to_vector(parameter_names);
js_object_ref = JSObjectMakeFunction(static_cast<JSContextRef>(js_context), static_cast<JSStringRef>(function_name), static_cast<unsigned>(parameter_name_array.size()), ¶meter_name_array[0], static_cast<JSStringRef>(body), source_url_ref, starting_line_number, &exception);
} else {
js_object_ref = JSObjectMakeFunction(static_cast<JSContextRef>(js_context), static_cast<JSStringRef>(function_name), 0, nullptr, static_cast<JSStringRef>(body), source_url_ref, starting_line_number, &exception);
}
if (exception) {
// If this assert fails then we need to JSValueUnprotect
// js_object_ref.
assert(!js_object_ref);
detail::ThrowRuntimeError("JSFunction", JSValue(js_context, exception));
}
return js_object_ref;
}
开发者ID:Sophrinix,项目名称:HAL-android,代码行数:20,代码来源:JSFunction.cpp
示例20: ASSERT
EncodedJSValue JSActivation::argumentsGetter(ExecState*, EncodedJSValue slotBase, EncodedJSValue, PropertyName)
{
JSActivation* activation = jsCast<JSActivation*>(JSValue::decode(slotBase));
CallFrame* callFrame = CallFrame::create(reinterpret_cast<Register*>(activation->m_registers));
ASSERT(!activation->isTornOff() && (callFrame->codeBlock()->usesArguments() || callFrame->codeBlock()->usesEval()));
if (activation->isTornOff() || !(callFrame->codeBlock()->usesArguments() || callFrame->codeBlock()->usesEval()))
return JSValue::encode(jsUndefined());
VirtualRegister argumentsRegister = callFrame->codeBlock()->argumentsRegister();
if (JSValue arguments = callFrame->uncheckedR(argumentsRegister.offset()).jsValue())
return JSValue::encode(arguments);
int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister).offset();
JSValue arguments = JSValue(Arguments::create(callFrame->vm(), callFrame));
callFrame->uncheckedR(argumentsRegister.offset()) = arguments;
callFrame->uncheckedR(realArgumentsRegister) = arguments;
ASSERT(callFrame->uncheckedR(realArgumentsRegister).jsValue().inherits(Arguments::info()));
return JSValue::encode(callFrame->uncheckedR(realArgumentsRegister).jsValue());
}
开发者ID:604339917,项目名称:JavaScriptCore-iOS-1,代码行数:20,代码来源:JSActivation.cpp
注:本文中的JSValue函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论