本文整理汇总了C++中JSFunction::displayAtom方法的典型用法代码示例。如果您正苦于以下问题:C++ JSFunction::displayAtom方法的具体用法?C++ JSFunction::displayAtom怎么用?C++ JSFunction::displayAtom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSFunction
的用法示例。
在下文中一共展示了JSFunction::displayAtom方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EscapedStringPrinter
bool
LCovSource::writeScriptName(LSprinter& out, JSScript* script)
{
JSFunction* fun = script->functionNonDelazifying();
if (fun && fun->displayAtom())
return EscapedStringPrinter(out, fun->displayAtom(), 0);
out.printf("top-level");
return true;
}
示例2: arg
static JSBool
DisplayName(JSContext *cx, unsigned argc, jsval *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (argc == 0 || !args[0].isObject() || !args[0].toObject().isFunction()) {
RootedObject arg(cx, &args.callee());
ReportUsageError(cx, arg, "Must have one function argument");
return false;
}
JSFunction *fun = args[0].toObject().toFunction();
JSString *str = fun->displayAtom();
vp->setString(str == NULL ? cx->runtime->emptyString : str);
return true;
}
示例3: thisFrame
bool
SavedStacks::insertFrames(JSContext *cx, ScriptFrameIter &iter, MutableHandle<SavedFrame*> frame)
{
if (iter.done()) {
frame.set(nullptr);
return true;
}
// Don't report the over-recursion error because if we are blowing the stack
// here, we already blew the stack in JS, reported it, and we are creating
// the saved stack for the over-recursion error object. We do this check
// here, rather than inside saveCurrentStack, because in some cases we will
// pass the check there, despite later failing the check here (for example,
// in js/src/jit-test/tests/saved-stacks/bug-1006876-too-much-recursion.js).
JS_CHECK_RECURSION_DONT_REPORT(cx, return false);
ScriptFrameIter thisFrame(iter);
Rooted<SavedFrame*> parentFrame(cx);
if (!insertFrames(cx, ++iter, &parentFrame))
return false;
LocationValue location;
if (!getLocation(cx, thisFrame.script(), thisFrame.pc(), &location))
return false;
JSFunction *callee = thisFrame.maybeCallee();
SavedFrame::Lookup lookup(location.source,
location.line,
location.column,
callee ? callee->displayAtom() : nullptr,
parentFrame,
thisFrame.compartment()->principals);
frame.set(getOrCreateSavedFrame(cx, lookup));
return frame.get() != nullptr;
}
示例4: switch
JS_GetTraceThingInfo(char* buf, size_t bufsize, JSTracer* trc, void* thing,
JS::TraceKind kind, bool details)
{
const char* name = nullptr; /* silence uninitialized warning */
size_t n;
if (bufsize == 0)
return;
switch (kind) {
case JS::TraceKind::Object:
{
name = static_cast<JSObject*>(thing)->getClass()->name;
break;
}
case JS::TraceKind::Script:
name = "script";
break;
case JS::TraceKind::String:
name = ((JSString*)thing)->isDependent()
? "substring"
: "string";
break;
case JS::TraceKind::Symbol:
name = "symbol";
break;
case JS::TraceKind::BaseShape:
name = "base_shape";
break;
case JS::TraceKind::JitCode:
name = "jitcode";
break;
case JS::TraceKind::LazyScript:
name = "lazyscript";
break;
case JS::TraceKind::Shape:
name = "shape";
break;
case JS::TraceKind::ObjectGroup:
name = "object_group";
break;
default:
name = "INVALID";
break;
}
n = strlen(name);
if (n > bufsize - 1)
n = bufsize - 1;
js_memcpy(buf, name, n + 1);
buf += n;
bufsize -= n;
*buf = '\0';
if (details && bufsize > 2) {
switch (kind) {
case JS::TraceKind::Object:
{
JSObject* obj = (JSObject*)thing;
if (obj->is<JSFunction>()) {
JSFunction* fun = &obj->as<JSFunction>();
if (fun->displayAtom()) {
*buf++ = ' ';
bufsize--;
PutEscapedString(buf, bufsize, fun->displayAtom(), 0);
}
} else if (obj->getClass()->flags & JSCLASS_HAS_PRIVATE) {
JS_snprintf(buf, bufsize, " %p", obj->as<NativeObject>().getPrivate());
} else {
JS_snprintf(buf, bufsize, " <no private>");
}
break;
}
case JS::TraceKind::Script:
{
JSScript* script = static_cast<JSScript*>(thing);
JS_snprintf(buf, bufsize, " %s:%" PRIuSIZE, script->filename(), script->lineno());
break;
}
case JS::TraceKind::String:
{
*buf++ = ' ';
bufsize--;
JSString* str = (JSString*)thing;
if (str->isLinear()) {
bool willFit = str->length() + strlen("<length > ") +
CountDecimalDigits(str->length()) < bufsize;
//.........这里部分代码省略.........
示例5: switch
JS_GetTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing,
JSGCTraceKind kind, bool details)
{
const char *name = nullptr; /* silence uninitialized warning */
size_t n;
if (bufsize == 0)
return;
switch (kind) {
case JSTRACE_OBJECT:
{
name = static_cast<JSObject *>(thing)->getClass()->name;
break;
}
case JSTRACE_STRING:
name = ((JSString *)thing)->isDependent()
? "substring"
: "string";
break;
case JSTRACE_SCRIPT:
name = "script";
break;
case JSTRACE_LAZY_SCRIPT:
name = "lazyscript";
break;
case JSTRACE_JITCODE:
name = "jitcode";
break;
case JSTRACE_SHAPE:
name = "shape";
break;
case JSTRACE_BASE_SHAPE:
name = "base_shape";
break;
case JSTRACE_TYPE_OBJECT:
name = "type_object";
break;
}
n = strlen(name);
if (n > bufsize - 1)
n = bufsize - 1;
js_memcpy(buf, name, n + 1);
buf += n;
bufsize -= n;
*buf = '\0';
if (details && bufsize > 2) {
switch (kind) {
case JSTRACE_OBJECT:
{
JSObject *obj = (JSObject *)thing;
if (obj->is<JSFunction>()) {
JSFunction *fun = &obj->as<JSFunction>();
if (fun->displayAtom()) {
*buf++ = ' ';
bufsize--;
PutEscapedString(buf, bufsize, fun->displayAtom(), 0);
}
} else if (obj->getClass()->flags & JSCLASS_HAS_PRIVATE) {
JS_snprintf(buf, bufsize, " %p", obj->getPrivate());
} else {
JS_snprintf(buf, bufsize, " <no private>");
}
break;
}
case JSTRACE_STRING:
{
*buf++ = ' ';
bufsize--;
JSString *str = (JSString *)thing;
if (str->isLinear()) {
bool willFit = str->length() + strlen("<length > ") +
CountDecimalDigits(str->length()) < bufsize;
n = JS_snprintf(buf, bufsize, "<length %d%s> ",
(int)str->length(),
willFit ? "" : " (truncated)");
buf += n;
bufsize -= n;
PutEscapedString(buf, bufsize, &str->asLinear(), 0);
}
else
JS_snprintf(buf, bufsize, "<rope: length %d>", (int)str->length());
break;
}
case JSTRACE_SCRIPT:
{
//.........这里部分代码省略.........
示例6: JS_GetTraceThingInfo
JS_PUBLIC_API void JS_GetTraceThingInfo(char* buf, size_t bufsize,
JSTracer* trc, void* thing,
JS::TraceKind kind, bool details) {
const char* name = nullptr; /* silence uninitialized warning */
size_t n;
if (bufsize == 0) {
return;
}
switch (kind) {
case JS::TraceKind::BaseShape:
name = "base_shape";
break;
case JS::TraceKind::JitCode:
name = "jitcode";
break;
case JS::TraceKind::LazyScript:
name = "lazyscript";
break;
case JS::TraceKind::Null:
name = "null_pointer";
break;
case JS::TraceKind::Object: {
name = static_cast<JSObject*>(thing)->getClass()->name;
break;
}
case JS::TraceKind::ObjectGroup:
name = "object_group";
break;
case JS::TraceKind::RegExpShared:
name = "reg_exp_shared";
break;
case JS::TraceKind::Scope:
name = "scope";
break;
case JS::TraceKind::Script:
name = "script";
break;
case JS::TraceKind::Shape:
name = "shape";
break;
case JS::TraceKind::String:
name = ((JSString*)thing)->isDependent() ? "substring" : "string";
break;
case JS::TraceKind::Symbol:
name = "symbol";
break;
#ifdef ENABLE_BIGINT
case JS::TraceKind::BigInt:
name = "BigInt";
break;
#endif
default:
name = "INVALID";
break;
}
n = strlen(name);
if (n > bufsize - 1) {
n = bufsize - 1;
}
js_memcpy(buf, name, n + 1);
buf += n;
bufsize -= n;
*buf = '\0';
if (details && bufsize > 2) {
switch (kind) {
case JS::TraceKind::Object: {
JSObject* obj = (JSObject*)thing;
if (obj->is<JSFunction>()) {
JSFunction* fun = &obj->as<JSFunction>();
if (fun->displayAtom()) {
*buf++ = ' ';
bufsize--;
PutEscapedString(buf, bufsize, fun->displayAtom(), 0);
}
} else if (obj->getClass()->flags & JSCLASS_HAS_PRIVATE) {
snprintf(buf, bufsize, " %p", obj->as<NativeObject>().getPrivate());
} else {
snprintf(buf, bufsize, " <no private>");
}
break;
}
case JS::TraceKind::Script: {
//.........这里部分代码省略.........