Debian Codegraph @

cpupane.h

raw symbols SCIP
1 // File: cpupane.h
2 /*
3 Pep8-1 is a virtual machine for writing machine language and assembly
4 language programs.
5
6 Copyright (C) 2009 J. Stanley Warford, Pepperdine University
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program 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
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef CPUPANE_H
23 #define CPUPANE_H
24
25 #include <QWidget>
26 #include "enu.h"
27
28 namespace Ui {
29 class CpuPane;
30 }
31
32 class CpuPane : public QWidget {
33 Q_OBJECT
34 Q_DISABLE_COPY(CpuPane)
35 public:
36 explicit CpuPane(QWidget *parent = 0);
37 virtual ~CpuPane();
38
39 void updateCpu();
40 // Post: Updates CPU pane labels
41
42 void clearCpu();
43 // Post: The CPU pane labels are blanked and the CPU registers are cleared
44
45 void runClicked();
46 // Post: All of the debug checkboxes are unclicked
47
48 void setDebugState(bool b);
49 // Post: if b is true, checkboxes are set to disabled, and vice versa
50
51 void traceTraps(bool b);
52 // Post: Trace traps checkbox is checked if b, unchecked else
53
54 void setButtonsEnabled(bool b);
55 // Post: if b is true, buttons are enabled, and vice versa
56
57 void runWithBatch();
58 // Runs the simulator through with batch input
59
60 void runWithTerminal();
61 // Runs the simulator through with terminal i/o
62
63 void resumeWithBatch();
64 // Resumes the simulator with batch input
65
66 void resumeWithTerminal();
67 // Resumes the simulator with terminal input
68
69 void singleStepWithBatch();
70 // Single steps the simulator with batch input
71
72 void singleStepWithTerminal();
73 // Single steps the simulator with terminal input
74
75 void trapLookahead();
76 // Looks ahead to the next instruction to determine if we are trapping
77
78 void interruptExecution();
79 // Post: interruptExecutionFlag is set to true
80
81 void highlightOnFocus();
82 // Post: Highlights the label based on the label window color saved in the UI file
83
84 Enu::EWaiting waitingState();
85 // Post: Returns the waiting state of the simulation (for terminal io)
86
87 bool singleStepHasFocus();
88 // Post: returns if the single step is enabled
89
90 bool hasFocus();
91 // Post: Returns if the single step button has focus
92
93 bool isSimulating();
94 // Returns if the CPU is currently simulating - this can happen when the enter key is
95 // held down to single step quickly, causing multiple enter events to fire per single step
96 // This is used to avoid that.
97
98 void giveSingleStepFocus();
99 // Gives the single step button focus - this is used when we press 'enter' in other panes
100 // and we want to give the cpu pane focus for ease of navigation
101
102 private:
103 Ui::CpuPane *ui;
104
105 bool interruptExecutionFlag; // Used to interrupt execution by the user
106
107 Enu::EWaiting waiting; // Used to store terminal IO waiting for input state
108
109 void mousePressEvent(QMouseEvent *);
110
111 bool isCurrentlySimulating;
112
113 private slots:
114 void singleStepButton();
115
116 signals:
117 void resumeButtonClicked();
118 void singleStepButtonClicked();
119 void updateSimulationView();
120 void executionComplete();
121 void appendOutput(QString);
122 void vonNeumannStepped();
123 void waitingForInput();
124 };
125
126 #endif // CPUPANE_H