Commit 07f7cce0 authored by darin's avatar darin

top level:

        * Tests/WebFoundation-Misc/ifnsurlextensions-test.m: (TestURLCommon):
	Add tests for the new WebNSURLExtras methods.

        * Tests/libiftest/IFCheckLeaks.c: (IFCheckLeaksAtExit): Remove workaround for
	CFPreferences race condition; it's now in WebFoundation.

JavaScriptCore:

	Speed improvements. 19% faster on cvs-js-performance, 1% on cvs-static-urls.

	Use global string objects for length and other common property names rather
	than constantly making and destroying them. Use integer versions of get() and
	other related calls rather than always making a string.

	Also get rid of many unneeded constructors, destructors, copy constructors, and
	assignment operators. And make some functions non-virtual.

        * kjs/internal.h:
        * kjs/internal.cpp:
        (NumberImp::toUInt32): Implement.
        (ReferenceImp::ReferenceImp): Special case for numeric property names.
        (ReferenceImp::getPropertyName): Moved guts here from ValueImp. Handle numeric case.
        (ReferenceImp::getValue): Moved guts here from ValueImp. Handle numeric case.
        (ReferenceImp::putValue): Moved guts here from ValueImp. Handle numeric case.
        (ReferenceImp::deleteValue): Added. Handle numeric case.

        * kjs/array_object.h:
        * kjs/array_object.cpp: All-new array implementation that stores the elements
	in a C++ array rather than in a property map.
        (ArrayInstanceImp::ArrayInstanceImp): Allocate the C++ array.
        (ArrayInstanceImp::~ArrayInstanceImp): Delete the C++ array.
        (ArrayInstanceImp::get): Implement both the old version and the new overload that
	takes an unsigned index for speed.
        (ArrayInstanceImp::put): Implement both the old version and the new overload that
	takes an unsigned index for speed.
        (ArrayInstanceImp::hasProperty): Implement both the old version and the new overload that
	takes an unsigned index for speed.
        (ArrayInstanceImp::deleteProperty): Implement both the old version and the new overload that
	takes an unsigned index for speed.
        (ArrayInstanceImp::setLength): Added. Used by the above to resize the array.
        (ArrayInstanceImp::mark): Mark the elements of the array too.
        (ArrayPrototypeImp::ArrayPrototypeImp): Pass the length to the array instance constructor.

        * kjs/bool_object.cpp:
        * kjs/date_object.cpp:
        * kjs/error_object.cpp:
        * kjs/function.cpp:
        * kjs/function_object.cpp:
        * kjs/math_object.cpp:
        * kjs/nodes.cpp:
        * kjs/nodes.h:
        * kjs/number_object.cpp:
        * kjs/object_object.cpp:
        * kjs/regexp_object.cpp:
        * kjs/string_object.cpp:

        * kjs/nodes2string.cpp: (SourceStream::operator<<): Add a special case for char now that
	you can't create a UString from a char implicitly.

        * kjs/object.h:
        * kjs/object.cpp:
        (ObjectImp::get): Call through to the string version if the numeric version is not implemented.
        (ObjectImp::put): Call through to the string version if the numeric version is not implemented.
        (ObjectImp::hasProperty): Call through to the string version if the numeric version is not implemented.
        (ObjectImp::deleteProperty): Call through to the string version if the numeric version is not implemented.

        * kjs/types.h:
        * kjs/types.cpp:
        (Reference::Reference): Added constructors for the numeric property name case.

        * kjs/ustring.h: Made the constructor that turns a character into a string be explicit so we
	don't get numbers that turn themselves into strings.
        * kjs/ustring.cpp:
        (UString::UString): Detect the empty string case, and use a shared empty string.
        (UString::find): Add an overload for single character finds.
        (UString::rfind): Add an overload for single character finds.
        (KJS::operator==): Fix bug where it would call strlen(0) if the first string was not null.
	Also handle non-ASCII characters consistently with the rest of the code by casting to unsigned char
	just in case.

        * kjs/value.h: Make ValueImp and all subclasses non-copyable and non-assignable.
        * kjs/value.cpp:
        (ValueImp::toUInt32): New interface, mainly useful so we can detect array indices and not turn
	them into strings and back.
        (ValueImp::toInteger): Use the new toUInt32. Probably can use more improvement.
        (ValueImp::toInt32): Use the new toUInt32. Probably can use more improvement.
        (ValueImp::toUInt16): Use the new toUInt32. Probably can use more improvement.
        (ValueImp::getBase): Remove handling of the Reference case. That's in ReferenceImp now.
        (ValueImp::getPropertyName): Remove handling of the Reference case. That's in ReferenceImp now.
        (ValueImp::getValue): Remove handling of the Reference case. That's in ReferenceImp now.
        (ValueImp::putValue): Remove handling of the Reference case. That's in ReferenceImp now.
        (ValueImp::deleteValue): Added. Used so we can do delete the same way we do put.

WebFoundation:

        * CacheLoader.subproj/WebHTTPResourceLoader.m:
        (-[WebHTTPProtocolHandler createWFLoadRequest]): Fix handling of paths with queries
	and some other subtle path and port number handling issues by using _web_hostWithPort
	and _web_pathWithQuery.

        * Misc.subproj/WebNSURLExtras.h:
        * Misc.subproj/WebNSURLExtras.m:
        (-[NSURL _web_hostWithPort]): Added.
        (-[NSURL _web_pathWithQuery]): Added.

        * CacheLoader.subproj/WebResourceLoad.m:
        (initLoader): Get some random preference before creating threads. This makes it impossible
	to run into the CFPreferences race condition.

WebCore:

        * force-clean-timestamp: Need a full build because of KJS changes.
        * khtml/ecma/kjs_window.h: Need to store an Object, not an ObjectImp, because there's no way
	to copy an ObjectImp. KJS changes caught this mistake.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1799 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b60f5892
2002-08-12 Darin Adler <darin@apple.com>
Speed improvements. 19% faster on cvs-js-performance, 1% on cvs-static-urls.
Use global string objects for length and other common property names rather
than constantly making and destroying them. Use integer versions of get() and
other related calls rather than always making a string.
Also get rid of many unneeded constructors, destructors, copy constructors, and
assignment operators. And make some functions non-virtual.
* kjs/internal.h:
* kjs/internal.cpp:
(NumberImp::toUInt32): Implement.
(ReferenceImp::ReferenceImp): Special case for numeric property names.
(ReferenceImp::getPropertyName): Moved guts here from ValueImp. Handle numeric case.
(ReferenceImp::getValue): Moved guts here from ValueImp. Handle numeric case.
(ReferenceImp::putValue): Moved guts here from ValueImp. Handle numeric case.
(ReferenceImp::deleteValue): Added. Handle numeric case.
* kjs/array_object.h:
* kjs/array_object.cpp: All-new array implementation that stores the elements
in a C++ array rather than in a property map.
(ArrayInstanceImp::ArrayInstanceImp): Allocate the C++ array.
(ArrayInstanceImp::~ArrayInstanceImp): Delete the C++ array.
(ArrayInstanceImp::get): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::put): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::hasProperty): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::deleteProperty): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::setLength): Added. Used by the above to resize the array.
(ArrayInstanceImp::mark): Mark the elements of the array too.
(ArrayPrototypeImp::ArrayPrototypeImp): Pass the length to the array instance constructor.
* kjs/bool_object.cpp:
* kjs/date_object.cpp:
* kjs/error_object.cpp:
* kjs/function.cpp:
* kjs/function_object.cpp:
* kjs/math_object.cpp:
* kjs/nodes.cpp:
* kjs/nodes.h:
* kjs/number_object.cpp:
* kjs/object_object.cpp:
* kjs/regexp_object.cpp:
* kjs/string_object.cpp:
* kjs/nodes2string.cpp: (SourceStream::operator<<): Add a special case for char now that
you can't create a UString from a char implicitly.
* kjs/object.h:
* kjs/object.cpp:
(ObjectImp::get): Call through to the string version if the numeric version is not implemented.
(ObjectImp::put): Call through to the string version if the numeric version is not implemented.
(ObjectImp::hasProperty): Call through to the string version if the numeric version is not implemented.
(ObjectImp::deleteProperty): Call through to the string version if the numeric version is not implemented.
* kjs/types.h:
* kjs/types.cpp:
(Reference::Reference): Added constructors for the numeric property name case.
* kjs/ustring.h: Made the constructor that turns a character into a string be explicit so we
don't get numbers that turn themselves into strings.
* kjs/ustring.cpp:
(UString::UString): Detect the empty string case, and use a shared empty string.
(UString::find): Add an overload for single character finds.
(UString::rfind): Add an overload for single character finds.
(KJS::operator==): Fix bug where it would call strlen(0) if the first string was not null.
Also handle non-ASCII characters consistently with the rest of the code by casting to unsigned char
just in case.
* kjs/value.h: Make ValueImp and all subclasses non-copyable and non-assignable.
* kjs/value.cpp:
(ValueImp::toUInt32): New interface, mainly useful so we can detect array indices and not turn
them into strings and back.
(ValueImp::toInteger): Use the new toUInt32. Probably can use more improvement.
(ValueImp::toInt32): Use the new toUInt32. Probably can use more improvement.
(ValueImp::toUInt16): Use the new toUInt32. Probably can use more improvement.
(ValueImp::getBase): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::getPropertyName): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::getValue): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::putValue): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::deleteValue): Added. Used so we can do delete the same way we do put.
=== Alexander-17 ===
2002-08-09 Darin Adler <darin@apple.com>
......
2002-08-12 Darin Adler <darin@apple.com>
Speed improvements. 19% faster on cvs-js-performance, 1% on cvs-static-urls.
Use global string objects for length and other common property names rather
than constantly making and destroying them. Use integer versions of get() and
other related calls rather than always making a string.
Also get rid of many unneeded constructors, destructors, copy constructors, and
assignment operators. And make some functions non-virtual.
* kjs/internal.h:
* kjs/internal.cpp:
(NumberImp::toUInt32): Implement.
(ReferenceImp::ReferenceImp): Special case for numeric property names.
(ReferenceImp::getPropertyName): Moved guts here from ValueImp. Handle numeric case.
(ReferenceImp::getValue): Moved guts here from ValueImp. Handle numeric case.
(ReferenceImp::putValue): Moved guts here from ValueImp. Handle numeric case.
(ReferenceImp::deleteValue): Added. Handle numeric case.
* kjs/array_object.h:
* kjs/array_object.cpp: All-new array implementation that stores the elements
in a C++ array rather than in a property map.
(ArrayInstanceImp::ArrayInstanceImp): Allocate the C++ array.
(ArrayInstanceImp::~ArrayInstanceImp): Delete the C++ array.
(ArrayInstanceImp::get): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::put): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::hasProperty): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::deleteProperty): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::setLength): Added. Used by the above to resize the array.
(ArrayInstanceImp::mark): Mark the elements of the array too.
(ArrayPrototypeImp::ArrayPrototypeImp): Pass the length to the array instance constructor.
* kjs/bool_object.cpp:
* kjs/date_object.cpp:
* kjs/error_object.cpp:
* kjs/function.cpp:
* kjs/function_object.cpp:
* kjs/math_object.cpp:
* kjs/nodes.cpp:
* kjs/nodes.h:
* kjs/number_object.cpp:
* kjs/object_object.cpp:
* kjs/regexp_object.cpp:
* kjs/string_object.cpp:
* kjs/nodes2string.cpp: (SourceStream::operator<<): Add a special case for char now that
you can't create a UString from a char implicitly.
* kjs/object.h:
* kjs/object.cpp:
(ObjectImp::get): Call through to the string version if the numeric version is not implemented.
(ObjectImp::put): Call through to the string version if the numeric version is not implemented.
(ObjectImp::hasProperty): Call through to the string version if the numeric version is not implemented.
(ObjectImp::deleteProperty): Call through to the string version if the numeric version is not implemented.
* kjs/types.h:
* kjs/types.cpp:
(Reference::Reference): Added constructors for the numeric property name case.
* kjs/ustring.h: Made the constructor that turns a character into a string be explicit so we
don't get numbers that turn themselves into strings.
* kjs/ustring.cpp:
(UString::UString): Detect the empty string case, and use a shared empty string.
(UString::find): Add an overload for single character finds.
(UString::rfind): Add an overload for single character finds.
(KJS::operator==): Fix bug where it would call strlen(0) if the first string was not null.
Also handle non-ASCII characters consistently with the rest of the code by casting to unsigned char
just in case.
* kjs/value.h: Make ValueImp and all subclasses non-copyable and non-assignable.
* kjs/value.cpp:
(ValueImp::toUInt32): New interface, mainly useful so we can detect array indices and not turn
them into strings and back.
(ValueImp::toInteger): Use the new toUInt32. Probably can use more improvement.
(ValueImp::toInt32): Use the new toUInt32. Probably can use more improvement.
(ValueImp::toUInt16): Use the new toUInt32. Probably can use more improvement.
(ValueImp::getBase): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::getPropertyName): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::getValue): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::putValue): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::deleteValue): Added. Used so we can do delete the same way we do put.
=== Alexander-17 ===
2002-08-09 Darin Adler <darin@apple.com>
......
2002-08-12 Darin Adler <darin@apple.com>
Speed improvements. 19% faster on cvs-js-performance, 1% on cvs-static-urls.
Use global string objects for length and other common property names rather
than constantly making and destroying them. Use integer versions of get() and
other related calls rather than always making a string.
Also get rid of many unneeded constructors, destructors, copy constructors, and
assignment operators. And make some functions non-virtual.
* kjs/internal.h:
* kjs/internal.cpp:
(NumberImp::toUInt32): Implement.
(ReferenceImp::ReferenceImp): Special case for numeric property names.
(ReferenceImp::getPropertyName): Moved guts here from ValueImp. Handle numeric case.
(ReferenceImp::getValue): Moved guts here from ValueImp. Handle numeric case.
(ReferenceImp::putValue): Moved guts here from ValueImp. Handle numeric case.
(ReferenceImp::deleteValue): Added. Handle numeric case.
* kjs/array_object.h:
* kjs/array_object.cpp: All-new array implementation that stores the elements
in a C++ array rather than in a property map.
(ArrayInstanceImp::ArrayInstanceImp): Allocate the C++ array.
(ArrayInstanceImp::~ArrayInstanceImp): Delete the C++ array.
(ArrayInstanceImp::get): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::put): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::hasProperty): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::deleteProperty): Implement both the old version and the new overload that
takes an unsigned index for speed.
(ArrayInstanceImp::setLength): Added. Used by the above to resize the array.
(ArrayInstanceImp::mark): Mark the elements of the array too.
(ArrayPrototypeImp::ArrayPrototypeImp): Pass the length to the array instance constructor.
* kjs/bool_object.cpp:
* kjs/date_object.cpp:
* kjs/error_object.cpp:
* kjs/function.cpp:
* kjs/function_object.cpp:
* kjs/math_object.cpp:
* kjs/nodes.cpp:
* kjs/nodes.h:
* kjs/number_object.cpp:
* kjs/object_object.cpp:
* kjs/regexp_object.cpp:
* kjs/string_object.cpp:
* kjs/nodes2string.cpp: (SourceStream::operator<<): Add a special case for char now that
you can't create a UString from a char implicitly.
* kjs/object.h:
* kjs/object.cpp:
(ObjectImp::get): Call through to the string version if the numeric version is not implemented.
(ObjectImp::put): Call through to the string version if the numeric version is not implemented.
(ObjectImp::hasProperty): Call through to the string version if the numeric version is not implemented.
(ObjectImp::deleteProperty): Call through to the string version if the numeric version is not implemented.
* kjs/types.h:
* kjs/types.cpp:
(Reference::Reference): Added constructors for the numeric property name case.
* kjs/ustring.h: Made the constructor that turns a character into a string be explicit so we
don't get numbers that turn themselves into strings.
* kjs/ustring.cpp:
(UString::UString): Detect the empty string case, and use a shared empty string.
(UString::find): Add an overload for single character finds.
(UString::rfind): Add an overload for single character finds.
(KJS::operator==): Fix bug where it would call strlen(0) if the first string was not null.
Also handle non-ASCII characters consistently with the rest of the code by casting to unsigned char
just in case.
* kjs/value.h: Make ValueImp and all subclasses non-copyable and non-assignable.
* kjs/value.cpp:
(ValueImp::toUInt32): New interface, mainly useful so we can detect array indices and not turn
them into strings and back.
(ValueImp::toInteger): Use the new toUInt32. Probably can use more improvement.
(ValueImp::toInt32): Use the new toUInt32. Probably can use more improvement.
(ValueImp::toUInt16): Use the new toUInt32. Probably can use more improvement.
(ValueImp::getBase): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::getPropertyName): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::getValue): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::putValue): Remove handling of the Reference case. That's in ReferenceImp now.
(ValueImp::deleteValue): Added. Used so we can do delete the same way we do put.
=== Alexander-17 ===
2002-08-09 Darin Adler <darin@apple.com>
......
This diff is collapsed.
......@@ -29,18 +29,32 @@ namespace KJS {
class ArrayInstanceImp : public ObjectImp {
public:
ArrayInstanceImp(const Object &proto);
ArrayInstanceImp(const Object &proto, unsigned initialLength);
ArrayInstanceImp(const Object &proto, const List &initialValues);
~ArrayInstanceImp();
virtual Value get(ExecState *exec, const UString &propertyName) const;
virtual Value get(ExecState *exec, unsigned propertyName) const;
virtual void put(ExecState *exec, const UString &propertyName, const Value &value, int attr = None);
virtual void putDirect(ExecState *exec, const UString &propertyName, const Value &value, int attr = None);
/**
* A shallow hasProperty() variant that doesn't look at the prototype's
* properties.
*/
virtual bool hasOwnProperty(ExecState *exec, const UString &propertyName);
virtual void put(ExecState *exec, unsigned propertyName, const Value &value, int attr = None);
virtual bool hasProperty(ExecState *exec, const UString &propertyName) const;
virtual bool hasProperty(ExecState *exec, unsigned propertyName) const;
virtual bool deleteProperty(ExecState *exec, const UString &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
virtual void mark();
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
unsigned getLength() const { return length; }
private:
void setLength(unsigned newLength);
unsigned length;
unsigned capacity;
Value *storage;
};
class ArrayPrototypeImp : public ArrayInstanceImp {
......
......@@ -52,8 +52,8 @@ BooleanPrototypeImp::BooleanPrototypeImp(ExecState *exec,
Value protect(this);
// The constructor will be added later by InterpreterImp::InterpreterImp()
put(exec,"toString", Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0)), DontEnum);
put(exec,"valueOf", Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0)), DontEnum);
put(exec,toStringPropertyName, Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0)), DontEnum);
put(exec,valueOfPropertyName, Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0)), DontEnum);
setInternalValue(Boolean(false));
}
......@@ -65,7 +65,7 @@ BooleanProtoFuncImp::BooleanProtoFuncImp(ExecState *exec,
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
}
......@@ -104,10 +104,10 @@ BooleanObjectImp::BooleanObjectImp(ExecState *exec, FunctionPrototypeImp *funcPr
: InternalFunctionImp(funcProto)
{
Value protect(this);
put(exec,"prototype", Object(booleanProto),DontEnum|DontDelete|ReadOnly);
put(exec,prototypePropertyName, Object(booleanProto),DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
put(exec,"length", Number(1), ReadOnly|DontDelete|DontEnum);
put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
}
......
......@@ -147,7 +147,7 @@ DateProtoFuncImp::DateProtoFuncImp(ExecState *exec, int i, int len)
// We use a negative ID to denote the "UTC" variant.
{
Value protect(this);
put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
}
bool DateProtoFuncImp::implementsCall() const
......@@ -321,13 +321,13 @@ DateObjectImp::DateObjectImp(ExecState *exec,
{
Value protect(this);
// ECMA 15.9.4.1 Date.prototype
put(exec,"prototype", Object(dateProto), DontEnum|DontDelete|ReadOnly);
put(exec,prototypePropertyName, Object(dateProto), DontEnum|DontDelete|ReadOnly);
put(exec,"parse", Object(new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::Parse, 1)), DontEnum);
put(exec,"UTC", Object(new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::UTC, 7)), DontEnum);
// no. of arguments for constructor
put(exec,"length", Number(7), ReadOnly|DontDelete|DontEnum);
put(exec,lengthPropertyName, Number(7), ReadOnly|DontDelete|DontEnum);
}
bool DateObjectImp::implementsConstruct() const
......@@ -416,7 +416,7 @@ DateObjectFuncImp::DateObjectFuncImp(ExecState *exec, FunctionPrototypeImp *func
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
}
bool DateObjectFuncImp::implementsCall() const
......
......@@ -43,7 +43,7 @@ ErrorPrototypeImp::ErrorPrototypeImp(ExecState *exec,
put(exec, "name", String("Error"), DontEnum);
put(exec, "message", String("Unknown error"), DontEnum);
put(exec, "toString", Object(new ErrorProtoFuncImp(exec,funcProto)), DontEnum);
put(exec, toStringPropertyName, Object(new ErrorProtoFuncImp(exec,funcProto)), DontEnum);
}
// ------------------------------ ErrorProtoFuncImp ----------------------------
......@@ -52,7 +52,7 @@ ErrorProtoFuncImp::ErrorProtoFuncImp(ExecState *exec, FunctionPrototypeImp *func
: InternalFunctionImp(funcProto)
{
Value protect(this);
put(exec,"length",Number(0),DontDelete|ReadOnly|DontEnum);
put(exec,lengthPropertyName,Number(0),DontDelete|ReadOnly|DontEnum);
}
bool ErrorProtoFuncImp::implementsCall() const
......@@ -86,7 +86,7 @@ ErrorObjectImp::ErrorObjectImp(ExecState *exec, FunctionPrototypeImp *funcProto,
{
Value protect(this);
// ECMA 15.11.3.1 Error.prototype
put(exec, "prototype", Object(errorProto), DontEnum|DontDelete|ReadOnly);
put(exec, prototypePropertyName, Object(errorProto), DontEnum|DontDelete|ReadOnly);
//put(exec, "name", String(n));
}
......@@ -143,8 +143,8 @@ NativeErrorImp::NativeErrorImp(ExecState *exec, FunctionPrototypeImp *funcProto,
Value protect(this);
proto = static_cast<ObjectImp*>(prot.imp());
put(exec,"length",Number(1),DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
put(exec,"prototype",prot);
put(exec,lengthPropertyName,Number(1),DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
put(exec,prototypePropertyName,prot);
}
bool NativeErrorImp::implementsConstruct() const
......
......@@ -274,7 +274,7 @@ bool DeclaredFunctionImp::implementsConstruct() const
Object DeclaredFunctionImp::construct(ExecState *exec, const List &args)
{
Object proto;
Value p = get(exec,"prototype");
Value p = get(exec,prototypePropertyName);
if (p.type() == ObjectType)
proto = Object(static_cast<ObjectImp*>(p.imp()));
else
......@@ -314,11 +314,11 @@ ArgumentsImp::ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args)
{
Value protect(this);
put(exec,"callee", Object(func), DontEnum);
put(exec,"length", Number(args.size()), DontEnum);
put(exec,lengthPropertyName, Number(args.size()), DontEnum);
if (!args.isEmpty()) {
ListIterator arg = args.begin();
for (int i = 0; arg != args.end(); arg++, i++) {
put(exec,UString::from(i), *arg, DontEnum);
put(exec,i, *arg, DontEnum);
}
}
}
......@@ -348,7 +348,7 @@ GlobalFuncImp::GlobalFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, i
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
}
CodeType GlobalFuncImp::codeType() const
......
......@@ -40,7 +40,7 @@ FunctionPrototypeImp::FunctionPrototypeImp(ExecState *exec)
: InternalFunctionImp(0)
{
Value protect(this);
put(exec, "toString", Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0)), DontEnum);
put(exec, toStringPropertyName, Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0)), DontEnum);
put(exec, "apply", Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Apply, 2)), DontEnum);
put(exec, "call", Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Call, 1)), DontEnum);
}
......@@ -67,7 +67,7 @@ FunctionProtoFuncImp::FunctionProtoFuncImp(ExecState *exec,
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
}
......@@ -129,9 +129,9 @@ Value FunctionProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &a
Object::dynamicCast(argArray).inherits(&ArgumentsImp::info)) {
Object argArrayObj = Object::dynamicCast(argArray);
unsigned int length = argArrayObj.get(exec,"length").toUInt32(exec);
unsigned int length = argArrayObj.get(exec,lengthPropertyName).toUInt32(exec);
for (unsigned int i = 0; i < length; i++)
applyArgs.append(argArrayObj.get(exec,UString::from(i)));
applyArgs.append(argArrayObj.get(exec,i));
}
else {
Object err = Error::create(exec,TypeError);
......@@ -174,10 +174,10 @@ FunctionObjectImp::FunctionObjectImp(ExecState *exec, FunctionPrototypeImp *func
: InternalFunctionImp(funcProto)
{
Value protect(this);
put(exec,"prototype", Object(funcProto), DontEnum|DontDelete|ReadOnly);
put(exec,prototypePropertyName, Object(funcProto), DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
put(exec,"length", Number(1), ReadOnly|DontDelete|DontEnum);
put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
}
FunctionObjectImp::~FunctionObjectImp()
......@@ -275,14 +275,14 @@ Object FunctionObjectImp::construct(ExecState *exec, const List &args)
return err;
}
fimp->put(exec,"length", Number(params),ReadOnly|DontDelete|DontEnum);
fimp->put(exec,lengthPropertyName, Number(params),ReadOnly|DontDelete|DontEnum);
List consArgs;
Object objCons = exec->interpreter()->builtinObject();
Object prototype = objCons.construct(exec,List::empty());
prototype.put(exec, "constructor",
Object(fimp), DontEnum|DontDelete|ReadOnly);
fimp->put(exec,"prototype",prototype,DontEnum|DontDelete|ReadOnly);
fimp->put(exec,prototypePropertyName,prototype,DontEnum|DontDelete|ReadOnly);
fimp->put(exec,"arguments",Null(),DontEnum|DontDelete|ReadOnly);
return ret;
}
......
......@@ -192,11 +192,6 @@ Object BooleanImp::toObject(ExecState *exec) const
// ------------------------------ StringImp ------------------------------------
StringImp::StringImp(const UString& v)
: val(v)
{
}
Value StringImp::toPrimitive(ExecState */*exec*/, Type) const
{
return Value((ValueImp*)this);
......@@ -220,17 +215,12 @@ UString StringImp::toString(ExecState */*exec*/) const
Object StringImp::toObject(ExecState *exec) const
{
List args;
args.append(String(const_cast<StringImp*>(this)));
args.append(Value(const_cast<StringImp*>(this)));
return Object::dynamicCast(exec->interpreter()->builtinString().construct(exec,args));
}
// ------------------------------ NumberImp ------------------------------------
NumberImp::NumberImp(double v)
: val(v)
{
}
Value NumberImp::toPrimitive(ExecState *, Type) const
{
return Number((NumberImp*)this);
......@@ -258,10 +248,21 @@ Object NumberImp::toObject(ExecState *exec) const
return Object::dynamicCast(exec->interpreter()->builtinNumber().construct(exec,args));
}
bool NumberImp::toUInt32(unsigned& uint32) const
{
uint32 = (unsigned)val;
return (double)uint32 == val;
}
// ------------------------------ ReferenceImp ---------------------------------
ReferenceImp::ReferenceImp(const Value& v, unsigned p)
: base(v.imp()), propertyNameIsNumber(true), propertyNameAsNumber(p)
{
}
ReferenceImp::ReferenceImp(const Value& v, const UString& p)
: base(v.imp()), prop(p)
: base(v.imp()), propertyNameIsNumber(false), prop(p)
{
}
......@@ -307,6 +308,65 @@ Object ReferenceImp::toObject(ExecState */*exec*/) const
return Object();
}
UString ReferenceImp::getPropertyName(ExecState *) const
{
if (propertyNameIsNumber && prop.isNull())
prop = UString::from(propertyNameAsNumber);
return prop;
}
Value ReferenceImp::getValue(ExecState *exec) const
{
Value o = getBase(exec);
if (o.isNull() || o.type() == NullType) {
UString m = I18N_NOOP("Can't find variable: ") + getPropertyName(exec);
Object err = Error::create(exec, ReferenceError, m.ascii());
exec->setException(err);
return err;
}
if (o.type() != ObjectType) {
UString m = I18N_NOOP("Base is not an object");
Object err = Error::create(exec, ReferenceError, m.ascii());
exec->setException(err);
return err;
}
if (propertyNameIsNumber)
return static_cast<ObjectImp*>(o.imp())->get(exec,propertyNameAsNumber);
return static_cast<ObjectImp*>(o.imp())->get(exec,prop);
}
void ReferenceImp::putValue(ExecState *exec, const Value& w)
{
#ifdef KJS_VERBOSE
printInfo(exec,(UString("setting property ")+getPropertyName(exec)).cstring().c_str(),w);
#endif
Value o = getBase(exec);
if (o.type() == NullType)
o = exec->interpreter()->globalObject();
if (propertyNameIsNumber)
return static_cast<ObjectImp*>(o.imp())->put(exec,propertyNameAsNumber, w);
return static_cast<ObjectImp*>(o.imp())->put(exec,prop, w);
}
bool ReferenceImp::deleteValue(ExecState *exec)
{
Value b = getBase(exec);
// The spec doesn't mention what to do if the base is null... just return true
if (b.type() != ObjectType) {
assert(b.type() == NullType);
return true;
}
if (propertyNameIsNumber)
return static_cast<ObjectImp*>(