Changeset 12911 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Feb 20, 2006, 11:54:55 PM (19 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_object.cpp
r12890 r12911 434 434 // ------------------------------ ArrayProtoFunc ---------------------------- 435 435 436 ArrayProtoFunc::ArrayProtoFunc(ExecState *exec, int i, int len )437 : InternalFunctionImp( 438 static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())439 ), id(i)436 ArrayProtoFunc::ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier& name) 437 : InternalFunctionImp(static_cast<FunctionPrototype*> 438 (exec->lexicalInterpreter()->builtinFunctionPrototype()), name) 439 , id(i) 440 440 { 441 441 put(exec,lengthPropertyName,jsNumber(len),DontDelete|ReadOnly|DontEnum); -
trunk/JavaScriptCore/kjs/array_object.h
r12317 r12911 23 23 #define _ARRAY_OBJECT_H_ 24 24 25 #include "array_instance.h" 25 26 #include "internal.h" 26 27 #include "function_object.h" … … 39 40 class ArrayProtoFunc : public InternalFunctionImp { 40 41 public: 41 ArrayProtoFunc(ExecState *exec, int i, int len );42 ArrayProtoFunc(ExecState *exec, int i, int len, const Identifier& name); 42 43 43 44 virtual bool implementsCall() const; -
trunk/JavaScriptCore/kjs/bool_object.cpp
r12317 r12911 47 47 // ECMA 15.6.4 48 48 49 BooleanPrototype::BooleanPrototype(ExecState *exec, 50 ObjectPrototype *objectProto, 51 FunctionPrototype *funcProto) 49 BooleanPrototype::BooleanPrototype(ExecState* exec, ObjectPrototype* objectProto, FunctionPrototype* funcProto) 52 50 : BooleanInstance(objectProto) 53 51 { 54 52 // The constructor will be added later by InterpreterImp::InterpreterImp() 55 53 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); 58 56 setInternalValue(jsBoolean(false)); 59 57 } … … 62 60 // ------------------------------ BooleanProtoFunc -------------------------- 63 61 64 BooleanProtoFunc::BooleanProtoFunc(ExecState *exec,65 FunctionPrototype *funcProto, int i, int len)66 : InternalFunctionImp(funcProto), id(i)62 BooleanProtoFunc::BooleanProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 63 : InternalFunctionImp(funcProto, name) 64 , id(i) 67 65 { 68 66 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); -
trunk/JavaScriptCore/kjs/bool_object.h
r12317 r12911 57 57 class BooleanProtoFunc : public InternalFunctionImp { 58 58 public: 59 BooleanProtoFunc(ExecState *exec, 60 FunctionPrototype *funcProto, int i, int len); 59 BooleanProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&); 61 60 62 61 virtual bool implementsCall() const; -
trunk/JavaScriptCore/kjs/date_object.cpp
r12624 r12911 84 84 class DateProtoFunc : public InternalFunctionImp { 85 85 public: 86 DateProtoFunc(ExecState *, int i, int len );86 DateProtoFunc(ExecState *, int i, int len, const Identifier& date); 87 87 88 88 virtual bool implementsCall() const; … … 111 111 class DateObjectFuncImp : public InternalFunctionImp { 112 112 public: 113 DateObjectFuncImp(ExecState *, FunctionPrototype *, int i, int len );113 DateObjectFuncImp(ExecState *, FunctionPrototype *, int i, int len, const Identifier& ); 114 114 115 115 virtual bool implementsCall() const; … … 540 540 // ------------------------------ DateProtoFunc ----------------------------- 541 541 542 DateProtoFunc::DateProtoFunc(ExecState *exec, int i, int len) 543 : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype())), 544 id(abs(i)), utc(i<0) 542 DateProtoFunc::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) 545 546 // We use a negative ID to denote the "UTC" variant. 546 547 { … … 720 721 721 722 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); 723 724 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); 725 726 726 727 // no. of arguments for constructor … … 811 812 // ------------------------------ DateObjectFuncImp ---------------------------- 812 813 813 DateObjectFuncImp::DateObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len )814 : InternalFunctionImp(funcProto ), id(i)814 DateObjectFuncImp::DateObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len, const Identifier& name) 815 : InternalFunctionImp(funcProto, name), id(i) 815 816 { 816 817 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); -
trunk/JavaScriptCore/kjs/error_object.cpp
r12317 r12911 54 54 put(exec, namePropertyName, jsString("Error"), DontEnum); 55 55 put(exec, messagePropertyName, jsString("Unknown error"), DontEnum); 56 putDirect (toStringPropertyName, new ErrorProtoFunc(exec,funcProto), DontEnum);56 putDirectFunction(new ErrorProtoFunc(exec, funcProto, toStringPropertyName), DontEnum); 57 57 } 58 58 59 59 // ------------------------------ ErrorProtoFunc ---------------------------- 60 60 61 ErrorProtoFunc::ErrorProtoFunc(ExecState *exec, FunctionPrototype *funcProto)62 : InternalFunctionImp(funcProto )61 ErrorProtoFunc::ErrorProtoFunc(ExecState*, FunctionPrototype* funcProto, const Identifier& name) 62 : InternalFunctionImp(funcProto, name) 63 63 { 64 64 putDirect(lengthPropertyName, jsNumber(0), DontDelete|ReadOnly|DontEnum); -
trunk/JavaScriptCore/kjs/error_object.h
r12317 r12911 45 45 class ErrorProtoFunc : public InternalFunctionImp { 46 46 public: 47 ErrorProtoFunc(ExecState *exec, FunctionPrototype *funcProto);47 ErrorProtoFunc(ExecState*, FunctionPrototype*, const Identifier&); 48 48 virtual bool implementsCall() const; 49 49 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); -
trunk/JavaScriptCore/kjs/function.cpp
r12523 r12911 57 57 58 58 FunctionImp::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) 62 62 { 63 63 } … … 558 558 559 559 560 GlobalFuncImp::GlobalFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len) 561 : InternalFunctionImp(funcProto), id(i) 560 GlobalFuncImp::GlobalFuncImp(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 561 : InternalFunctionImp(funcProto, name) 562 , id(i) 562 563 { 563 564 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); -
trunk/JavaScriptCore/kjs/function.h
r12523 r12911 25 25 #define KJS_FUNCTION_H 26 26 27 #include "array_instance.h"28 27 #include "internal.h" 29 28 #include <kxmlcore/OwnPtr.h> … … 57 56 58 57 virtual Completion execute(ExecState *exec) = 0; 59 Identifier name() const { return ident; }60 58 61 59 virtual const ClassInfo *classInfo() const { return &info; } … … 63 61 protected: 64 62 OwnPtr<Parameter> param; 65 Identifier ident;66 63 67 64 private: … … 99 96 Identifier& operator[](const Identifier &indexIdentifier); 100 97 bool isMapped(const Identifier &index) const; 101 void IndexToNameMap::unMap(const Identifier &index);98 void unMap(const Identifier &index); 102 99 103 100 private: … … 149 146 class GlobalFuncImp : public InternalFunctionImp { 150 147 public: 151 GlobalFuncImp(ExecState *exec, FunctionPrototype *funcProto, int i, int len);148 GlobalFuncImp(ExecState*, FunctionPrototype*, int i, int len, const Identifier&); 152 149 virtual bool implementsCall() const; 153 150 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); -
trunk/JavaScriptCore/kjs/function_object.cpp
r12317 r12911 41 41 FunctionPrototype::FunctionPrototype(ExecState *exec) 42 42 { 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); 45 45 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); 47 47 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); 49 49 } 50 50 … … 66 66 // ------------------------------ FunctionProtoFunc ------------------------- 67 67 68 FunctionProtoFunc::FunctionProtoFunc(ExecState *exec,69 FunctionPrototype *funcProto, int i, int len)70 : InternalFunctionImp(funcProto), id(i)68 FunctionProtoFunc::FunctionProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 69 : InternalFunctionImp(funcProto, name) 70 , id(i) 71 71 { 72 72 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); … … 84 84 85 85 switch (id) { 86 case ToString: { 87 // ### also make this work for internal functions 86 case ToString: 88 87 if (!thisObj || !thisObj->inherits(&InternalFunctionImp::info)) { 89 88 #ifndef NDEBUG … … 93 92 } 94 93 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]"); 106 103 } 107 104 break; -
trunk/JavaScriptCore/kjs/function_object.h
r12317 r12911 52 52 class FunctionProtoFunc : public InternalFunctionImp { 53 53 public: 54 FunctionProtoFunc(ExecState *exec, 55 FunctionPrototype *funcProto, int i, int len); 54 FunctionProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&); 56 55 57 56 virtual bool implementsCall() const; -
trunk/JavaScriptCore/kjs/internal.cpp
r12728 r12911 455 455 456 456 // ECMA 15.3.4.1 457 funcProto->put(&globExec, "constructor", b_Function, DontEnum);457 funcProto->put(&globExec, constructorPropertyName, b_Function, DontEnum); 458 458 459 459 global->put(&globExec, "Object", b_Object, DontEnum); … … 475 475 global->put(&globExec, "URIError",b_uriError, Internal); 476 476 477 // Set the "constructor"property of all builtin constructors478 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); 493 493 494 494 // built-in values … … 498 498 499 499 // 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); 511 511 #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); 513 513 #endif 514 514 … … 711 711 } 712 712 713 InternalFunctionImp::InternalFunctionImp(FunctionPrototype *funcProto)713 InternalFunctionImp::InternalFunctionImp(FunctionPrototype* funcProto) 714 714 : JSObject(funcProto) 715 { 716 } 717 718 InternalFunctionImp::InternalFunctionImp(FunctionPrototype* funcProto, const Identifier& name) 719 : JSObject(funcProto) 720 , m_name(name) 715 721 { 716 722 } -
trunk/JavaScriptCore/kjs/internal.h
r12728 r12911 349 349 public: 350 350 InternalFunctionImp(); 351 InternalFunctionImp(FunctionPrototype *funcProto); 351 InternalFunctionImp(FunctionPrototype*); 352 InternalFunctionImp(FunctionPrototype*, const Identifier&); 352 353 bool implementsHasInstance() const; 353 354 bool hasInstance(ExecState *exec, JSValue *value); … … 355 356 virtual const ClassInfo *classInfo() const { return &info; } 356 357 static const ClassInfo info; 358 const Identifier& functionName() const { return m_name; } 359 private: 360 Identifier m_name; 357 361 }; 358 362 -
trunk/JavaScriptCore/kjs/lookup.h
r12534 r12911 30 30 31 31 namespace KJS { 32 33 class FunctionPrototype; 32 34 33 35 /** … … 131 133 132 134 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); 134 136 thisObj->putDirect(propertyName, val, entry->attr); 135 137 return val; … … 248 250 thisObj->putValueProperty(exec, entry->value, value, attr); 249 251 } 250 252 251 253 } // namespace 252 254 … … 341 343 342 344 #define KJS_IMPLEMENT_PROTOFUNC(ClassFunc) \ 343 class ClassFunc : public DOMFunction{ \345 class ClassFunc : public InternalFunctionImp { \ 344 346 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) \ 346 350 { \ 347 351 put(exec, lengthPropertyName, jsNumber(len), DontDelete|ReadOnly|DontEnum); \ -
trunk/JavaScriptCore/kjs/math_object.cpp
r12317 r12911 154 154 static bool randomSeeded = false; 155 155 156 MathFuncImp::MathFuncImp(ExecState *exec, int i, int l) 157 : InternalFunctionImp( 158 static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()) 159 ), id(i) 156 MathFuncImp::MathFuncImp(ExecState* exec, int i, int l, const Identifier& name) 157 : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) 158 , id(i) 160 159 { 161 160 putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum); -
trunk/JavaScriptCore/kjs/math_object.h
r12317 r12911 43 43 class MathFuncImp : public InternalFunctionImp { 44 44 public: 45 MathFuncImp(ExecState *exec, int i, int l );45 MathFuncImp(ExecState *exec, int i, int l, const Identifier&); 46 46 virtual bool implementsCall() const; 47 47 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); -
trunk/JavaScriptCore/kjs/number_object.cpp
r12435 r12911 61 61 // The constructor will be added later, after NumberObjectImp has been constructed 62 62 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); 69 69 } 70 70 … … 72 72 // ------------------------------ NumberProtoFunc --------------------------- 73 73 74 NumberProtoFunc::NumberProtoFunc(ExecState *exec,75 FunctionPrototype *funcProto, int i, int len)76 : InternalFunctionImp(funcProto), id(i)74 NumberProtoFunc::NumberProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 75 : InternalFunctionImp(funcProto, name) 76 , id(i) 77 77 { 78 78 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); -
trunk/JavaScriptCore/kjs/number_object.h
r12317 r12911 57 57 class NumberProtoFunc : public InternalFunctionImp { 58 58 public: 59 NumberProtoFunc(ExecState *exec, FunctionPrototype *funcProto, 60 int i, int len); 59 NumberProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&); 61 60 62 61 virtual bool implementsCall() const; -
trunk/JavaScriptCore/kjs/object.cpp
r12728 r12911 542 542 } 543 543 544 void JSObject::putDirectFunction(InternalFunctionImp* func, int attr) 545 { 546 putDirect(func->functionName(), func, attr); 547 } 548 544 549 void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue **location) 545 550 { … … 613 618 /* 614 619 #ifndef NDEBUG 615 const char *msg = err->get( "message")->toString().value().ascii();620 const char *msg = err->get(messagePropertyName)->toString().value().ascii(); 616 621 if (l >= 0) 617 622 fprintf(stderr, "KJS: %s at line %d. %s\n", estr, l, msg); -
trunk/JavaScriptCore/kjs/object.h
r12728 r12911 50 50 class HashEntry; 51 51 class ListImp; 52 class InternalFunctionImp; 52 53 53 54 // ECMA 262-3 8.6.1 … … 510 511 void putDirect(const Identifier &propertyName, int value, int attr = 0); 511 512 513 // convenience to add a function property under the function's own built-in name 514 void putDirectFunction(InternalFunctionImp*, int attr = 0); 515 512 516 void fillGetterPropertySlot(PropertySlot& slot, JSValue **location); 513 517 -
trunk/JavaScriptCore/kjs/object_object.cpp
r12317 r12911 35 35 // ------------------------------ ObjectPrototype -------------------------------- 36 36 37 ObjectPrototype::ObjectPrototype(ExecState *exec, 38 FunctionPrototype *funcProto) 37 ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* funcProto) 39 38 : JSObject() // [[Prototype]] is null 40 39 { 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 47 50 // 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); 52 59 } 53 60 … … 55 62 // ------------------------------ ObjectProtoFunc -------------------------------- 56 63 57 ObjectProtoFunc::ObjectProtoFunc(ExecState *exec, 58 FunctionPrototype *funcProto, 59 int i, int len) 60 : InternalFunctionImp(funcProto), id(i) 64 ObjectProtoFunc::ObjectProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 65 : InternalFunctionImp(funcProto, name) 66 , id(i) 61 67 { 62 68 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); -
trunk/JavaScriptCore/kjs/object_object.h
r12317 r12911 48 48 class ObjectProtoFunc : public InternalFunctionImp { 49 49 public: 50 ObjectProtoFunc(ExecState *exec, FunctionPrototype *funcProto, int i, int len);50 ObjectProtoFunc(ExecState* exec, FunctionPrototype* funcProto, int i, int len, const Identifier&); 51 51 52 52 virtual bool implementsCall() const; -
trunk/JavaScriptCore/kjs/regexp_object.cpp
r12523 r12911 55 55 56 56 static const Identifier execPropertyName("exec"); 57 putDirect(execPropertyName, new RegExpProtoFunc(exec,funcProto,RegExpProtoFunc::Exec, 0), DontEnum);58 57 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); 61 61 } 62 62 63 63 // ------------------------------ RegExpProtoFunc --------------------------- 64 64 65 RegExpProtoFunc::RegExpProtoFunc(ExecState *exec, 66 FunctionPrototype *funcProto, int i, int len) 67 : InternalFunctionImp(funcProto), id(i) 65 RegExpProtoFunc::RegExpProtoFunc(ExecState*, FunctionPrototype* funcProto, int i, int len, const Identifier& name) 66 : InternalFunctionImp(funcProto, name), id(i) 68 67 { 69 68 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); -
trunk/JavaScriptCore/kjs/regexp_object.h
r12523 r12911 41 41 class RegExpProtoFunc : public InternalFunctionImp { 42 42 public: 43 RegExpProtoFunc(ExecState *exec, 44 FunctionPrototype *funcProto, int i, int len); 43 RegExpProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&); 45 44 46 45 virtual bool implementsCall() const; -
trunk/JavaScriptCore/kjs/string_object.cpp
r12728 r12911 168 168 // ------------------------------ StringProtoFunc --------------------------- 169 169 170 StringProtoFunc::StringProtoFunc(ExecState *exec, int i, int len) 171 : InternalFunctionImp( 172 static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()) 173 ), id(i) 170 StringProtoFunc::StringProtoFunc(ExecState *exec, int i, int len, const Identifier& name) 171 : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) 172 , id(i) 174 173 { 175 174 putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum); … … 700 699 putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly); 701 700 702 putDirect (fromCharCodePropertyName, new StringObjectFuncImp(exec, funcProto), DontEnum);701 putDirectFunction(new StringObjectFuncImp(exec, funcProto, fromCharCodePropertyName), DontEnum); 703 702 704 703 // no. of arguments for constructor … … 740 739 741 740 // ECMA 15.5.3.2 fromCharCode() 742 StringObjectFuncImp::StringObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto)743 : InternalFunctionImp(funcProto )741 StringObjectFuncImp::StringObjectFuncImp(ExecState*, FunctionPrototype* funcProto, const Identifier& name) 742 : InternalFunctionImp(funcProto, name) 744 743 { 745 744 putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum); -
trunk/JavaScriptCore/kjs/string_object.h
r12317 r12911 68 68 class StringProtoFunc : public InternalFunctionImp { 69 69 public: 70 StringProtoFunc(ExecState *exec, int i, int len );70 StringProtoFunc(ExecState *exec, int i, int len, const Identifier&); 71 71 72 72 virtual bool implementsCall() const; … … 111 111 class StringObjectFuncImp : public InternalFunctionImp { 112 112 public: 113 StringObjectFuncImp(ExecState *exec, FunctionPrototype *funcProto);113 StringObjectFuncImp(ExecState*, FunctionPrototype*, const Identifier&); 114 114 virtual bool implementsCall() const; 115 115 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
Note:
See TracChangeset
for help on using the changeset viewer.