KHtml

interpreter_ctx.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2006 Matt Broadstone ([email protected])
4  * Copyright (C) 2007 Maksim Orlovich ([email protected])
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 #ifndef KJSDBG_ICTX_H
21 #define KJSDBG_ICTX_H
22 
23 #include <QStack>
24 #include <QString>
25 #include "debugdocument.h"
26 
27 namespace KJS
28 {
29 class ExecState;
30 }
31 
32 namespace KTextEditor
33 {
34 class MarkInterface;
35 }
36 
37 namespace KJSDebugger
38 {
39 
40 enum Mode {
41  Normal = 0, // Only stop at breakpoints
42  StepOver = 1, // Will break on next statement in current context
43  StepOut = 2, // Will break one or more contexts above.
44  Step = 3, // Will break on next statement in current or deeper context
45  Abort = 4 // The script will stop execution completely,
46  // as soon as possible
47 };
48 
49 struct CallStackEntry {
50  QString name;
51  int lineNumber;
52  DebugDocument::Ptr doc;
53 
54  bool operator==(const CallStackEntry &other) const
55  {
56  return ((other.name == name) &&
57  (other.lineNumber == lineNumber) &&
58  (other.doc == doc));
59  }
60 };
61 
62 // This contains information we have to keep track of per-interpreter,
63 // such as the stack information.
64 struct InterpreterContext {
65  Mode mode;
66  QStack<KJS::ExecState *> execContexts;
67  int depthAtSkip; // How far we were in on stepOut
68  // our stepOver.
69  QStack<CallStackEntry> callStack;
70 
71  // Document and line we're currently in
72  DebugDocument::Ptr activeDocument();
73  int activeLine();
74 
75  bool hasActiveDocument() const;
76 
77  InterpreterContext() : mode(Normal), depthAtSkip(0)
78  {}
79 
80  /**
81  * add a new entry to the call stack
82  *
83  * @param doc the document the function is in
84  * @param function the function called
85  * @param line the line number of the function
86  */
87  void addCall(DebugDocument::Ptr doc, const QString &function, int line);
88  /**
89  * update the line number of the current context
90  *
91  * @param line the new line number within the current function
92  */
93  void updateCall(int line);
94  void removeCall();
95 
96 };
97 
98 }
99 
100 #endif
101 
QString name(const QVariant &location)
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.