本文整理汇总了C++中JSGlobalObject::globalScopeChain方法的典型用法代码示例。如果您正苦于以下问题:C++ JSGlobalObject::globalScopeChain方法的具体用法?C++ JSGlobalObject::globalScopeChain怎么用?C++ JSGlobalObject::globalScopeChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSGlobalObject
的用法示例。
在下文中一共展示了JSGlobalObject::globalScopeChain方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JSEvaluateScript
JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSObject* jsThisObject = toJS(thisObject);
// evaluate sets "this" to the global object if it is NULL
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject);
if (completion.complType() == Throw) {
if (exception)
*exception = toRef(completion.value());
return 0;
}
if (completion.value())
return toRef(completion.value());
// happens, for example, when the only statement is an empty (';') statement
return toRef(jsUndefined());
}
示例2: functionLoad
JSValue* functionLoad(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
UString fileName = args.at(exec, 0)->toString(exec);
Vector<char> script;
if (!fillBufferWithContentsOfFile(fileName, script))
return throwError(exec, GeneralError, "Could not open file.");
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), fileName, 1, script.data());
return jsUndefined();
}
示例3: functionLoad
EncodedJSValue JSC_HOST_CALL functionLoad(ExecState* exec)
{
UString fileName = exec->argument(0).toString(exec);
Vector<char> script;
if (!fillBufferWithContentsOfFile(fileName, script))
return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
Completion result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName));
if (result.complType() == Throw)
throwError(exec, result.value());
return JSValue::encode(result.value());
}
示例4: functionLoad
EncodedJSValue JSC_HOST_CALL functionLoad(ExecState* exec)
{
UString fileName = exec->argument(0).toString(exec)->value(exec);
Vector<char> script;
if (!fillBufferWithContentsOfFile(fileName, script))
return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
JSValue evaluationException;
JSValue result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), jscSource(script.data(), fileName), JSValue(), &evaluationException);
if (evaluationException)
throwError(exec, evaluationException);
return JSValue::encode(result);
}
示例5: functionLoad
JSValue JSC_HOST_CALL functionLoad(ExecState* exec, JSObject* o, JSValue v, const ArgList& args)
{
UNUSED_PARAM(o);
UNUSED_PARAM(v);
UString fileName = args.at(0).toString(exec);
Vector<char> script;
if (!fillBufferWithContentsOfFile(fileName, script))
return throwError(exec, GeneralError, "Could not open file.");
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
Completion result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName));
if (result.complType() == Throw)
exec->setException(result.value());
return result.value();
}
示例6: functionRun
JSValue* functionRun(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
StopWatch stopWatch;
UString fileName = args.at(exec, 0)->toString(exec);
Vector<char> script;
if (!fillBufferWithContentsOfFile(fileName, script))
return throwError(exec, GeneralError, "Could not open file.");
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
stopWatch.start();
Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), fileName, 1, script.data());
stopWatch.stop();
return jsNumber(globalObject->globalExec(), stopWatch.getElapsedMS());
}
示例7: functionRun
JSValue JSC_HOST_CALL functionRun(ExecState* exec, JSObject*, JSValue, const ArgList& args)
{
StopWatch stopWatch;
UString fileName = args.at(0).toString(exec);
Vector<char> script;
if (!fillBufferWithContentsOfFile(fileName, script))
return throwError(exec, GeneralError, "Could not open file.");
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
stopWatch.start();
evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName));
stopWatch.stop();
return jsNumber(globalObject->globalExec(), stopWatch.getElapsedMS());
}
示例8: JSEvaluateScript
JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
JSLock lock;
ExecState* exec = toJS(ctx);
JSObject* jsThisObject = toJS(thisObject);
UString::Rep* scriptRep = toJS(script);
UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null;
// Interpreter::evaluate sets "this" to the global object if it is NULL
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
Completion completion = Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), UString(sourceURLRep), startingLineNumber, UString(scriptRep), jsThisObject);
if (completion.complType() == Throw) {
if (exception)
*exception = toRef(completion.value());
return 0;
}
if (completion.value())
return toRef(completion.value());
// happens, for example, when the only statement is an empty (';') statement
return toRef(jsUndefined());
}