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


Ignore:
Timestamp:
Mar 21, 2002, 4:31:57 PM (23 years ago)
Author:
mjs
Message:

Merged changes from LABYRINTH_KDE_3_MERGE branch.

File:
1 edited

Legend:

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

    r6 r798  
     1// -*- c-basic-offset: 2 -*-
    12/*
    23 *  This file is part of the KDE libraries
     
    1718 *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    1819 *  Boston, MA 02111-1307, USA.
     20 *
     21 *  $Id$
    1922 */
    2023
     
    2225#define _KJS_FUNCTION_H_
    2326
    24 #include <assert.h>
    25 
    26 #include "object.h"
    27 #include "types.h"
     27#include "internal.h"
    2828
    2929namespace KJS {
    3030
    31   enum CodeType { GlobalCode,
    32                   EvalCode,
    33                   FunctionCode,
    34                   AnonymousCode,
    35                   HostCode };
    36 
    37   enum FunctionAttribute { ImplicitNone, ImplicitThis, ImplicitParents };
    38 
    39   class Function;
    4031  class Parameter;
    4132
    4233  /**
    43    * @short Implementation class for Functions.
     34   * @short Implementation class for internal Functions.
    4435   */
    45   class FunctionImp : public ObjectImp {
     36  class FunctionImp : public InternalFunctionImp {
    4637    friend class Function;
     38    friend class ActivationImp;
    4739  public:
    48     FunctionImp();
    49     FunctionImp(const UString &n);
     40    FunctionImp(ExecState *exec, const UString &n = UString::null);
    5041    virtual ~FunctionImp();
    51     virtual const TypeInfo* typeInfo() const { return &info; }
    52     static const TypeInfo info;
    53     virtual Completion execute(const List &) = 0;
    54     bool hasAttribute(FunctionAttribute a) const { return (attr & a) != 0; }
     42
     43    virtual void mark();
     44
     45    virtual bool implementsCall() const;
     46    virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     47
     48    void addParameter(const UString &n);
    5549    virtual CodeType codeType() const = 0;
    56     KJSO thisValue() const;
    57     void addParameter(const UString &n);
    58     void setLength(int l);
    59     KJSO executeCall(Imp *thisV, const List *args);
    60     KJSO executeCall(Imp *thisV, const List *args, const List *extraScope);
    61     UString name() const;
     50
     51    virtual Completion execute(ExecState *exec) = 0;
     52    UString name() const { return ident; }
     53
     54    virtual const ClassInfo *classInfo() const { return &info; }
     55    static const ClassInfo info;
    6256  protected:
     57    Parameter *param;
    6358    UString ident;
    64     FunctionAttribute attr;
    65     Parameter *param;
     59
    6660  private:
    67     void processParameters(const List *);
     61    void processParameters(ExecState *exec, const List &);
     62    virtual void processVarDecls(ExecState *exec);
     63
     64    void pushArgs(ExecState *exec, const Object &args);
     65    void popArgs(ExecState *exec);
     66    ListImp *argStack;
    6867  };
    6968
    70   /**
    71    * @short Abstract base class for internal functions.
    72    */
    73   class InternalFunctionImp : public FunctionImp {
     69  class DeclaredFunctionImp : public FunctionImp {
    7470  public:
    75     InternalFunctionImp();
    76     InternalFunctionImp(int l);
    77     InternalFunctionImp(const UString &n);
    78     virtual ~InternalFunctionImp() { }
    79     virtual String toString() const;
    80     virtual KJSO toPrimitive(Type) const { return toString(); }
    81     virtual const TypeInfo* typeInfo() const { return &info; }
    82     static const TypeInfo info;
    83     virtual Completion execute(const List &);
    84     virtual CodeType codeType() const { return HostCode; }
     71    DeclaredFunctionImp(ExecState *exec, const UString &n,
     72                        FunctionBodyNode *b, const List &sc);
     73    ~DeclaredFunctionImp();
     74
     75    bool implementsConstruct() const;
     76    Object construct(ExecState *exec, const List &args);
     77
     78    virtual Completion execute(ExecState *exec);
     79    CodeType codeType() const { return FunctionCode; }
     80    FunctionBodyNode *body;
     81
     82    virtual const ClassInfo *classInfo() const { return &info; }
     83    static const ClassInfo info;
     84  private:
     85    virtual void processVarDecls(ExecState *exec);
    8586  };
    8687
    87   /**
    88    * @short Base class for Function objects.
    89    */
    90   class Function : public KJSO {
     88
     89
     90
     91  class ArgumentsImp : public ObjectImp {
    9192  public:
    92     Function(Imp *);
    93     virtual ~Function() { }
    94     Completion execute(const List &);
    95     bool hasAttribute(FunctionAttribute a) const;
    96     CodeType codeType() const { return HostCode; }
    97     KJSO thisValue() const;
    98   };
    99  
    100   /**
    101    * @short Implementation class for Constructors.
    102    */
    103   class ConstructorImp : public InternalFunctionImp {
    104   public:
    105     ConstructorImp();
    106     ConstructorImp(const UString &n);   /* TODO: add length */
    107     ConstructorImp(const KJSO &, int);
    108     ConstructorImp(const UString &n, const KJSO &p, int len);
    109     virtual ~ConstructorImp();
    110     virtual const TypeInfo* typeInfo() const { return &info; }
    111     static const TypeInfo info;
    112     virtual Completion execute(const List &);
    113     virtual Object construct(const List &) = 0;
     93    ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args);
     94
     95    virtual const ClassInfo *classInfo() const { return &info; }
     96    static const ClassInfo info;
    11497  };
    11598
    116   /**
    117     * @short Constructor object for use with the 'new' operator
    118     */
    119   class Constructor : public Function {
     99  class ActivationImp : public ObjectImp {
    120100  public:
    121     Constructor(Imp *);
    122     virtual ~Constructor();
    123     //    Constructor(const Object& proto, int len);
    124     /**
    125      * @return @ref ConstructorType
    126      */
    127     Completion execute(const List &);
    128     Object construct(const List &args);
    129     static Constructor dynamicCast(const KJSO &obj);
     101    ActivationImp(ExecState *exec, FunctionImp *f, const List &args);
     102    ~ActivationImp();
     103
     104    Object argumentsObject() { return Object(arguments); }
     105
     106    virtual const ClassInfo *classInfo() const { return &info; }
     107    static const ClassInfo info;
     108  private:
     109    ObjectImp* arguments;
    130110  };
     111
     112  class GlobalFuncImp : public InternalFunctionImp {
     113  public:
     114    GlobalFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, int i, int len);
     115    virtual bool implementsCall() const;
     116    virtual Value call(ExecState *exec, Object &thisObj, const List &args);
     117    virtual CodeType codeType() const;
     118    enum { Eval, ParseInt, ParseFloat, IsNaN, IsFinite, Escape, UnEscape };
     119  private:
     120    int id;
     121  };
     122
     123
    131124
    132125}; // namespace
Note: See TracChangeset for help on using the changeset viewer.