/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
namespace JSC {
- class JSNotAnObjectErrorStub : public JSObject {
- public:
- JSNotAnObjectErrorStub(ExecState* exec, bool isNull)
- : JSObject(exec->globalData().notAnObjectErrorStubStructure)
- , m_isNull(isNull)
- {
- }
-
- bool isNull() const { return m_isNull; }
-
- private:
- virtual bool isNotAnObjectErrorStub() const { return true; }
-
- bool m_isNull;
- };
-
// This unholy class is used to allow us to avoid multiple exception checks
// in certain SquirrelFish bytecodes -- effectively it just silently consumes
// any operations performed on the result of a failed toObject call.
- class JSNotAnObject : public JSObject {
+ class JSNotAnObject : public JSNonFinalObject {
+ private:
+ JSNotAnObject(ExecState* exec)
+ : JSNonFinalObject(exec->globalData(), exec->globalData().notAnObjectStructure.get())
+ {
+ }
+
public:
- JSNotAnObject(ExecState* exec, JSNotAnObjectErrorStub* exception)
- : JSObject(exec->globalData().notAnObjectStructure)
- , m_exception(exception)
+ typedef JSNonFinalObject Base;
+
+ static JSNotAnObject* create(ExecState* exec)
{
+ JSNotAnObject* object = new (NotNull, allocateCell<JSNotAnObject>(*exec->heap())) JSNotAnObject(exec);
+ object->finishCreation(exec->globalData());
+ return object;
}
- static PassRefPtr<Structure> createStructure(JSValuePtr prototype)
+ static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
- return Structure::create(prototype, TypeInfo(ObjectType));
+ return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
}
+ static const ClassInfo s_info;
+
private:
- // JSValue methods
- virtual JSValuePtr toPrimitive(ExecState*, PreferredPrimitiveType) const;
- virtual bool getPrimitiveNumber(ExecState*, double& number, JSValuePtr&);
- virtual bool toBoolean(ExecState*) const;
- virtual double toNumber(ExecState*) const;
- virtual UString toString(ExecState*) const;
- virtual JSObject* toObject(ExecState*) const;
+
+ static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags;
- // Marking
- virtual void mark();
+ // JSValue methods
+ static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
// JSObject methods
- virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
- virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
-
- virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&);
- virtual void put(ExecState*, unsigned propertyName, JSValuePtr);
+ static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier& propertyName, PropertySlot&);
+ static bool getOwnPropertySlotByIndex(JSCell*, ExecState*, unsigned propertyName, PropertySlot&);
+ static bool getOwnPropertyDescriptor(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&);
- virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
- virtual bool deleteProperty(ExecState*, unsigned propertyName);
+ static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
+ static void putByIndex(JSCell*, ExecState*, unsigned propertyName, JSValue, bool shouldThrow);
- virtual void getPropertyNames(ExecState*, PropertyNameArray&);
+ static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
+ static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned propertyName);
- JSNotAnObjectErrorStub* m_exception;
+ static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
};
} // namespace JSC