+2006-09-27 Kevin McCullough <KMcCullough@apple.com>
+
+ Reviewed by GGaren.
+
+ Cleanup of previous fix which was to address Radar: 4752492
+
+ * kjs/function.cpp:
+ (KJS::FunctionImp::addParameter):
+ (KJS::FunctionImp::parameterString):
+ (KJS::FunctionImp::processParameters):
+ (KJS::FunctionImp::lengthGetter):
+ (KJS::FunctionImp::getParameterName):
+ * kjs/function.h:
+
2006-09-27 Kevin McCullough <KMcCullough@apple.com>
Reviewed by Adele.
Parameter() {};
Parameter(const Identifier &n) : name(n) { }
Identifier name;
-// OwnPtr<Parameter> next;
};
FunctionImp::FunctionImp(ExecState *exec, const Identifier &n, FunctionBodyNode* b)
void FunctionImp::addParameter(const Identifier &n)
{
- params.append(Parameter(n));
+ parameters.append(Parameter(n));
}
UString FunctionImp::parameterString() const
{
UString s;
- for(Vector<Parameter>::const_iterator it = params.begin(); it < params.end(); it++) {
+ Vector<Parameter>::const_iterator end = parameters.end();
+ for(Vector<Parameter>::const_iterator it = parameters.begin(); it < end; it++) {
if (!s.isEmpty())
s += ", ";
s += it->name.ustring();
name().isEmpty() ? "(internal)" : name().ascii());
#endif
- if(params.size() != 0) {
ListIterator it = args.begin();
JSValue *v = *it;
- for(Vector<Parameter>::iterator pit = params.begin(); pit < params.end(); pit++) {
+ Vector<Parameter>::const_iterator end = parameters.end();
+ for(Vector<Parameter>::iterator pit = parameters.begin(); pit < end; pit++) {
if (it != args.end()) {
#ifdef KJS_VERBOSE
fprintf(stderr, "setting parameter %s ", p->name.ascii());
v = ++it;
} else
variable->put(exec, pit->name, jsUndefined());
- }
}
#ifdef KJS_VERBOSE
else {
JSValue *FunctionImp::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot)
{
FunctionImp *thisObj = static_cast<FunctionImp *>(slot.slotBase());
- return jsNumber(thisObj->params.size());
+ return jsNumber(thisObj->parameters.size());
}
bool FunctionImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
*/
Identifier FunctionImp::getParameterName(int index)
{
- if(params.size() == 0)
- return Identifier::null();
-
- if (index > static_cast<int>(params.size()))
+ ASSERT(static_cast<size_t>(index) == index);
+ if (static_cast<size_t>(index) > parameters.size())
return Identifier::null();
- Identifier name = params[index].name;
+ Identifier name = parameters[index].name;
// Are there any subsequent parameters with the same name?
- for (Vector<Parameter>::iterator it = &(params[index+1]); it < params.end(); it++)
+ Vector<Parameter>::const_iterator end = parameters.end();
+ for (Vector<Parameter>::iterator it = &(parameters[index+1]); it < end; it++)
if (it->name == name)
return Identifier::null();