Changeset 10084 in webkit for trunk/JavaScriptCore/kjs/internal.h
- Timestamp:
- Aug 7, 2005, 9:07:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/internal.h
r10076 r10084 23 23 */ 24 24 25 #ifndef _INTERNAL_H_26 #define _INTERNAL_H_25 #ifndef INTERNAL_H 26 #define INTERNAL_H 27 27 28 28 #include "ustring.h" … … 38 38 namespace KJS { 39 39 40 static const double D16 = 65536.0;41 static const double D32 = 4294967296.0;42 43 40 class ProgramNode; 44 41 class FunctionBodyNode; … … 51 48 // --------------------------------------------------------------------------- 52 49 53 class UndefinedImp : public ValueImp {50 class UndefinedImp : public AllocatedValueImp { 54 51 public: 55 52 Type type() const { return UndefinedType; } 56 53 57 Value 54 ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const; 58 55 bool toBoolean(ExecState *exec) const; 59 56 double toNumber(ExecState *exec) const; 60 57 UString toString(ExecState *exec) const; 61 Object toObject(ExecState *exec) const; 62 63 static UndefinedImp *staticUndefined; 64 }; 65 66 inline Undefined::Undefined(UndefinedImp *imp) : Value(imp) { } 67 68 class NullImp : public ValueImp { 58 ObjectImp *toObject(ExecState *exec) const; 59 }; 60 61 class NullImp : public AllocatedValueImp { 69 62 public: 70 63 Type type() const { return NullType; } 71 64 72 Value 65 ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const; 73 66 bool toBoolean(ExecState *exec) const; 74 67 double toNumber(ExecState *exec) const; 75 68 UString toString(ExecState *exec) const; 76 Object toObject(ExecState *exec) const; 77 78 static NullImp *staticNull; 79 }; 80 81 inline Null::Null(NullImp *imp) : Value(imp) { } 82 83 class BooleanImp : public ValueImp { 69 ObjectImp *toObject(ExecState *exec) const; 70 }; 71 72 class BooleanImp : public AllocatedValueImp { 84 73 public: 85 74 BooleanImp(bool v = false) : val(v) { } … … 88 77 Type type() const { return BooleanType; } 89 78 90 Value 79 ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const; 91 80 bool toBoolean(ExecState *exec) const; 92 81 double toNumber(ExecState *exec) const; 93 82 UString toString(ExecState *exec) const; 94 Object toObject(ExecState *exec) const; 95 96 static BooleanImp *staticTrue; 97 static BooleanImp *staticFalse; 83 ObjectImp *toObject(ExecState *exec) const; 84 98 85 private: 99 86 bool val; 100 87 }; 101 88 102 inline Boolean::Boolean(BooleanImp *imp) : Value(imp) { } 103 104 class StringImp : public ValueImp { 89 class StringImp : public AllocatedValueImp { 105 90 public: 106 91 StringImp(const UString& v) : val(v) { } … … 109 94 Type type() const { return StringType; } 110 95 111 Value 96 ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const; 112 97 bool toBoolean(ExecState *exec) const; 113 98 double toNumber(ExecState *exec) const; 114 99 UString toString(ExecState *exec) const; 115 Object 100 ObjectImp *toObject(ExecState *exec) const; 116 101 117 102 private: … … 119 104 }; 120 105 121 inline String::String(StringImp *imp) : Value(imp) { } 122 123 class NumberImp : public ValueImp { 124 friend class Value; 125 friend class Number; 106 class NumberImp : public AllocatedValueImp { 107 friend class ConstantValues; 126 108 friend class InterpreterImp; 127 friend ValueImp *number(int); 128 friend ValueImp *number(unsigned); 129 friend ValueImp *number(long); 130 friend ValueImp *number(unsigned long); 131 friend ValueImp *number(double); 132 friend ValueImp *number(double, bool); 133 public: 134 static ValueImp *create(int); 135 static ValueImp *create(double); 136 static ValueImp *zero() { return SimpleNumber::make(0); } 137 static ValueImp *one() { return SimpleNumber::make(1); } 138 static ValueImp *two() { return SimpleNumber::make(2); } 139 109 friend ValueImp *jsNumber(int); 110 friend ValueImp *jsNumber(unsigned); 111 friend ValueImp *jsNumber(long); 112 friend ValueImp *jsNumber(unsigned long); 113 friend ValueImp *jsNumber(double); 114 friend ValueImp *jsNumber(double, bool); 115 public: 140 116 double value() const { return val; } 141 117 142 118 Type type() const { return NumberType; } 143 119 144 Value 120 ValueImp *toPrimitive(ExecState *exec, Type preferred = UnspecifiedType) const; 145 121 bool toBoolean(ExecState *exec) const; 146 122 double toNumber(ExecState *exec) const; 147 123 UString toString(ExecState *exec) const; 148 Object toObject(ExecState *exec) const; 149 150 static NumberImp *staticNaN; 124 ObjectImp *toObject(ExecState *exec) const; 151 125 152 126 private: 153 127 NumberImp(double v) : val(v) { } 154 128 155 virtual bool toUInt32(unsigned&) const;129 virtual bool getUInt32(uint32_t&) const; 156 130 157 131 double val; 158 132 }; 159 160 inline Number::Number(NumberImp *imp) : Value(imp) { }161 133 162 134 /** … … 207 179 208 180 // --------------------------------------------------------------------------- 209 // Parsing & evaluat eion181 // Parsing & evaluation 210 182 // --------------------------------------------------------------------------- 211 183 … … 276 248 static void globalClear(); 277 249 278 InterpreterImp(Interpreter *interp, const Object &glob);250 InterpreterImp(Interpreter *interp, ObjectImp *glob); 279 251 ~InterpreterImp(); 280 252 … … 291 263 ExecState *globalExec() { return &globExec; } 292 264 bool checkSyntax(const UString &code); 293 Completion evaluate(const UString &code, const Value &thisV, const UString &sourceURL, int startingLineNumber);265 Completion evaluate(const UString &code, ValueImp *thisV, const UString &sourceURL, int startingLineNumber); 294 266 Debugger *debugger() const { return dbg; } 295 267 void setDebugger(Debugger *d) { dbg = d; } 296 268 297 Object 298 Object 299 Object 300 Object 301 Object 302 Object 303 Object 304 Object 305 Object 306 307 Object 308 Object 309 Object 310 Object 311 Object 312 Object 313 Object 314 Object 315 Object 316 317 Object 318 Object 319 Object 320 Object 321 Object 322 Object 323 324 Object 325 Object 326 Object 327 Object 328 Object 329 Object 269 ObjectImp *builtinObject() const { return b_Object; } 270 ObjectImp *builtinFunction() const { return b_Function; } 271 ObjectImp *builtinArray() const { return b_Array; } 272 ObjectImp *builtinBoolean() const { return b_Boolean; } 273 ObjectImp *builtinString() const { return b_String; } 274 ObjectImp *builtinNumber() const { return b_Number; } 275 ObjectImp *builtinDate() const { return b_Date; } 276 ObjectImp *builtinRegExp() const { return b_RegExp; } 277 ObjectImp *builtinError() const { return b_Error; } 278 279 ObjectImp *builtinObjectPrototype() const { return b_ObjectPrototype; } 280 ObjectImp *builtinFunctionPrototype() const { return b_FunctionPrototype; } 281 ObjectImp *builtinArrayPrototype() const { return b_ArrayPrototype; } 282 ObjectImp *builtinBooleanPrototype() const { return b_BooleanPrototype; } 283 ObjectImp *builtinStringPrototype() const { return b_StringPrototype; } 284 ObjectImp *builtinNumberPrototype() const { return b_NumberPrototype; } 285 ObjectImp *builtinDatePrototype() const { return b_DatePrototype; } 286 ObjectImp *builtinRegExpPrototype() const { return b_RegExpPrototype; } 287 ObjectImp *builtinErrorPrototype() const { return b_ErrorPrototype; } 288 289 ObjectImp *builtinEvalError() const { return b_evalError; } 290 ObjectImp *builtinRangeError() const { return b_rangeError; } 291 ObjectImp *builtinReferenceError() const { return b_referenceError; } 292 ObjectImp *builtinSyntaxError() const { return b_syntaxError; } 293 ObjectImp *builtinTypeError() const { return b_typeError; } 294 ObjectImp *builtinURIError() const { return b_uriError; } 295 296 ObjectImp *builtinEvalErrorPrototype() const { return b_evalErrorPrototype; } 297 ObjectImp *builtinRangeErrorPrototype() const { return b_rangeErrorPrototype; } 298 ObjectImp *builtinReferenceErrorPrototype() const { return b_referenceErrorPrototype; } 299 ObjectImp *builtinSyntaxErrorPrototype() const { return b_syntaxErrorPrototype; } 300 ObjectImp *builtinTypeErrorPrototype() const { return b_typeErrorPrototype; } 301 ObjectImp *builtinURIErrorPrototype() const { return b_uriErrorPrototype; } 330 302 331 303 void setCompatMode(Interpreter::CompatMode mode) { m_compatMode = mode; } … … 423 395 InternalFunctionImp(FunctionPrototypeImp *funcProto); 424 396 bool implementsHasInstance() const; 425 Boolean hasInstance(ExecState *exec, const Value &value);397 bool hasInstance(ExecState *exec, ValueImp *value); 426 398 427 399 virtual const ClassInfo *classInfo() const { return &info; } … … 430 402 431 403 // helper function for toInteger, toInt32, toUInt32 and toUInt16 432 double roundValue(ExecState * exec, const Value &v);404 double roundValue(ExecState *, ValueImp *); 433 405 434 406 #ifndef NDEBUG 435 void printInfo(ExecState *exec, const char *s, const Value &o, int lineno = -1);407 void printInfo(ExecState *exec, const char *s, ValueImp *, int lineno = -1); 436 408 #endif 437 409 438 410 } // namespace 439 411 440 441 #endif // _INTERNAL_H_ 412 #endif // INTERNAL_H
Note:
See TracChangeset
for help on using the changeset viewer.