1e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block/*
2e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * Copyright (C) 2010 Apple Inc. All rights reserved.
3e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block *
4e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * Redistribution and use in source and binary forms, with or without
5e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * modification, are permitted provided that the following conditions
6e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * are met:
7e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * 1. Redistributions of source code must retain the above copyright
8e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block *    notice, this list of conditions and the following disclaimer.
9e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * 2. Redistributions in binary form must reproduce the above copyright
10e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block *    notice, this list of conditions and the following disclaimer in the
11e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block *    documentation and/or other materials provided with the distribution.
12e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block *
13e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * THE POSSIBILITY OF SUCH DAMAGE.
24e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block */
25e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block
26e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block#include "config.h"
27e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block#include "JSObjectWithGlobalObject.h"
28e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block
29e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block#include "JSGlobalObject.h"
30e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block
31e78cbe89e6f337f2f1fe40315be88f742b547151Steve Blocknamespace JSC {
32e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block
332daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben MurdochJSObjectWithGlobalObject::JSObjectWithGlobalObject(JSGlobalObject* globalObject, Structure* structure)
342daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch    : JSNonFinalObject(globalObject->globalData(), structure)
35e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block{
36e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block    COMPILE_ASSERT(AnonymousSlotCount == 1, AnonymousSlotCount_must_be_one);
37e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block    ASSERT(!globalObject || globalObject->isGlobalObject());
382fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    if (!globalObject)
392fc2651226baac27029e38c9d6ef883fa32084dbSteve Block        clearAnonymousValue(GlobalObjectSlot);
402fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    else
412fc2651226baac27029e38c9d6ef883fa32084dbSteve Block        putAnonymousValue(globalObject->globalData(), GlobalObjectSlot, globalObject);
42e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block}
43e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block
442daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben MurdochJSObjectWithGlobalObject::JSObjectWithGlobalObject(JSGlobalData& globalData, JSGlobalObject* globalObject, Structure* structure)
452daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch    : JSNonFinalObject(globalData, structure)
46e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block{
472daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch    COMPILE_ASSERT(AnonymousSlotCount == 1, AnonymousSlotCount_must_be_one);
482daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch    ASSERT(!globalObject || globalObject->isGlobalObject());
492daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch    if (!globalObject)
502daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch        clearAnonymousValue(GlobalObjectSlot);
512daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch    else
522daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch        putAnonymousValue(globalData, GlobalObjectSlot, globalObject);
53e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block}
54e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block
55e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block} // namespace JSC
56