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


Ignore:
Timestamp:
Apr 23, 2007, 3:28:10 AM (18 years ago)
Author:
mjs
Message:

Reviewed by Darin.


  • shrink FunctionImp / DeclaredFunctionImp by 4 bytes, by moving parameter list to function body


I reconciled this with a similar change in KDE kjs by Maks Orlovich <[email protected]>.

  • kjs/function.cpp: (KJS::FunctionImp::callAsFunction): (KJS::FunctionImp::passInParameters): (KJS::FunctionImp::lengthGetter): (KJS::FunctionImp::getParameterName):
  • kjs/function.h:
  • kjs/function_object.cpp: (FunctionProtoFunc::callAsFunction): (FunctionObjectImp::construct):
  • kjs/nodes.cpp: (FunctionBodyNode::addParam): (FunctionBodyNode::paramString): (FuncDeclNode::addParams): (FuncDeclNode::processFuncDecl): (FuncExprNode::addParams): (FuncExprNode::evaluate):
  • kjs/nodes.h: (KJS::Parameter::Parameter): (KJS::FunctionBodyNode::numParams): (KJS::FunctionBodyNode::paramName): (KJS::FunctionBodyNode::parameters): (KJS::FuncExprNode::FuncExprNode): (KJS::FuncDeclNode::FuncDeclNode):
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Disable 64-bit warnings because they handle size_t badly.
File:
1 edited

Legend:

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

    r21027 r21032  
    23932393}
    23942394
     2395void FunctionBodyNode::addParam(const Identifier& ident)
     2396{
     2397  m_parameters.append(Parameter(ident));
     2398}
     2399
     2400UString FunctionBodyNode::paramString() const
     2401{
     2402  UString s("");
     2403  size_t count = numParams();
     2404  for (size_t pos = 0; pos < count; ++pos) {
     2405    if (!s.isEmpty())
     2406        s += ", ";
     2407    s += paramName(pos).ustring();
     2408  }
     2409
     2410  return s;
     2411}
     2412
     2413
    23952414// ------------------------------ FuncDeclNode ---------------------------------
     2415
     2416void FuncDeclNode::addParams()
     2417{
     2418  for (ParameterNode *p = param.get(); p != 0L; p = p->nextParam())
     2419    body->addParam(p->ident());
     2420}
    23962421
    23972422// ECMA 13
     
    24072432  func->put(exec, exec->propertyNames().prototype, proto, Internal|DontDelete);
    24082433
    2409   int plen = 0;
    2410   for(ParameterNode *p = param.get(); p != 0L; p = p->nextParam(), plen++)
    2411     func->addParameter(p->ident());
    2412 
    2413   func->put(exec, exec->propertyNames().length, jsNumber(plen), ReadOnly|DontDelete|DontEnum);
     2434  func->put(exec, exec->propertyNames().length, jsNumber(body->numParams()), ReadOnly|DontDelete|DontEnum);
    24142435
    24152436  // ECMA 10.2.2
     
    24362457
    24372458// ECMA 13
     2459void FuncExprNode::addParams()
     2460{
     2461  for (ParameterNode *p = param.get(); p != 0L; p = p->nextParam())
     2462    body->addParam(p->ident());
     2463}
     2464
    24382465JSValue *FuncExprNode::evaluate(ExecState *exec)
    24392466{
     
    24542481  proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum);
    24552482  func->put(exec, exec->propertyNames().prototype, proto, Internal | DontDelete);
    2456 
    2457   int plen = 0;
    2458   for(ParameterNode *p = param.get(); p != 0L; p = p->nextParam(), plen++)
    2459     func->addParameter(p->ident());
    24602483
    24612484  if (named) {
Note: See TracChangeset for help on using the changeset viewer.