Changeset 26715 in webkit for trunk/JavaScriptCore/kjs/function.h


Ignore:
Timestamp:
Oct 17, 2007, 2:01:27 PM (18 years ago)
Author:
ggaren
Message:

Reviewed by Darin Adler.


Merged DeclaredFunctionImp into FunctionImp (the base class) because
the distinction between the two was unused.


Removed codeType() from FunctionImp because FunctionImp and its
subclasses all returned FunctionCode, so it was unused, practically
speaking.


Removed a different codeType() from GlobalFuncImp because it was unused.
(Perhaps it was vestigial from a time when GlobalFuncImp used to
inherit from FunctionImp.)

  • bindings/runtime_method.cpp:
  • bindings/runtime_method.h:
  • kjs/function.cpp: (KJS::): (KJS::FunctionImp::FunctionImp): (KJS::FunctionImp::callAsFunction): (KJS::FunctionImp::construct): (KJS::FunctionImp::execute): (KJS::FunctionImp::processVarDecls):
  • kjs/function.h: (KJS::FunctionImp::implementsConstruct): (KJS::FunctionImp::scope):
  • kjs/function_object.cpp: (FunctionProtoFunc::callAsFunction): (FunctionObjectImp::construct):
  • kjs/nodes.cpp: (FuncDeclNode::processFuncDecl): (FuncExprNode::evaluate):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/function.h

    r26620 r26715  
    7373  };
    7474
    75   /**
    76    * @short Implementation class for internal Functions.
    77    */
    7875  class FunctionImp : public InternalFunctionImp {
    7976    friend class ActivationImp;
    8077  public:
    81     FunctionImp(ExecState*, const Identifier& n, FunctionBodyNode* b);
    82     virtual ~FunctionImp();
     78    FunctionImp(ExecState*, const Identifier& name, FunctionBodyNode*, const ScopeChain&);
    8379
    8480    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     
    8682    virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    8783
     84    virtual bool implementsConstruct() const { return true; }
     85    virtual JSObject* construct(ExecState*, const List& args);
     86   
    8887    virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List& args);
     88    Completion execute(ExecState*);
    8989
    9090    // Note: unlike body->paramName, this returns Identifier::null for parameters
    9191    // that will never get set, due to later param having the same name
    9292    Identifier getParameterName(int index);
    93     virtual CodeType codeType() const = 0;
    94 
    95     virtual Completion execute(ExecState*) = 0;
    9693
    9794    virtual const ClassInfo* classInfo() const { return &info; }
     
    10097    RefPtr<FunctionBodyNode> body;
    10198
    102     /**
    103      * Returns the scope of this object. This is used when execution declared
    104      * functions - the execution context for the function is initialized with
    105      * extra object in it's scope. An example of this is functions declared
    106      * inside other functions:
    107      *
    108      * \code
    109      * function f() {
    110      *
    111      *   function b() {
    112      *     return prototype;
    113      *   }
    114      *
    115      *   var x = 4;
    116      *   // do some stuff
    117      * }
    118      * f.prototype = new String();
    119      * \endcode
    120      *
    121      * When the function f.b is executed, its scope will include properties of
    122      * f. So in the example above the return value of f.b() would be the new
    123      * String object that was assigned to f.prototype.
    124      *
    125      * @param exec The current execution state
    126      * @return The function's scope
    127      */
     99    void setScope(const ScopeChain& s) { _scope = s; }
    128100    const ScopeChain& scope() const { return _scope; }
    129     void setScope(const ScopeChain& s) { _scope = s; }
    130101
    131102    virtual void mark();
     
    139110
    140111    void passInParameters(ExecState*, const List&);
    141     virtual void processVarDecls(ExecState*);
    142   };
    143 
    144   class DeclaredFunctionImp : public FunctionImp {
    145   public:
    146     DeclaredFunctionImp(ExecState*, const Identifier& n,
    147                         FunctionBodyNode* b, const ScopeChain& sc);
    148 
    149     bool implementsConstruct() const;
    150     JSObject* construct(ExecState*, const List& args);
    151 
    152     virtual Completion execute(ExecState*);
    153     CodeType codeType() const { return FunctionCode; }
    154 
    155     virtual const ClassInfo* classInfo() const { return &info; }
    156     static const ClassInfo info;
    157 
    158   private:
    159     virtual void processVarDecls(ExecState*);
     112    void processVarDecls(ExecState*);
    160113  };
    161114
     
    223176    GlobalFuncImp(ExecState*, FunctionPrototype*, int i, int len, const Identifier&);
    224177    virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List& args);
    225     virtual CodeType codeType() const;
    226178    enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape,
    227179           DecodeURI, DecodeURIComponent, EncodeURI, EncodeURIComponent
Note: See TracChangeset for help on using the changeset viewer.