Bug 788586: Don't drop "prototype" from inferred display names. r=acrichto

This commit is contained in:
Jim Blandy 2012-09-06 03:12:18 -07:00
parent 7da534684f
commit 89f582f5b1
2 changed files with 6 additions and 21 deletions

View File

@ -32,15 +32,6 @@ class NameResolver
return pn && pn->isKind(PNK_LP);
}
/*
* Some special atoms like 'prototype' and '__proto__' aren't useful to show
* up in function names.
*/
bool special(JSAtom *atom) {
return cx->runtime->atomState.protoAtom == atom ||
cx->runtime->atomState.classPrototypeAtom == atom;
}
/*
* Walk over the given ParseNode, converting it to a stringified name that
* respresents where the function is being assigned to.
@ -48,9 +39,9 @@ class NameResolver
bool nameExpression(ParseNode *n) {
switch (n->getKind()) {
case PNK_DOT:
return nameExpression(n->expr()) &&
(special(n->pn_atom) ||
(buf->append(".") && buf->append(n->pn_atom)));
return (nameExpression(n->expr()) &&
buf->append(".") &&
buf->append(n->pn_atom));
case PNK_NAME:
return buf->append(n->pn_atom);
@ -202,14 +193,8 @@ class NameResolver
ParseNode *node = toName[pos];
if (node->isKind(PNK_COLON)) {
if (node->pn_left->isKind(PNK_NAME)) {
/* special atoms are skipped, but others are dot-appended */
if (!special(node->pn_left->pn_atom)) {
if (!buf.append(".") || !buf.append(node->pn_left->pn_atom))
return NULL;
}
} else if (node->pn_left->isKind(PNK_STRING)) {
/* If a string is explicitly specified, don't see if its special */
if (node->pn_left->isKind(PNK_NAME) || node->pn_left->isKind(PNK_STRING)) {
/* Atoms are dot-appended. */
if (!buf.append(".") || !buf.append(node->pn_left->pn_atom))
return NULL;
}

View File

@ -69,7 +69,7 @@ function Fuz(){};
Fuz.prototype = {
add: function() {}
}
assertName(Fuz.prototype.add, 'Fuz.add');
assertName(Fuz.prototype.add, 'Fuz.prototype.add');
var x = 1;
x = function(){};