Changeset 26621 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


Ignore:
Timestamp:
Oct 15, 2007, 1:44:09 PM (18 years ago)
Author:
ggaren
Message:

JavaScriptCore:

Reviewed by Darin Adler.


Removed surprising self-named "hack" that made nested functions
available as named properties of their containing functions, and placed
containing function objects in the scope chains of nested functions.


There were a few reasons to remove this "hack:"

  1. It contradicted FF, IE, and the ECMA spec.
  1. It incurred a performance penalty, since merely parsing a function required parsing its body for nested functions (and so on).
  1. SVN history contains no explanation for why it was added. It was just legacy code in a large merge a long, long time ago.

[ Patch broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ]

  • kjs/nodes.cpp: (FuncDeclNode::processFuncDecl):

LayoutTests:

Reviewed by Darin Adler.


Removed surprising self-named "hack" that made nested functions
available as named properties of their containing functions, and placed
containing function objects in the scope chains of nested functions.


[ Patch broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ]

Changed this test to reflect correct behavior:

  • fast/js/kde/function-expected.txt:
  • fast/js/kde/resources/function.js: (Also removed tab characters.)

Added this test to flesh out the behavior more:

  • fast/js/nested-function-scope-expected.txt: Added.
  • fast/js/nested-function-scope.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r26620 r26621  
    24872487  // ECMA 10.2.2
    24882488  context->variableObject()->put(exec, ident, func, Internal | (context->codeType() == EvalCode ? 0 : DontDelete));
    2489 
    2490   if (body) {
    2491     // hack the scope so that the function gets put as a property of func, and it's scope
    2492     // contains the func as well as our current scope
    2493     JSObject *oldVar = context->variableObject();
    2494     context->setVariableObject(func);
    2495     context->pushScope(func);
    2496     body->processFuncDecl(exec);
    2497     context->popScope();
    2498     context->setVariableObject(oldVar);
    2499   }
    25002489}
    25012490
Note: See TracChangeset for help on using the changeset viewer.