2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)
5 * Copyright (C) 2007 Maks Orlovich
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
27 #include "ExecState.h"
28 #include "JSVariableObject.h"
36 class ActivationImp
: public JSVariableObject
{
37 friend class JSGlobalObject
;
38 friend struct StackActivation
;
40 struct ActivationData
: public JSVariableObjectData
{
41 ActivationData() : isOnStack(true), leftRelic(false) { }
42 ActivationData(const ActivationData
&);
45 FunctionImp
* function
;
46 Arguments
* argumentsObject
;
54 ActivationImp(const ActivationData
&, bool);
56 virtual ~ActivationImp();
58 void init(ExecState
*);
60 virtual bool getOwnPropertySlot(ExecState
*, const Identifier
&, PropertySlot
&);
61 virtual void put(ExecState
*, const Identifier
&, JSValue
*, int attr
= None
);
62 virtual bool deleteProperty(ExecState
*, const Identifier
& propertyName
);
64 virtual const ClassInfo
* classInfo() const { return &info
; }
65 static const ClassInfo info
;
70 virtual bool isActivationObject() { return true; }
72 bool isOnStack() const { return d()->isOnStack
; }
73 bool needsPop() const { return d()->isOnStack
|| d()->leftRelic
; }
76 static PropertySlot::GetValueFunc
getArgumentsGetter();
77 static JSValue
* argumentsGetter(ExecState
*, JSObject
*, const Identifier
&, const PropertySlot
&);
78 void createArgumentsObject(ExecState
*);
79 ActivationData
* d() const { return static_cast<ActivationData
*>(JSVariableObject::d
); }
82 const size_t activationStackNodeSize
= 32;
84 struct StackActivation
{
85 StackActivation() { activationStorage
.JSVariableObject::d
= &activationDataStorage
; }
86 StackActivation(const StackActivation
&);
88 ActivationImp activationStorage
;
89 ActivationImp::ActivationData activationDataStorage
;
92 struct ActivationStackNode
{
93 ActivationStackNode
* prev
;
94 StackActivation data
[activationStackNodeSize
];