]>
Commit | Line | Data |
---|---|---|
b37bf2e1 A |
1 | /* |
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 | |
6 | * | |
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. | |
11 | * | |
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. | |
16 | * | |
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. | |
21 | * | |
22 | */ | |
23 | ||
24 | #ifndef Activation_h | |
25 | #define Activation_h | |
26 | ||
27 | #include "ExecState.h" | |
28 | #include "JSVariableObject.h" | |
29 | #include "object.h" | |
30 | ||
31 | namespace KJS { | |
32 | ||
33 | class Arguments; | |
34 | class FunctionImp; | |
35 | ||
36 | class ActivationImp : public JSVariableObject { | |
37 | friend class JSGlobalObject; | |
38 | friend struct StackActivation; | |
39 | private: | |
40 | struct ActivationData : public JSVariableObjectData { | |
41 | ActivationData() : isOnStack(true), leftRelic(false) { } | |
42 | ActivationData(const ActivationData&); | |
43 | ||
44 | ExecState* exec; | |
45 | FunctionImp* function; | |
46 | Arguments* argumentsObject; | |
47 | ||
48 | bool isOnStack : 1; | |
49 | bool leftRelic : 1; | |
50 | }; | |
51 | ||
52 | public: | |
53 | ActivationImp() { } | |
54 | ActivationImp(const ActivationData&, bool); | |
55 | ||
56 | virtual ~ActivationImp(); | |
57 | ||
58 | void init(ExecState*); | |
59 | ||
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); | |
63 | ||
64 | virtual const ClassInfo* classInfo() const { return &info; } | |
65 | static const ClassInfo info; | |
66 | ||
67 | virtual void mark(); | |
68 | void markChildren(); | |
69 | ||
70 | virtual bool isActivationObject() { return true; } | |
71 | ||
72 | bool isOnStack() const { return d()->isOnStack; } | |
73 | bool needsPop() const { return d()->isOnStack || d()->leftRelic; } | |
74 | ||
75 | private: | |
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); } | |
80 | }; | |
81 | ||
82 | const size_t activationStackNodeSize = 32; | |
83 | ||
84 | struct StackActivation { | |
85 | StackActivation() { activationStorage.JSVariableObject::d = &activationDataStorage; } | |
86 | StackActivation(const StackActivation&); | |
87 | ||
88 | ActivationImp activationStorage; | |
89 | ActivationImp::ActivationData activationDataStorage; | |
90 | }; | |
91 | ||
92 | struct ActivationStackNode { | |
93 | ActivationStackNode* prev; | |
94 | StackActivation data[activationStackNodeSize]; | |
95 | }; | |
96 | ||
97 | } // namespace | |
98 | ||
99 | #endif |