/*
* Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)
* Copyright (C) 2007 Maks Orlovich
*
delete [] d->extraArguments;
}
-void Arguments::mark()
+void Arguments::markChildren(MarkStack& markStack)
{
- JSObject::mark();
+ JSObject::markChildren(markStack);
- if (d->registerArray) {
- for (unsigned i = 0; i < d->numParameters; ++i) {
- if (!d->registerArray[i].marked())
- d->registerArray[i].mark();
- }
- }
+ if (d->registerArray)
+ markStack.appendValues(reinterpret_cast<JSValue*>(d->registerArray.get()), d->numParameters);
if (d->extraArguments) {
unsigned numExtraArguments = d->numArguments - d->numParameters;
- for (unsigned i = 0; i < numExtraArguments; ++i) {
- if (!d->extraArguments[i].marked())
- d->extraArguments[i].mark();
- }
+ markStack.appendValues(reinterpret_cast<JSValue*>(d->extraArguments), numExtraArguments);
}
- if (!d->callee->marked())
- d->callee->mark();
+ markStack.append(d->callee);
- if (d->activation && !d->activation->marked())
- d->activation->mark();
+ if (d->activation)
+ markStack.append(d->activation);
}
void Arguments::copyToRegisters(ExecState* exec, Register* buffer, uint32_t maxSize)
return JSObject::getOwnPropertySlot(exec, propertyName, slot);
}
+bool Arguments::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
+{
+ bool isArrayIndex;
+ unsigned i = propertyName.toArrayIndex(&isArrayIndex);
+ if (isArrayIndex && i < d->numArguments && (!d->deletedArguments || !d->deletedArguments[i])) {
+ if (i < d->numParameters) {
+ descriptor.setDescriptor(d->registers[d->firstParameterIndex + i].jsValue(), DontEnum);
+ } else
+ descriptor.setDescriptor(d->extraArguments[i - d->numParameters].jsValue(), DontEnum);
+ return true;
+ }
+
+ if (propertyName == exec->propertyNames().length && LIKELY(!d->overrodeLength)) {
+ descriptor.setDescriptor(jsNumber(exec, d->numArguments), DontEnum);
+ return true;
+ }
+
+ if (propertyName == exec->propertyNames().callee && LIKELY(!d->overrodeCallee)) {
+ descriptor.setDescriptor(d->callee, DontEnum);
+ return true;
+ }
+
+ return JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
+}
+
+void Arguments::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
+{
+ if (mode == IncludeDontEnumProperties) {
+ for (unsigned i = 0; i < d->numArguments; ++i) {
+ if (!d->deletedArguments || !d->deletedArguments[i])
+ propertyNames.add(Identifier(exec, UString::from(i)));
+ }
+ propertyNames.add(exec->propertyNames().callee);
+ propertyNames.add(exec->propertyNames().length);
+ }
+ JSObject::getOwnPropertyNames(exec, propertyNames, mode);
+}
+
void Arguments::put(ExecState* exec, unsigned i, JSValue value, PutPropertySlot& slot)
{
if (i < d->numArguments && (!d->deletedArguments || !d->deletedArguments[i])) {