本文整理汇总了C++中ExecState::vmEntryGlobalObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecState::vmEntryGlobalObject方法的具体用法?C++ ExecState::vmEntryGlobalObject怎么用?C++ ExecState::vmEntryGlobalObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecState
的用法示例。
在下文中一共展示了ExecState::vmEntryGlobalObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JSCheckScriptSyntax
bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return false;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
startingLineNumber = std::max(1, startingLineNumber);
SourceCode source = makeSource(script->string(), sourceURL ? sourceURL->string() : String(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
JSValue syntaxException;
bool isValidSyntax = checkSyntax(exec->vmEntryGlobalObject()->globalExec(), source, &syntaxException);
if (!isValidSyntax) {
if (exception)
*exception = toRef(exec, syntaxException);
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, syntaxException);
#endif
return false;
}
return true;
}
示例2: JSGlobalContextRelease
void JSGlobalContextRelease(JSGlobalContextRef ctx)
{
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
VM& vm = exec->vm();
bool protectCountIsZero = Heap::heap(exec->vmEntryGlobalObject())->unprotect(exec->vmEntryGlobalObject());
if (protectCountIsZero)
vm.heap.reportAbandonedObjectGraph();
vm.deref();
}
示例3: JSObjectSetProperty
void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->vm()));
JSValue jsValue = toJS(exec, value);
if (attributes && !jsObject->hasProperty(exec, name)) {
PropertyDescriptor desc(jsValue, attributes);
jsObject->methodTable()->defineOwnProperty(jsObject, exec, name, desc, false);
} else {
PutPropertySlot slot(jsObject);
jsObject->methodTable()->put(jsObject, exec, name, jsValue, slot);
}
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
}
}
示例4: JSObjectMakeError
JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
JSValue message = argumentCount ? toJS(exec, arguments[0]) : jsUndefined();
Structure* errorStructure = exec->lexicalGlobalObject()->errorStructure();
JSObject* result = ErrorInstance::create(exec, errorStructure, message);
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
result = 0;
}
return toRef(result);
}
示例5: JSObjectCallAsConstructor
JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
if (!object)
return 0;
JSObject* jsObject = toJS(object);
ConstructData constructData;
ConstructType constructType = jsObject->methodTable()->getConstructData(jsObject, constructData);
if (constructType == ConstructTypeNone)
return 0;
MarkedArgumentBuffer argList;
for (size_t i = 0; i < argumentCount; i++)
argList.append(toJS(exec, arguments[i]));
JSObjectRef result = toRef(construct(exec, jsObject, constructType, constructData, argList));
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
result = 0;
}
return result;
}
示例6: JSObjectMakeRegExp
JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
MarkedArgumentBuffer argList;
for (size_t i = 0; i < argumentCount; ++i)
argList.append(toJS(exec, arguments[i]));
JSObject* result = constructRegExp(exec, exec->lexicalGlobalObject(), argList);
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
result = 0;
}
return toRef(result);
}
示例7: JSObjectMakeFunction
JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
startingLineNumber = std::max(1, startingLineNumber);
Identifier nameID = name ? name->identifier(&exec->vm()) : Identifier(exec, "anonymous");
MarkedArgumentBuffer args;
for (unsigned i = 0; i < parameterCount; i++)
args.append(jsString(exec, parameterNames[i]->string()));
args.append(jsString(exec, body->string()));
JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
result = 0;
}
return toRef(result);
}
示例8: JSEvaluateScript
JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* jsThisObject = toJS(thisObject);
startingLineNumber = std::max(1, startingLineNumber);
// evaluate sets "this" to the global object if it is NULL
JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
JSValue evaluationException;
JSValue returnValue = evaluate(globalObject->globalExec(), source, jsThisObject, &evaluationException);
if (evaluationException) {
if (exception)
*exception = toRef(exec, evaluationException);
return 0;
}
if (returnValue)
return toRef(exec, returnValue);
// happens, for example, when the only statement is an empty (';') statement
return toRef(exec, jsUndefined());
}
示例9: JSValueIsInstanceOfConstructor
bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return false;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
JSValue jsValue = toJS(exec, value);
JSObject* jsConstructor = toJS(constructor);
if (!jsConstructor->structure()->typeInfo().implementsHasInstance())
return false;
bool result = jsConstructor->hasInstance(exec, jsValue); // false if an exception is thrown
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
}
return result;
}
示例10: JSGlobalContextRetain
JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
{
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
VM& vm = exec->vm();
gcProtect(exec->vmEntryGlobalObject());
vm.ref();
return ctx;
}
示例11: JSGlobalContextSetName
void JSGlobalContextSetName(JSGlobalContextRef ctx, JSStringRef name)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
exec->vmEntryGlobalObject()->setName(name ? name->string() : String());
}
示例12: JSGlobalContextGetRemoteInspectionEnabled
bool JSGlobalContextGetRemoteInspectionEnabled(JSGlobalContextRef ctx)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return false;
}
ExecState* exec = toJS(ctx);
JSLockHolder lock(exec);
return exec->vmEntryGlobalObject()->remoteDebuggingEnabled();
}
示例13: JSGlobalContextSetRemoteInspectionEnabled
void JSGlobalContextSetRemoteInspectionEnabled(JSGlobalContextRef ctx, bool enabled)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return;
}
ExecState* exec = toJS(ctx);
JSLockHolder lock(exec);
exec->vmEntryGlobalObject()->setRemoteDebuggingEnabled(enabled);
}
示例14: JSGlobalContextGetAugmentableInspectorController
Inspector::AugmentableInspectorController* JSGlobalContextGetAugmentableInspectorController(JSGlobalContextRef ctx)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return nullptr;
}
ExecState* exec = toJS(ctx);
JSLockHolder lock(exec);
return &exec->vmEntryGlobalObject()->inspectorController();
}
示例15: JSGlobalContextCopyName
JSStringRef JSGlobalContextCopyName(JSGlobalContextRef ctx)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
String name = exec->vmEntryGlobalObject()->name();
if (name.isNull())
return 0;
return OpaqueJSString::create(name).leakRef();
}