Warning, /frameworks/kjs/src/kjs/DESIGN.ideas is written in an unsupported language. File is not indexed.
0001 Get rid of SourceElementsNode by integrating its functionality into 0002 StatementNode. 0003 0004 ========================================================================== 0005 0006 The hash value of a string could be calculated at creation time and be 0007 stored in the UString instance for later use by the lookup functions. 0008 0009 ========================================================================== 0010 0011 Proposal for a new object model. Far from being complete. 0012 0013 Object Type 0014 +---------+ +-------------+ 0015 | type | ----------------> | toString() | 0016 | | | toNumber() | 0017 | data | | .... | 0018 +---------+ | construct() | 0019 | +-------------+ 0020 | | /|\ 0021 \|/ | | 0022 +---------+ | | 0023 | type | | | 0024 | | Shared (optional) \|/ | 0025 | data | +-------------+ 0026 +---------+ +---------+ | types | 0027 /|\ | |<------| gc | Interpreter/Environment 0028 +-------| | | .... | 0029 | | | excp state | 0030 +---------+ +-------------+ 0031 Garbage Collector 0032 0033 Features: 0034 - offers class static data (nice replacement for pointers to member 0035 function objects in the prototype object) 0036 - no more need to pass around ExecState pointers for the C++ user 0037 (substituted with the need for Object* in the type implementation) 0038 - simple types are stored simple (no new'ed Imp objects) 0039 0040 Alternative A: pass around Object by pointer rather than value 0041 rather than new'ing they should come out of a pool 0042 0043 Alternative B: instead of virtual functions like toBoolean(), Type could 0044 have an array of function pointers which can be modified 0045 on the fly and checked for != 0. 0046 0047 Limitations: Konqueror's requirement to allow access to other frame's 0048 interpreter data but flagging errors on the caller's side 0049 is not satisfied. 0050 0051 class Interpreter; 0052 0053 class Type { 0054 public: 0055 Type(Interpreter* i, Type *b) : ip(i), bs(b) { } 0056 virtual UString name() const = 0; 0057 Type* base() const { return bs; } 0058 Interpreter* interpreter() const { return ip; } 0059 0060 virtual bool toBoolean(Object *o); 0061 // .... 0062 virtual Object construct(const List &args); 0063 0064 // factory 0065 Boolean newBoolean(bool b) { return Boolean(interpreter(), b); } 0066 0067 private: 0068 Interpreter* ip; 0069 Type* bs; 0070 }; 0071 0072 union Data { 0073 bool b; 0074 double d; 0075 // UString ??? 0076 Shared* sh; 0077 }; 0078 0079 class Object { 0080 public: 0081 // creation 0082 Boolean newBoolean(bool b) { return Boolean(typ->interpreter(), b); } 0083 0084 // conversion 0085 bool to Boolean() const { return typ->toBoolean(this); } 0086 0087 // this object's "parent" 0088 Interpreter* interpreter() const { return typ->ip; } 0089 private: 0090 Type* typ; 0091 Data dat; 0092 }; 0093 0094 class Boolean : public Object { 0095 public: 0096 // used by convenience function newBoolean() 0097 Boolean(Interpreter *i, bool b) { 0098 typ = i->booleanType(); 0099 dat.b = b; 0100 } 0101 Boolean(const Boolean &b) { 0102 typ = b.typ; 0103 dat.b = b.b; 0104 } 0105 Boolean& operator=(const Boolean &b) { 0106 type = b.typ; 0107 dat.b = b.b; 0108 return *this; 0109 } 0110 };