context.h
00001 // -*- c-basic-offset: 2 -*- 00002 /* 00003 * This file is part of the KDE libraries 00004 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 00005 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 00006 * Copyright (C) 2003 Apple Computer, Inc. 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Library General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Library General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Library General Public License 00019 * along with this library; see the file COPYING.LIB. If not, write to 00020 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 * Boston, MA 02110-1301, USA. 00022 * 00023 */ 00024 00025 #ifndef KJS_CONTEXT_H 00026 #define KJS_CONTEXT_H 00027 00028 #include "function.h" 00029 00030 namespace KJS { 00031 00035 class ContextImp { 00036 friend class Context; 00037 friend class StatementNode; 00038 public: 00039 // TODO: remove glob parameter. deducable from exec. 00040 ContextImp(Object &glob, InterpreterImp *interpreter, Object &thisV, int _sourceId, CodeType type = GlobalCode, 00041 ContextImp *callingContext = 0L, FunctionImp *func = 0L, const List *args = 0); 00042 virtual ~ContextImp(); 00043 00044 const ScopeChain &scopeChain() const { return scope; } 00045 CodeType codeType() const { return m_codeType; } 00046 Object variableObject() const { return variable; } 00047 void setVariableObject(const Object &v) { variable = v; } 00048 Object thisValue() const { return thisVal; } 00049 ContextImp *callingContext() { return _callingContext; } 00050 ObjectImp *activationObject() { return activation.imp(); } 00051 FunctionImp *function() const { return _function; } 00052 const List *arguments() const { return _arguments; } 00053 00054 void pushScope(const Object &s) { scope.push(s.imp()); } 00055 void popScope() { scope.pop(); } 00056 LabelStack *seenLabels() { return &ls; } 00057 00058 void mark(); 00059 00060 void pushTryCatch() { tryCatch++; }; 00061 void popTryCatch() { tryCatch--; }; 00062 bool inTryCatch() const; 00063 00064 void setLines(int l0, int l1) { line0 = l0; line1 = l1; } 00065 00066 private: 00067 InterpreterImp *_interpreter; 00068 ContextImp *_callingContext; 00069 FunctionImp *_function; 00070 const List *_arguments; 00071 Object activation; 00072 00073 ScopeChain scope; 00074 Object variable; 00075 Object thisVal; 00076 00077 LabelStack ls; 00078 CodeType m_codeType; 00079 00080 int tryCatch; 00081 int sourceId; 00082 int line0; 00083 int line1; 00084 Identifier functionName; 00085 List args; 00086 }; 00087 00088 } // namespace KJS 00089 00090 #endif