- fixed REGRESSION (r16606): javascriptCore Crash on website load
Plus style fixes.
- fixed some possible off-by-one bugs
- use indexing, not iterators, for Vectors
- store Vector by pointer instead of by value to avoid blowing out FunctionImp size
* kjs/function.cpp:
(KJS::FunctionImp::addParameter):
(KJS::FunctionImp::parameterString):
(KJS::FunctionImp::processParameters):
(KJS::FunctionImp::lengthGetter):
(KJS::FunctionImp::getParameterName):
* kjs/function.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16613
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-09-28 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Mitz.
+
+ - fixed REGRESSION (r16606): javascriptCore Crash on website load
+
+ Plus style fixes.
+
+ - fixed some possible off-by-one bugs
+ - use indexing, not iterators, for Vectors
+ - store Vector by pointer instead of by value to avoid blowing out FunctionImp size
+
+ * kjs/function.cpp:
+ (KJS::FunctionImp::addParameter):
+ (KJS::FunctionImp::parameterString):
+ (KJS::FunctionImp::processParameters):
+ (KJS::FunctionImp::lengthGetter):
+ (KJS::FunctionImp::getParameterName):
+ * kjs/function.h:
+
2006-09-27 Steve Falkenburg <sfalken@apple.com>
Reviewed by Maciej.
2006-09-27 Steve Falkenburg <sfalken@apple.com>
Reviewed by Maciej.
void FunctionImp::addParameter(const Identifier &n)
{
void FunctionImp::addParameter(const Identifier &n)
{
- parameters.append(Parameter(n));
+ if (!parameters)
+ parameters.set(new Vector<Parameter>);
+
+ parameters->append(Parameter(n));
}
UString FunctionImp::parameterString() const
{
}
UString FunctionImp::parameterString() const
{
+ UString s;
+
+ if (!parameters)
+ return s;
- Vector<Parameter>::const_iterator end = parameters.end();
- for(Vector<Parameter>::const_iterator it = parameters.begin(); it < end; it++) {
+ for (size_t i = 0; i < parameters->size(); ++i) {
if (!s.isEmpty())
s += ", ";
if (!s.isEmpty())
s += ", ";
- s += it->name.ustring();
+ s += parameters->at(i).name.ustring();
}
// ECMA 10.1.3q
void FunctionImp::processParameters(ExecState *exec, const List &args)
{
}
// ECMA 10.1.3q
void FunctionImp::processParameters(ExecState *exec, const List &args)
{
- JSObject* variable = exec->context()->variableObject();
+ if (!parameters)
+ return;
+
+ JSObject* variable = exec->context()->variableObject();
- fprintf(stderr, "---------------------------------------------------\n"
+ fprintf(stderr, "---------------------------------------------------\n"
"processing parameters for %s call\n",
name().isEmpty() ? "(internal)" : name().ascii());
#endif
"processing parameters for %s call\n",
name().isEmpty() ? "(internal)" : name().ascii());
#endif
ListIterator it = args.begin();
JSValue *v = *it;
ListIterator it = args.begin();
JSValue *v = *it;
- Vector<Parameter>::const_iterator end = parameters.end();
- for(Vector<Parameter>::iterator pit = parameters.begin(); pit < end; pit++) {
+ for (size_t i = 0; i < parameters->size(); ++i) {
if (it != args.end()) {
#ifdef KJS_VERBOSE
if (it != args.end()) {
#ifdef KJS_VERBOSE
- fprintf(stderr, "setting parameter %s ", p->name.ascii());
- printInfo(exec,"to", *it);
+ fprintf(stderr, "setting parameter %s ", parameters->at(i).name.ascii());
+ printInfo(exec, "to", *it);
- variable->put(exec, pit->name, v);
+ variable->put(exec, parameters->at(i).name, v);
- variable->put(exec, pit->name, jsUndefined());
+ variable->put(exec, parameters->at(i).name, jsUndefined());
}
#ifdef KJS_VERBOSE
else {
}
#ifdef KJS_VERBOSE
else {
- for (int i = 0; i < args.size(); i++)
+ for (int i = 0; i < args.size(); ++i)
printInfo(exec,"setting argument", args[i]);
}
#endif
printInfo(exec,"setting argument", args[i]);
}
#endif
JSValue *FunctionImp::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot)
{
FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase());
JSValue *FunctionImp::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot)
{
FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase());
- return jsNumber(thisObj->parameters.size());
+ return jsNumber(thisObj->parameters ? thisObj->parameters->size() : 0);
}
bool FunctionImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
}
bool FunctionImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
*/
Identifier FunctionImp::getParameterName(int index)
{
*/
Identifier FunctionImp::getParameterName(int index)
{
- if (static_cast<size_t>(index) > parameters.size())
+ if (!parameters)
+ return Identifier::null();
+
+ if (static_cast<size_t>(index) >= parameters->size())
return Identifier::null();
return Identifier::null();
- Identifier name = parameters[index].name;
+ Identifier name = parameters->at(index).name;
// Are there any subsequent parameters with the same name?
// Are there any subsequent parameters with the same name?
- Vector<Parameter>::const_iterator end = parameters.end();
- for (Vector<Parameter>::iterator it = &(parameters[index+1]); it < end; it++)
- if (it->name == name)
+ for (size_t i = index + 1; i < parameters->size(); ++i)
+ if (parameters->at(i).name == name)
return Identifier::null();
return name;
return Identifier::null();
return name;
virtual void mark();
protected:
virtual void mark();
protected:
- Vector<Parameter> parameters;
+ OwnPtr<Vector<Parameter> > parameters;
private:
ScopeChain _scope;
private:
ScopeChain _scope;