File indexing completed on 2024-12-01 09:50:26

0001 /*
0002  *  This file is part of the KDE libraries
0003  *  Copyright (C) 2006 Matt Broadstone (mbroadst@gmail.com)
0004  *  Copyright (C) 2007 Maksim Orlovich (maksim@kde.org)
0005  *
0006  *  This library is free software; you can redistribute it and/or
0007  *  modify it under the terms of the GNU Library General Public
0008  *  License as published by the Free Software Foundation; either
0009  *  version 2 of the License, or (at your option) any later version.
0010  *
0011  *  This library is distributed in the hope that it will be useful,
0012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  *  Library General Public License for more details.
0015  *
0016  *  You should have received a copy of the GNU Library General Public
0017  *  License along with this library; if not, write to the Free Software
0018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  */
0020 
0021 #include "interpreter_ctx.h"
0022 
0023 namespace KJSDebugger
0024 {
0025 
0026 void InterpreterContext::addCall(DebugDocument::Ptr doc, const QString &function, int lineNumber)
0027 {
0028     CallStackEntry entry;
0029     entry.doc  = doc;
0030     entry.name = function;
0031     entry.lineNumber = lineNumber;
0032 
0033     callStack.append(entry);
0034 }
0035 
0036 void InterpreterContext::removeCall()
0037 {
0038     callStack.pop_back();
0039 }
0040 
0041 void InterpreterContext::updateCall(int line)
0042 {
0043     callStack.last().lineNumber = line;
0044     // Expects displayStack to be called to redraw.
0045 }
0046 
0047 int InterpreterContext::activeLine()
0048 {
0049     return callStack.top().lineNumber;
0050 }
0051 
0052 DebugDocument::Ptr InterpreterContext::activeDocument()
0053 {
0054     return callStack.top().doc;
0055 }
0056 
0057 bool InterpreterContext::hasActiveDocument() const
0058 {
0059     return !callStack.isEmpty();
0060 }
0061 
0062 }
0063