Commit 1ef28f38 authored by kmccullo's avatar kmccullo
Browse files

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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16607 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8b3a80b0
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.
......
......@@ -53,7 +53,6 @@ const ClassInfo FunctionImp::info = {"Function", &InternalFunctionImp::info, 0,
Parameter() {};
Parameter(const Identifier &n) : name(n) { }
Identifier name;
// OwnPtr<Parameter> next;
};
FunctionImp::FunctionImp(ExecState *exec, const Identifier &n, FunctionBodyNode* b)
......@@ -152,14 +151,15 @@ JSValue *FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const L
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();
......@@ -180,11 +180,11 @@ void FunctionImp::processParameters(ExecState *exec, const List &args)
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());
......@@ -194,7 +194,6 @@ void FunctionImp::processParameters(ExecState *exec, const List &args)
v = ++it;
} else
variable->put(exec, pit->name, jsUndefined());
}
}
#ifdef KJS_VERBOSE
else {
......@@ -224,7 +223,7 @@ JSValue *FunctionImp::argumentsGetter(ExecState* exec, JSObject*, const Identifi
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)
......@@ -267,16 +266,15 @@ bool FunctionImp::deleteProperty(ExecState *exec, const Identifier &propertyName
*/
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();
......
......@@ -93,7 +93,7 @@ namespace KJS {
virtual void mark();
protected:
Vector<Parameter> params;
Vector<Parameter> parameters;
private:
ScopeChain _scope;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment