Changeset 16606 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Sep 27, 2006, 5:58:52 PM (19 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/function.cpp
r16117 r16606 51 51 class Parameter { 52 52 public: 53 Parameter() {}; 53 54 Parameter(const Identifier &n) : name(n) { } 54 55 Identifier name; 55 OwnPtr<Parameter> next;56 // OwnPtr<Parameter> next; 56 57 }; 57 58 … … 152 153 void FunctionImp::addParameter(const Identifier &n) 153 154 { 154 OwnPtr<Parameter> *p = ¶m; 155 while (*p) 156 p = &(*p)->next; 157 158 p->set(new Parameter(n)); 155 params.append(Parameter(n)); 159 156 } 160 157 … … 162 159 { 163 160 UString s; 164 const Parameter *p = param.get(); 165 while (p) { 166 if (!s.isEmpty()) 167 s += ", "; 168 s += p->name.ustring(); 169 p = p->next.get(); 170 } 161 162 for(Vector<Parameter>::const_iterator it = params.begin(); it < params.end(); it++) { 163 if (!s.isEmpty()) 164 s += ", "; 165 s += it->name.ustring(); 166 } 171 167 172 168 return s; … … 185 181 #endif 186 182 187 if (param) {183 if(params.size() != 0) { 188 184 ListIterator it = args.begin(); 189 Parameter *p = param.get(); 185 190 186 JSValue *v = *it; 191 while (p) {187 for(Vector<Parameter>::iterator pit = params.begin(); pit < params.end(); pit++) { 192 188 if (it != args.end()) { 193 189 #ifdef KJS_VERBOSE … … 195 191 printInfo(exec,"to", *it); 196 192 #endif 197 variable->put(exec, p ->name, v);193 variable->put(exec, pit->name, v); 198 194 v = ++it; 199 195 } else 200 variable->put(exec, p->name, jsUndefined()); 201 p = p->next.get(); 196 variable->put(exec, pit->name, jsUndefined()); 202 197 } 203 198 } … … 229 224 JSValue *FunctionImp::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot) 230 225 { 231 FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase()); 232 const Parameter *p = thisObj->param.get(); 233 int count = 0; 234 while (p) { 235 ++count; 236 p = p->next.get(); 237 } 238 return jsNumber(count); 226 FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase()); 227 return jsNumber(thisObj->params.size()); 239 228 } 240 229 … … 279 268 Identifier FunctionImp::getParameterName(int index) 280 269 { 281 int i = 0;282 Parameter *p = param.get();270 if(params.size() == 0) 271 return Identifier::null(); 283 272 284 if(!p)285 return Identifier::null();273 if (index > static_cast<int>(params.size())) 274 return Identifier::null(); 286 275 287 // skip to the parameter we want 288 while (i++ < index && (p = p->next.get())) 289 ; 290 291 if (!p) 292 return Identifier::null(); 293 294 Identifier name = p->name; 295 296 // Are there any subsequent parameters with the same name? 297 while ((p = p->next.get())) 298 if (p->name == name) 299 return Identifier::null(); 300 301 return name; 276 Identifier name = params[index].name; 277 278 // Are there any subsequent parameters with the same name? 279 for (Vector<Parameter>::iterator it = &(params[index+1]); it < params.end(); it++) 280 if (it->name == name) 281 return Identifier::null(); 282 283 return name; 302 284 } 303 285 -
trunk/JavaScriptCore/kjs/function.h
r15846 r16606 27 27 #include "internal.h" 28 28 #include <wtf/OwnPtr.h> 29 #include <wtf/Vector.h> 29 30 30 31 namespace KJS { … … 93 94 virtual void mark(); 94 95 protected: 95 OwnPtr<Parameter> param;96 Vector<Parameter> params; 96 97 97 98 private:
Note:
See TracChangeset
for help on using the changeset viewer.