Changeset 12911 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Feb 20, 2006, 11:54:55 PM (19 years ago)
Author:
mjs
Message:

Reviewed by Geoff and Darin.


Patch from Maks Orlovich, based on work by David Faure, hand-applied and
significantly reworked by me.


  • tests/mozilla/expected.html: Updated for newly fixed test.
  • kjs/array_object.cpp: (ArrayProtoFunc::ArrayProtoFunc):
  • kjs/array_object.h:
  • kjs/bool_object.cpp: (BooleanPrototype::BooleanPrototype): (BooleanProtoFunc::BooleanProtoFunc):
  • kjs/bool_object.h:
  • kjs/date_object.cpp: (KJS::DateProtoFunc::DateProtoFunc): (KJS::DateObjectImp::DateObjectImp): (KJS::DateObjectFuncImp::DateObjectFuncImp):
  • kjs/error_object.cpp: (ErrorPrototype::ErrorPrototype): (ErrorProtoFunc::ErrorProtoFunc):
  • kjs/error_object.h:
  • kjs/function.cpp: (KJS::FunctionImp::FunctionImp): (KJS::GlobalFuncImp::GlobalFuncImp):
  • kjs/function.h:
  • kjs/function_object.cpp: (FunctionPrototype::FunctionPrototype): (FunctionProtoFunc::FunctionProtoFunc): (FunctionProtoFunc::callAsFunction):
  • kjs/function_object.h:
  • kjs/internal.cpp: (KJS::InterpreterImp::initGlobalObject): (KJS::InternalFunctionImp::InternalFunctionImp):
  • kjs/internal.h: (KJS::InternalFunctionImp::functionName):
  • kjs/lookup.h: (KJS::staticFunctionGetter): (KJS::HashEntryFunction::HashEntryFunction): (KJS::HashEntryFunction::implementsCall): (KJS::HashEntryFunction::toBoolean): (KJS::HashEntryFunction::implementsHasInstance): (KJS::HashEntryFunction::hasInstance):
  • kjs/math_object.cpp: (MathFuncImp::MathFuncImp):
  • kjs/math_object.h:
  • kjs/number_object.cpp: (NumberPrototype::NumberPrototype): (NumberProtoFunc::NumberProtoFunc):
  • kjs/number_object.h:
  • kjs/object.cpp: (KJS::JSObject::putDirectFunction): (KJS::Error::create):
  • kjs/object.h:
  • kjs/object_object.cpp: (ObjectPrototype::ObjectPrototype): (ObjectProtoFunc::ObjectProtoFunc):
  • kjs/object_object.h:
  • kjs/regexp_object.cpp: (RegExpPrototype::RegExpPrototype): (RegExpProtoFunc::RegExpProtoFunc):
  • kjs/regexp_object.h:
  • kjs/string_object.cpp: (StringProtoFunc::StringProtoFunc): (StringObjectImp::StringObjectImp): (StringObjectFuncImp::StringObjectFuncImp):
  • kjs/string_object.h:
Location:
trunk/JavaScriptCore/kjs
Files:
26 edited

Legend:

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

    r12890 r12911  
    434434// ------------------------------ ArrayProtoFunc ----------------------------
    435435
    436 ArrayProtoFunc::ArrayProtoFunc(ExecState *exec, int i, int len)
    437   : InternalFunctionImp(
    438     static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
    439     ), id(i)
     436ArrayProtoFunc::ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
     437  : InternalFunctionImp(static_cast<FunctionPrototype*>
     438                        (exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
     439  , id(i)
    440440{
    441441  put(exec,lengthPropertyName,jsNumber(len),DontDelete|ReadOnly|DontEnum);
  • trunk/JavaScriptCore/kjs/array_object.h

    r12317 r12911  
    2323#define _ARRAY_OBJECT_H_
    2424
     25#include "array_instance.h"
    2526#include "internal.h"
    2627#include "function_object.h"
     
    3940  class ArrayProtoFunc : public InternalFunctionImp {
    4041  public:
    41     ArrayProtoFunc(ExecState *exec, int i, int len);
     42    ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier& name);
    4243
    4344    virtual bool implementsCall() const;
  • trunk/JavaScriptCore/kjs/bool_object.cpp

    r12317 r12911  
    4747// ECMA 15.6.4
    4848
    49 BooleanPrototype::BooleanPrototype(ExecState *exec,
    50                                          ObjectPrototype *objectProto,
    51                                          FunctionPrototype *funcProto)
     49BooleanPrototype::BooleanPrototype(ExecState* exec, ObjectPrototype* objectProto, FunctionPrototype* funcProto)
    5250  : BooleanInstance(objectProto)
    5351{
    5452  // The constructor will be added later by InterpreterImp::InterpreterImp()
    5553
    56   putDirect(toStringPropertyName, new BooleanProtoFunc(exec,funcProto,BooleanProtoFunc::ToString,0), DontEnum);
    57   putDirect(valueOfPropertyName,  new BooleanProtoFunc(exec,funcProto,BooleanProtoFunc::ValueOf,0),  DontEnum);
     54  putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
     55  putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ValueOf, 0, valueOfPropertyName),  DontEnum);
    5856  setInternalValue(jsBoolean(false));
    5957}
     
    6260// ------------------------------ BooleanProtoFunc --------------------------
    6361
    64 BooleanProtoFunc::BooleanProtoFunc(ExecState *exec,
    65                                          FunctionPrototype *funcProto, int i, int len)
    66   : InternalFunctionImp(funcProto), id(i)
     62BooleanProtoFunc::BooleanProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     63  : InternalFunctionImp(funcProto, name)
     64  , id(i)
    6765{
    6866  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
  • trunk/JavaScriptCore/kjs/bool_object.h

    r12317 r12911  
    5757  class BooleanProtoFunc : public InternalFunctionImp {
    5858  public:
    59     BooleanProtoFunc(ExecState *exec,
    60                         FunctionPrototype *funcProto, int i, int len);
     59    BooleanProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&);
    6160
    6261    virtual bool implementsCall() const;
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r12624 r12911  
    8484class DateProtoFunc : public InternalFunctionImp {
    8585public:
    86     DateProtoFunc(ExecState *, int i, int len);
     86    DateProtoFunc(ExecState *, int i, int len, const Identifier& date);
    8787
    8888    virtual bool implementsCall() const;
     
    111111class DateObjectFuncImp : public InternalFunctionImp {
    112112public:
    113     DateObjectFuncImp(ExecState *, FunctionPrototype *, int i, int len);
     113    DateObjectFuncImp(ExecState *, FunctionPrototype *, int i, int len, const Identifier& );
    114114
    115115    virtual bool implementsCall() const;
     
    540540// ------------------------------ DateProtoFunc -----------------------------
    541541
    542 DateProtoFunc::DateProtoFunc(ExecState *exec, int i, int len)
    543   : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())),
    544     id(abs(i)), utc(i<0)
     542DateProtoFunc::DateProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
     543  : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
     544  , id(abs(i))
     545  , utc(i < 0)
    545546  // We use a negative ID to denote the "UTC" variant.
    546547{
     
    720721
    721722  static const Identifier parsePropertyName("parse");
    722   putDirect(parsePropertyName, new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::Parse, 1), DontEnum);
     723  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::Parse, 1, parsePropertyName), DontEnum);
    723724  static const Identifier UTCPropertyName("UTC");
    724   putDirect(UTCPropertyName,   new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::UTC,   7),  DontEnum);
     725  putDirectFunction(new DateObjectFuncImp(exec, funcProto, DateObjectFuncImp::UTC, 7, UTCPropertyName), DontEnum);
    725726
    726727  // no. of arguments for constructor
     
    811812// ------------------------------ DateObjectFuncImp ----------------------------
    812813
    813 DateObjectFuncImp::DateObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len)
    814     : InternalFunctionImp(funcProto), id(i)
     814DateObjectFuncImp::DateObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len, const Identifier& name)
     815    : InternalFunctionImp(funcProto, name), id(i)
    815816{
    816817    putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
  • trunk/JavaScriptCore/kjs/error_object.cpp

    r12317 r12911  
    5454  put(exec, namePropertyName,     jsString("Error"), DontEnum);
    5555  put(exec, messagePropertyName,  jsString("Unknown error"), DontEnum);
    56   putDirect(toStringPropertyName, new ErrorProtoFunc(exec,funcProto), DontEnum);
     56  putDirectFunction(new ErrorProtoFunc(exec, funcProto, toStringPropertyName), DontEnum);
    5757}
    5858
    5959// ------------------------------ ErrorProtoFunc ----------------------------
    6060
    61 ErrorProtoFunc::ErrorProtoFunc(ExecState *exec, FunctionPrototype *funcProto)
    62   : InternalFunctionImp(funcProto)
     61ErrorProtoFunc::ErrorProtoFunc(ExecState*, FunctionPrototype* funcProto, const Identifier& name)
     62  : InternalFunctionImp(funcProto, name)
    6363{
    6464  putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
  • trunk/JavaScriptCore/kjs/error_object.h

    r12317 r12911  
    4545  class ErrorProtoFunc : public InternalFunctionImp {
    4646  public:
    47     ErrorProtoFunc(ExecState *exec, FunctionPrototype *funcProto);
     47    ErrorProtoFunc(ExecState*, FunctionPrototype*, const Identifier&);
    4848    virtual bool implementsCall() const;
    4949    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
  • trunk/JavaScriptCore/kjs/function.cpp

    r12523 r12911  
    5757
    5858FunctionImp::FunctionImp(ExecState *exec, const Identifier &n)
    59   : InternalFunctionImp(
    60       static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
    61       ), param(0L), ident(n)
     59  : InternalFunctionImp(static_cast<FunctionPrototype*>
     60                        (exec->lexicalInterpreter()->builtinFunctionPrototype()), n)
     61  , param(0L)
    6262{
    6363}
     
    558558
    559559
    560 GlobalFuncImp::GlobalFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len)
    561   : InternalFunctionImp(funcProto), id(i)
     560GlobalFuncImp::GlobalFuncImp(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     561  : InternalFunctionImp(funcProto, name)
     562  , id(i)
    562563{
    563564  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
  • trunk/JavaScriptCore/kjs/function.h

    r12523 r12911  
    2525#define KJS_FUNCTION_H
    2626
    27 #include "array_instance.h"
    2827#include "internal.h"
    2928#include <kxmlcore/OwnPtr.h>
     
    5756
    5857    virtual Completion execute(ExecState *exec) = 0;
    59     Identifier name() const { return ident; }
    6058
    6159    virtual const ClassInfo *classInfo() const { return &info; }
     
    6361  protected:
    6462    OwnPtr<Parameter> param;
    65     Identifier ident;
    6663
    6764  private:
     
    9996    Identifier& operator[](const Identifier &indexIdentifier);
    10097    bool isMapped(const Identifier &index) const;
    101     void IndexToNameMap::unMap(const Identifier &index);
     98    void unMap(const Identifier &index);
    10299   
    103100  private:
     
    149146  class GlobalFuncImp : public InternalFunctionImp {
    150147  public:
    151     GlobalFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len);
     148    GlobalFuncImp(ExecState*, FunctionPrototype*, int i, int len, const Identifier&);
    152149    virtual bool implementsCall() const;
    153150    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
  • trunk/JavaScriptCore/kjs/function_object.cpp

    r12317 r12911  
    4141FunctionPrototype::FunctionPrototype(ExecState *exec)
    4242{
    43   putDirect(lengthPropertyName,   jsNumber(0),                                                      DontDelete|ReadOnly|DontEnum);
    44   putDirect(toStringPropertyName, new FunctionProtoFunc(exec, this, FunctionProtoFunc::ToString, 0), DontEnum);
     43  putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum);
     44  putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
    4545  static const Identifier applyPropertyName("apply");
    46   putDirect(applyPropertyName,    new FunctionProtoFunc(exec, this, FunctionProtoFunc::Apply,    2), DontEnum);
     46  putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::Apply, 2, applyPropertyName), DontEnum);
    4747  static const Identifier callPropertyName("call");
    48   putDirect(callPropertyName,     new FunctionProtoFunc(exec, this, FunctionProtoFunc::Call,     1), DontEnum);
     48  putDirectFunction(new FunctionProtoFunc(exec, this, FunctionProtoFunc::Call, 1, callPropertyName), DontEnum);
    4949}
    5050
     
    6666// ------------------------------ FunctionProtoFunc -------------------------
    6767
    68 FunctionProtoFunc::FunctionProtoFunc(ExecState *exec,
    69                                          FunctionPrototype *funcProto, int i, int len)
    70   : InternalFunctionImp(funcProto), id(i)
     68FunctionProtoFunc::FunctionProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     69  : InternalFunctionImp(funcProto, name)
     70  , id(i)
    7171{
    7272  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
     
    8484
    8585  switch (id) {
    86   case ToString: {
    87     // ### also make this work for internal functions
     86  case ToString:
    8887    if (!thisObj || !thisObj->inherits(&InternalFunctionImp::info)) {
    8988#ifndef NDEBUG
     
    9392    }
    9493    if (thisObj->inherits(&DeclaredFunctionImp::info)) {
    95        DeclaredFunctionImp *fi = static_cast<DeclaredFunctionImp*>
    96                                  (thisObj);
    97        return jsString("function " + fi->name().ustring() + "(" +
    98          fi->parameterString() + ") " + fi->body->toString());
    99     } else if (thisObj->inherits(&FunctionImp::info) &&
    100         !static_cast<FunctionImp*>(thisObj)->name().isNull()) {
    101       result = jsString("function " + static_cast<FunctionImp*>(thisObj)->name().ustring() + "()");
    102     }
    103     else {
    104       result = jsString("(Internal Function)");
    105     }
     94        DeclaredFunctionImp *fi = static_cast<DeclaredFunctionImp*>(thisObj);
     95        return jsString("function " + fi->functionName().ustring() + "(" +
     96                        fi->parameterString() + ") " + fi->body->toString());
     97     } else if (thisObj->inherits(&InternalFunctionImp::info) &&
     98                !static_cast<InternalFunctionImp*>(thisObj)->functionName().isNull()) {
     99       result = jsString("\nfunction " + static_cast<InternalFunctionImp*>(thisObj)->functionName().ustring() + "() {\n"
     100                       "    [native code]\n}\n");
     101    } else {
     102      result = jsString("[function]");
    106103    }
    107104    break;
  • trunk/JavaScriptCore/kjs/function_object.h

    r12317 r12911  
    5252  class FunctionProtoFunc : public InternalFunctionImp {
    5353  public:
    54     FunctionProtoFunc(ExecState *exec,
    55                         FunctionPrototype *funcProto, int i, int len);
     54    FunctionProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&);
    5655
    5756    virtual bool implementsCall() const;
  • trunk/JavaScriptCore/kjs/internal.cpp

    r12728 r12911  
    455455
    456456  // ECMA 15.3.4.1
    457   funcProto->put(&globExec, "constructor", b_Function, DontEnum);
     457  funcProto->put(&globExec, constructorPropertyName, b_Function, DontEnum);
    458458
    459459  global->put(&globExec, "Object", b_Object, DontEnum);
     
    475475  global->put(&globExec, "URIError",b_uriError, Internal);
    476476
    477   // Set the "constructor" property of all builtin constructors
    478   objProto->put(&globExec, "constructor", b_Object, DontEnum | DontDelete | ReadOnly);
    479   funcProto->put(&globExec, "constructor", b_Function, DontEnum | DontDelete | ReadOnly);
    480   arrayProto->put(&globExec, "constructor", b_Array, DontEnum | DontDelete | ReadOnly);
    481   booleanProto->put(&globExec, "constructor", b_Boolean, DontEnum | DontDelete | ReadOnly);
    482   stringProto->put(&globExec, "constructor", b_String, DontEnum | DontDelete | ReadOnly);
    483   numberProto->put(&globExec, "constructor", b_Number, DontEnum | DontDelete | ReadOnly);
    484   dateProto->put(&globExec, "constructor", b_Date, DontEnum | DontDelete | ReadOnly);
    485   regexpProto->put(&globExec, "constructor", b_RegExp, DontEnum | DontDelete | ReadOnly);
    486   errorProto->put(&globExec, "constructor", b_Error, DontEnum | DontDelete | ReadOnly);
    487   b_evalErrorPrototype->put(&globExec, "constructor", b_evalError, DontEnum | DontDelete | ReadOnly);
    488   b_rangeErrorPrototype->put(&globExec, "constructor", b_rangeError, DontEnum | DontDelete | ReadOnly);
    489   b_referenceErrorPrototype->put(&globExec, "constructor", b_referenceError, DontEnum | DontDelete | ReadOnly);
    490   b_syntaxErrorPrototype->put(&globExec, "constructor", b_syntaxError, DontEnum | DontDelete | ReadOnly);
    491   b_typeErrorPrototype->put(&globExec, "constructor", b_typeError, DontEnum | DontDelete | ReadOnly);
    492   b_uriErrorPrototype->put(&globExec, "constructor", b_uriError, DontEnum | DontDelete | ReadOnly);
     477  // Set the constructorPropertyName property of all builtin constructors
     478  objProto->put(&globExec, constructorPropertyName, b_Object, DontEnum | DontDelete | ReadOnly);
     479  funcProto->put(&globExec, constructorPropertyName, b_Function, DontEnum | DontDelete | ReadOnly);
     480  arrayProto->put(&globExec, constructorPropertyName, b_Array, DontEnum | DontDelete | ReadOnly);
     481  booleanProto->put(&globExec, constructorPropertyName, b_Boolean, DontEnum | DontDelete | ReadOnly);
     482  stringProto->put(&globExec, constructorPropertyName, b_String, DontEnum | DontDelete | ReadOnly);
     483  numberProto->put(&globExec, constructorPropertyName, b_Number, DontEnum | DontDelete | ReadOnly);
     484  dateProto->put(&globExec, constructorPropertyName, b_Date, DontEnum | DontDelete | ReadOnly);
     485  regexpProto->put(&globExec, constructorPropertyName, b_RegExp, DontEnum | DontDelete | ReadOnly);
     486  errorProto->put(&globExec, constructorPropertyName, b_Error, DontEnum | DontDelete | ReadOnly);
     487  b_evalErrorPrototype->put(&globExec, constructorPropertyName, b_evalError, DontEnum | DontDelete | ReadOnly);
     488  b_rangeErrorPrototype->put(&globExec, constructorPropertyName, b_rangeError, DontEnum | DontDelete | ReadOnly);
     489  b_referenceErrorPrototype->put(&globExec, constructorPropertyName, b_referenceError, DontEnum | DontDelete | ReadOnly);
     490  b_syntaxErrorPrototype->put(&globExec, constructorPropertyName, b_syntaxError, DontEnum | DontDelete | ReadOnly);
     491  b_typeErrorPrototype->put(&globExec, constructorPropertyName, b_typeError, DontEnum | DontDelete | ReadOnly);
     492  b_uriErrorPrototype->put(&globExec, constructorPropertyName, b_uriError, DontEnum | DontDelete | ReadOnly);
    493493
    494494  // built-in values
     
    498498
    499499  // built-in functions
    500   global->put(&globExec, "eval",       new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Eval, 1), DontEnum);
    501   global->put(&globExec, "parseInt",   new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseInt, 2), DontEnum);
    502   global->put(&globExec, "parseFloat", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseFloat, 1), DontEnum);
    503   global->put(&globExec, "isNaN",      new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsNaN, 1), DontEnum);
    504   global->put(&globExec, "isFinite",   new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsFinite, 1), DontEnum);
    505   global->put(&globExec, "escape",     new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Escape, 1), DontEnum);
    506   global->put(&globExec, "unescape",   new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::UnEscape, 1), DontEnum);
    507   global->put(&globExec, "decodeURI",  new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURI, 1), DontEnum);
    508   global->put(&globExec, "decodeURIComponent", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURIComponent, 1), DontEnum);
    509   global->put(&globExec, "encodeURI",  new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURI, 1), DontEnum);
    510   global->put(&globExec, "encodeURIComponent", new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURIComponent, 1), DontEnum);
     500  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Eval, 1, "eval"), DontEnum);
     501  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum);
     502  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum);
     503  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum);
     504  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum);
     505  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Escape, 1, "escape"), DontEnum);
     506  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum);
     507  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum);
     508  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum);
     509  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum);
     510  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum);
    511511#ifndef NDEBUG
    512   global->put(&globExec, "kjsprint",   new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::KJSPrint, 1), DontEnum);
     512  global->putDirectFunction(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum);
    513513#endif
    514514
     
    711711}
    712712
    713 InternalFunctionImp::InternalFunctionImp(FunctionPrototype *funcProto)
     713InternalFunctionImp::InternalFunctionImp(FunctionPrototype* funcProto)
    714714  : JSObject(funcProto)
     715{
     716}
     717
     718InternalFunctionImp::InternalFunctionImp(FunctionPrototype* funcProto, const Identifier& name)
     719  : JSObject(funcProto)
     720  , m_name(name)
    715721{
    716722}
  • trunk/JavaScriptCore/kjs/internal.h

    r12728 r12911  
    349349  public:
    350350    InternalFunctionImp();
    351     InternalFunctionImp(FunctionPrototype *funcProto);
     351    InternalFunctionImp(FunctionPrototype*);
     352    InternalFunctionImp(FunctionPrototype*, const Identifier&);
    352353    bool implementsHasInstance() const;
    353354    bool hasInstance(ExecState *exec, JSValue *value);
     
    355356    virtual const ClassInfo *classInfo() const { return &info; }
    356357    static const ClassInfo info;
     358    const Identifier& functionName() const { return m_name; }
     359  private:
     360    Identifier m_name;
    357361  };
    358362
  • trunk/JavaScriptCore/kjs/lookup.h

    r12534 r12911  
    3030
    3131namespace KJS {
     32
     33  class FunctionPrototype;
    3234
    3335  /**
     
    131133
    132134      const HashEntry *entry = slot.staticEntry();
    133       JSValue *val = new FuncImp(exec, entry->value, entry->params);
     135      JSValue *val = new FuncImp(exec, entry->value, entry->params, propertyName);
    134136      thisObj->putDirect(propertyName, val, entry->attr);
    135137      return val;
     
    248250      thisObj->putValueProperty(exec, entry->value, value, attr);
    249251  }
    250  
     252
    251253} // namespace
    252254
     
    341343
    342344#define KJS_IMPLEMENT_PROTOFUNC(ClassFunc) \
    343   class ClassFunc : public DOMFunction { \
     345  class ClassFunc : public InternalFunctionImp { \
    344346  public: \
    345     ClassFunc(ExecState *exec, int i, int len) : id(i) \
     347    ClassFunc(ExecState* exec, int i, int len, const Identifier& name) \
     348      : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) \
     349      , id(i) \
    346350    { \
    347351       put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum); \
  • trunk/JavaScriptCore/kjs/math_object.cpp

    r12317 r12911  
    154154static bool randomSeeded = false;
    155155
    156 MathFuncImp::MathFuncImp(ExecState *exec, int i, int l)
    157   : InternalFunctionImp(
    158     static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
    159     ), id(i)
     156MathFuncImp::MathFuncImp(ExecState* exec, int i, int l, const Identifier& name)
     157  : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
     158  , id(i)
    160159{
    161160  putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);
  • trunk/JavaScriptCore/kjs/math_object.h

    r12317 r12911  
    4343  class MathFuncImp : public InternalFunctionImp {
    4444  public:
    45     MathFuncImp(ExecState *exec, int i, int l);
     45    MathFuncImp(ExecState *exec, int i, int l, const Identifier&);
    4646    virtual bool implementsCall() const;
    4747    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
  • trunk/JavaScriptCore/kjs/number_object.cpp

    r12435 r12911  
    6161  // The constructor will be added later, after NumberObjectImp has been constructed
    6262
    63   putDirect(toStringPropertyName,       new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ToString,       1), DontEnum);
    64   putDirect(toLocaleStringPropertyName, new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ToLocaleString, 0), DontEnum);
    65   putDirect(valueOfPropertyName,        new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ValueOf,        0), DontEnum);
    66   putDirect(toFixedPropertyName,        new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ToFixed,        1), DontEnum);
    67   putDirect(toExponentialPropertyName,  new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ToExponential,  1), DontEnum);
    68   putDirect(toPrecisionPropertyName,    new NumberProtoFunc(exec,funcProto,NumberProtoFunc::ToPrecision,    1), DontEnum);
     63  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToString,       1, toStringPropertyName), DontEnum);
     64  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToLocaleString, 0, toLocaleStringPropertyName), DontEnum);
     65  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ValueOf,        0, valueOfPropertyName), DontEnum);
     66  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToFixed,        1, toFixedPropertyName), DontEnum);
     67  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToExponential,  1, toExponentialPropertyName), DontEnum);
     68  putDirectFunction(new NumberProtoFunc(exec, funcProto, NumberProtoFunc::ToPrecision,    1, toPrecisionPropertyName), DontEnum);
    6969}
    7070
     
    7272// ------------------------------ NumberProtoFunc ---------------------------
    7373
    74 NumberProtoFunc::NumberProtoFunc(ExecState *exec,
    75                                        FunctionPrototype *funcProto, int i, int len)
    76   : InternalFunctionImp(funcProto), id(i)
     74NumberProtoFunc::NumberProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     75   : InternalFunctionImp(funcProto, name)
     76   , id(i)
    7777{
    7878  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
  • trunk/JavaScriptCore/kjs/number_object.h

    r12317 r12911  
    5757  class NumberProtoFunc : public InternalFunctionImp {
    5858  public:
    59     NumberProtoFunc(ExecState *exec, FunctionPrototype *funcProto,
    60                        int i, int len);
     59    NumberProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&);
    6160
    6261    virtual bool implementsCall() const;
  • trunk/JavaScriptCore/kjs/object.cpp

    r12728 r12911  
    542542}
    543543
     544void JSObject::putDirectFunction(InternalFunctionImp* func, int attr)
     545{
     546    putDirect(func->functionName(), func, attr);
     547}
     548
    544549void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue **location)
    545550{
     
    613618/*
    614619#ifndef NDEBUG
    615   const char *msg = err->get("message")->toString().value().ascii();
     620  const char *msg = err->get(messagePropertyName)->toString().value().ascii();
    616621  if (l >= 0)
    617622      fprintf(stderr, "KJS: %s at line %d. %s\n", estr, l, msg);
  • trunk/JavaScriptCore/kjs/object.h

    r12728 r12911  
    5050  class HashEntry;
    5151  class ListImp;
     52  class InternalFunctionImp;
    5253
    5354  // ECMA 262-3 8.6.1
     
    510511    void putDirect(const Identifier &propertyName, int value, int attr = 0);
    511512
     513    // convenience to add a function property under the function's own built-in name
     514    void putDirectFunction(InternalFunctionImp*, int attr = 0);
     515
    512516    void fillGetterPropertySlot(PropertySlot& slot, JSValue **location);
    513517
  • trunk/JavaScriptCore/kjs/object_object.cpp

    r12317 r12911  
    3535// ------------------------------ ObjectPrototype --------------------------------
    3636
    37 ObjectPrototype::ObjectPrototype(ExecState *exec,
    38                                        FunctionPrototype *funcProto)
     37ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* funcProto)
    3938  : JSObject() // [[Prototype]] is null
    4039{
    41     putDirect(toStringPropertyName, new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToString,               0), DontEnum);
    42     putDirect(toLocaleStringPropertyName, new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToLocaleString,   0), DontEnum);
    43     putDirect(valueOfPropertyName, new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ValueOf,                 0), DontEnum);
    44     putDirect("hasOwnProperty", new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::HasOwnProperty,             1), DontEnum);
    45     putDirect("propertyIsEnumerable", new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::PropertyIsEnumerable, 1), DontEnum);
    46     putDirect("isPrototypeOf", new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::IsPrototypeOf,               1), DontEnum);
     40    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
     41    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ToLocaleString, 0, toLocaleStringPropertyName), DontEnum);
     42    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::ValueOf, 0, valueOfPropertyName), DontEnum);
     43    static Identifier hasOwnPropertyPropertyName("hasOwnProperty");
     44    static Identifier propertyIsEnumerablePropertyName("propertyIsEnumerable");
     45    static Identifier isPrototypeOfPropertyName("isPrototypeOf");
     46    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::HasOwnProperty, 1, hasOwnPropertyPropertyName), DontEnum);
     47    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::PropertyIsEnumerable, 1, propertyIsEnumerablePropertyName), DontEnum);
     48    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::IsPrototypeOf, 1, isPrototypeOfPropertyName), DontEnum);
     49
    4750    // Mozilla extensions
    48     putDirect("__defineGetter__", new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::DefineGetter,             2), DontEnum);
    49     putDirect("__defineSetter__", new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::DefineSetter,             2), DontEnum);
    50     putDirect("__lookupGetter__", new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::LookupGetter,             1), DontEnum);
    51     putDirect("__lookupSetter__", new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::LookupSetter,             1), DontEnum);
     51    static const Identifier defineGetterPropertyName("__defineGetter__");
     52    static const Identifier defineSetterPropertyName("__defineSetter__");
     53    static const Identifier lookupGetterPropertyName("__lookupGetter__");
     54    static const Identifier lookupSetterPropertyName("__lookupSetter__");
     55    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::DefineGetter, 2, defineGetterPropertyName), DontEnum);
     56    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::DefineSetter, 2, defineSetterPropertyName), DontEnum);
     57    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::LookupGetter, 1, lookupGetterPropertyName), DontEnum);
     58    putDirectFunction(new ObjectProtoFunc(exec, funcProto, ObjectProtoFunc::LookupSetter, 1, lookupSetterPropertyName), DontEnum);
    5259}
    5360
     
    5562// ------------------------------ ObjectProtoFunc --------------------------------
    5663
    57 ObjectProtoFunc::ObjectProtoFunc(ExecState *exec,
    58                                        FunctionPrototype *funcProto,
    59                                        int i, int len)
    60   : InternalFunctionImp(funcProto), id(i)
     64ObjectProtoFunc::ObjectProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     65  : InternalFunctionImp(funcProto, name)
     66  , id(i)
    6167{
    6268  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
  • trunk/JavaScriptCore/kjs/object_object.h

    r12317 r12911  
    4848  class ObjectProtoFunc : public InternalFunctionImp {
    4949  public:
    50     ObjectProtoFunc(ExecState *exec, FunctionPrototype *funcProto, int i, int len);
     50    ObjectProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier&);
    5151
    5252    virtual bool implementsCall() const;
  • trunk/JavaScriptCore/kjs/regexp_object.cpp

    r12523 r12911  
    5555
    5656  static const Identifier execPropertyName("exec");
    57   putDirect(execPropertyName,     new RegExpProtoFunc(exec,funcProto,RegExpProtoFunc::Exec,     0), DontEnum);
    5857  static const Identifier testPropertyName("test");
    59   putDirect(testPropertyName,     new RegExpProtoFunc(exec,funcProto,RegExpProtoFunc::Test,     0), DontEnum);
    60   putDirect(toStringPropertyName, new RegExpProtoFunc(exec,funcProto,RegExpProtoFunc::ToString, 0), DontEnum);
     58  putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::Exec, 0, execPropertyName), DontEnum);
     59  putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::Test, 0, testPropertyName), DontEnum);
     60  putDirectFunction(new RegExpProtoFunc(exec, funcProto, RegExpProtoFunc::ToString, 0, toStringPropertyName), DontEnum);
    6161}
    6262
    6363// ------------------------------ RegExpProtoFunc ---------------------------
    6464
    65 RegExpProtoFunc::RegExpProtoFunc(ExecState *exec,
    66                                        FunctionPrototype *funcProto, int i, int len)
    67   : InternalFunctionImp(funcProto), id(i)
     65RegExpProtoFunc::RegExpProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name)
     66   : InternalFunctionImp(funcProto, name), id(i)
    6867{
    6968  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
  • trunk/JavaScriptCore/kjs/regexp_object.h

    r12523 r12911  
    4141  class RegExpProtoFunc : public InternalFunctionImp {
    4242  public:
    43     RegExpProtoFunc(ExecState *exec,
    44                        FunctionPrototype *funcProto, int i, int len);
     43    RegExpProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&);
    4544
    4645    virtual bool implementsCall() const;
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r12728 r12911  
    168168// ------------------------------ StringProtoFunc ---------------------------
    169169
    170 StringProtoFunc::StringProtoFunc(ExecState *exec, int i, int len)
    171   : InternalFunctionImp(
    172     static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())
    173     ), id(i)
     170StringProtoFunc::StringProtoFunc(ExecState *exec, int i, int len, const Identifier& name)
     171  : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
     172  , id(i)
    174173{
    175174  putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
     
    700699  putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly);
    701700
    702   putDirect(fromCharCodePropertyName, new StringObjectFuncImp(exec, funcProto), DontEnum);
     701  putDirectFunction(new StringObjectFuncImp(exec, funcProto, fromCharCodePropertyName), DontEnum);
    703702
    704703  // no. of arguments for constructor
     
    740739
    741740// ECMA 15.5.3.2 fromCharCode()
    742 StringObjectFuncImp::StringObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto)
    743   : InternalFunctionImp(funcProto)
     741StringObjectFuncImp::StringObjectFuncImp(ExecState*, FunctionPrototype* funcProto, const Identifier& name)
     742  : InternalFunctionImp(funcProto, name)
    744743{
    745744  putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum);
  • trunk/JavaScriptCore/kjs/string_object.h

    r12317 r12911  
    6868  class StringProtoFunc : public InternalFunctionImp {
    6969  public:
    70     StringProtoFunc(ExecState *exec, int i, int len);
     70    StringProtoFunc(ExecState *exec, int i, int len, const Identifier&);
    7171
    7272    virtual bool implementsCall() const;
     
    111111  class StringObjectFuncImp : public InternalFunctionImp {
    112112  public:
    113     StringObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto);
     113    StringObjectFuncImp(ExecState*, FunctionPrototype*, const Identifier&);
    114114    virtual bool implementsCall() const;
    115115    virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
Note: See TracChangeset for help on using the changeset viewer.