1 // -*- mode: c++; c-basic-offset: 4 -*-
3 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
4 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
5 * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
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.
24 #ifndef ExecStateInlines_h
25 #define ExecStateInlines_h
27 #include "ExecState.h"
29 #include "JSGlobalObject.h"
33 inline ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisObject,
34 FunctionBodyNode* functionBodyNode, ExecState* callingExec,
35 FunctionImp* func, const List& args)
36 : m_globalObject(globalObject)
38 , m_propertyNames(callingExec->m_propertyNames)
39 , m_emptyList(callingExec->m_emptyList)
40 , m_callingExec(callingExec)
41 , m_scopeNode(functionBodyNode)
44 , m_scopeChain(func->scope())
45 , m_inlineScopeChainNode(0, 0)
46 , m_thisValue(thisObject)
49 , m_codeType(FunctionCode)
53 ActivationImp* activation = globalObject->pushActivation(this);
54 m_activation = activation;
55 m_localStorage = &activation->localStorage();
56 m_variableObject = activation;
57 if (functionBodyNode->usesEval() || functionBodyNode->needsClosure())
58 m_scopeChain.push(activation);
60 m_inlineScopeChainNode.object = activation;
61 // The ScopeChain will ref this node itself, so we don't need to worry about
62 // anything trying to delete our scopenode
63 m_scopeChain.push(&m_inlineScopeChainNode);
67 inline ExecState::~ExecState()
71 inline FunctionExecState::FunctionExecState(JSGlobalObject* globalObject, JSObject* thisObject,
72 FunctionBodyNode* functionBodyNode, ExecState* callingExec,
73 FunctionImp* func, const List& args)
74 : ExecState(globalObject, thisObject, functionBodyNode, callingExec, func, args)
76 m_globalObject->activeExecStates().append(this);
79 inline FunctionExecState::~FunctionExecState()
81 ASSERT(m_globalObject->activeExecStates().last() == this);
82 m_globalObject->activeExecStates().removeLast();
84 if (m_activation->needsPop())
85 m_globalObject->popActivation();
87 if (m_inlineScopeChainNode.next) {
88 m_scopeChain.popInlineScopeNode();
89 m_inlineScopeChainNode.next = 0;
95 #endif // ExecStateInlines_h