1 | // -*- c-basic-offset: 2 -*-
|
---|
2 | /*
|
---|
3 | * This file is part of the KDE libraries
|
---|
4 | * Copyright (C) 1999-2001 Harri Porten ([email protected])
|
---|
5 | * Copyright (C) 2001 Peter Kelly ([email protected])
|
---|
6 | * Copyright (C) 2003 Apple Computer, Inc.
|
---|
7 | *
|
---|
8 | * This library is free software; you can redistribute it and/or
|
---|
9 | * modify it under the terms of the GNU Library General Public
|
---|
10 | * License as published by the Free Software Foundation; either
|
---|
11 | * version 2 of the License, or (at your option) any later version.
|
---|
12 | *
|
---|
13 | * This library is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
16 | * Library General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU Library General Public License
|
---|
19 | * along with this library; see the file COPYING.LIB. If not, write to
|
---|
20 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
---|
21 | * Boston, MA 02110-1301, USA.
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef KJS_CONTEXT_H
|
---|
26 | #define KJS_CONTEXT_H
|
---|
27 |
|
---|
28 | #include "function.h"
|
---|
29 | #include "protect.h"
|
---|
30 |
|
---|
31 | namespace KJS {
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * @short Execution context.
|
---|
35 | */
|
---|
36 | class ContextImp {
|
---|
37 | public:
|
---|
38 | ContextImp(JSObject *glob, InterpreterImp *, JSObject *thisV, CodeType type = GlobalCode,
|
---|
39 | ContextImp *callingContext = 0, FunctionImp *functiion = 0, const List *args = 0);
|
---|
40 | ~ContextImp();
|
---|
41 |
|
---|
42 | const ScopeChain &scopeChain() const { return scope; }
|
---|
43 | CodeType codeType() { return m_codeType; }
|
---|
44 | JSObject *variableObject() const { return variable; }
|
---|
45 | void setVariableObject(JSObject *v) { variable = v; }
|
---|
46 | JSObject *thisValue() const { return thisVal; }
|
---|
47 | ContextImp *callingContext() { return _callingContext; }
|
---|
48 | JSObject *activationObject() { return activation; }
|
---|
49 | FunctionImp *function() const { return _function; }
|
---|
50 | const List *arguments() const { return _arguments; }
|
---|
51 |
|
---|
52 | void pushScope(JSObject *s) { scope.push(s); }
|
---|
53 | void popScope() { scope.pop(); }
|
---|
54 | LabelStack *seenLabels() { return &ls; }
|
---|
55 |
|
---|
56 | void mark();
|
---|
57 |
|
---|
58 | private:
|
---|
59 | InterpreterImp *_interpreter;
|
---|
60 | ContextImp *_callingContext;
|
---|
61 | FunctionImp *_function;
|
---|
62 | const List *_arguments;
|
---|
63 | // because ContextImp is always allocated on the stack,
|
---|
64 | // there is no need to protect various pointers from conservative
|
---|
65 | // GC since they will be caught by the conservative sweep anyway!
|
---|
66 | JSObject *activation;
|
---|
67 |
|
---|
68 | ScopeChain scope;
|
---|
69 | JSObject *variable;
|
---|
70 | JSObject *thisVal;
|
---|
71 |
|
---|
72 | LabelStack ls;
|
---|
73 | CodeType m_codeType;
|
---|
74 | };
|
---|
75 |
|
---|
76 | } // namespace KJS
|
---|
77 |
|
---|
78 | #endif
|
---|