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


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.h

    r21027 r21032  
    2929#include "internal.h"
    3030#include <wtf/ListRefPtr.h>
     31#include <wtf/Vector.h>
    3132
    3233namespace KJS {
     
    10041005  };
    10051006
     1007  class Parameter {
     1008  public:
     1009    Parameter() { }
     1010    Parameter(const Identifier& n) : name(n) { }
     1011    Identifier name;
     1012  };
     1013
    10061014  // inherited by ProgramNode
    10071015  class FunctionBodyNode : public BlockNode {
     
    10111019    int sourceId() { return m_sourceId; }
    10121020    const UString& sourceURL() { return m_sourceURL; }
     1021
     1022    void addParam(const Identifier& ident);
     1023    size_t numParams() const { return m_parameters.size(); }
     1024    Identifier paramName(size_t pos) const { return m_parameters[pos].name; }
     1025    UString paramString() const;
     1026    Vector<Parameter>& parameters() { return m_parameters; }
    10131027  private:
    10141028    UString m_sourceURL;
    10151029    int m_sourceId;
     1030    Vector<Parameter> m_parameters;
    10161031  };
    10171032
     
    10191034  public:
    10201035    FuncExprNode(const Identifier &i, FunctionBodyNode *b, ParameterNode *p = 0)
    1021       : ident(i), param(p ? p->next.release() : 0), body(b) { if (p) { Parser::removeNodeCycle(param.get()); } }
     1036      : ident(i), param(p ? p->next.release() : 0), body(b) { if (p) { Parser::removeNodeCycle(param.get()); } addParams(); }
    10221037    virtual JSValue *evaluate(ExecState*);
    10231038    virtual void streamTo(SourceStream&) const;
    10241039  private:
     1040    void addParams();
    10251041    // Used for streamTo
    10261042    friend class PropertyNode;
     
    10331049  public:
    10341050    FuncDeclNode(const Identifier &i, FunctionBodyNode *b)
    1035       : ident(i), body(b) { }
     1051      : ident(i), body(b) { addParams(); }
    10361052    FuncDeclNode(const Identifier &i, ParameterNode *p, FunctionBodyNode *b)
    1037       : ident(i), param(p->next.release()), body(b) { Parser::removeNodeCycle(param.get()); }
     1053      : ident(i), param(p->next.release()), body(b) { Parser::removeNodeCycle(param.get()); addParams(); }
    10381054    virtual Completion execute(ExecState*);
    10391055    virtual void processFuncDecl(ExecState*);
    10401056    virtual void streamTo(SourceStream&) const;
    10411057  private:
     1058    void addParams();
    10421059    Identifier ident;
    10431060    RefPtr<ParameterNode> param;
Note: See TracChangeset for help on using the changeset viewer.