Debian Codegraph @

stackframefsm.cpp

raw symbols SCIP
1 // StackFrameFSM.cpp: implementation of the StackFrameFSM class.cxx . . $ `<file>/stackframefsm.cpp`/
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 #include "stackframefsm.h"cxx . . $ `<file>/stackframefsm.h`/
23 #include "sim.h"cxx . . $ `<file>/sim.h`/
24 #include "pep.h"cxx . . $ `<file>/pep.h`/
25
26 // #include <QDebug>
27
28 StackFrameFSMcxx . . $ StackFrameFSM#::StackFrameFSMcxx . . $ StackFrameFSM#StackFrameFSM(49f6e7a06ebc5aa8).()
29 {
30
31 }
32
33 void StackFrameFSMcxx . . $ StackFrameFSM#::resetcxx . . $ StackFrameFSM#reset(49f6e7a06ebc5aa8).()
34 {
35 stackStatecxx . . $ StackFrameFSM#stackState. = EStartcxx . . $ StackFrameFSM#EStart.;
36 numCellsFromSubSPcxx . . $ StackFrameFSM#numCellsFromSubSP. = 0;
37 numCellsFromCallcxx . . $ StackFrameFSM#numCellsFromCall. = 0;
38 }
39
40 // the states: EStart, ESubSP, ECall
41
42 int StackFrameFSMcxx . . $ StackFrameFSM#::makeTransitioncxx . . $ StackFrameFSM#makeTransition(7864480464b09eea).(int numCellsToAdd)
43 {
44 Enucxx . . $ Enu/::EMnemoniccxx . . $ Enu/EMnemonic# mnemon = Pepcxx . . $ Pep#::decodeMnemoniccxx . . $ Pep#decodeMnemonic.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).Simcxx . . $ Sim#::instructionSpecifiercxx . . $ Sim#instructionSpecifier.];
45
46 switch(stackStatecxx . . $ StackFrameFSM#stackState.)
47 {
48 case(EStartcxx . . $ StackFrameFSM#EStart.):
49 if (mnemon == Enucxx . . $ Enu/::SUBSPcxx . . $ Enu/SUBSP.) {
50 numCellsFromSubSPcxx . . $ StackFrameFSM#numCellsFromSubSP. = numCellsToAdd;
51 stackStatecxx . . $ StackFrameFSM#stackState. = ESubSPcxx . . $ StackFrameFSM#ESubSP.;
52 }
53 else if (mnemon == Enucxx . . $ Enu/::CALLcxx . . $ Enu/CALL.) {
54 numCellsFromSubSPcxx . . $ StackFrameFSM#numCellsFromSubSP. = 0;
55 numCellsFromCallcxx . . $ StackFrameFSM#numCellsFromCall. = 1; // = numCellsToAdd; // ECall = 1
56 stackStatecxx . . $ StackFrameFSM#stackState. = ECallcxx . . $ StackFrameFSM#ECall.;
57 }
58 break;
59 case(ESubSPcxx . . $ StackFrameFSM#ESubSP.):
60 if (mnemon == Enucxx . . $ Enu/::CALLcxx . . $ Enu/CALL.) {
61 numCellsFromCallcxx . . $ StackFrameFSM#numCellsFromCall. = 1; // = numCellsToAdd; // ECall = 1
62 stackStatecxx . . $ StackFrameFSM#stackState. = ECallcxx . . $ StackFrameFSM#ECall.;
63 }
64 else { // not ECall
65 stackStatecxx . . $ StackFrameFSM#stackState. = EStartcxx . . $ StackFrameFSM#EStart.;
66 return numCellsFromSubSPcxx . . $ StackFrameFSM#numCellsFromSubSP.; // lone subsp
67 }
68 break;
69 case(ECallcxx . . $ StackFrameFSM#ECall.):
70 if (mnemon == Enucxx . . $ Enu/::SUBSPcxx . . $ Enu/SUBSP.) { // function with 1 or more locals and 0 or more parameters
71 stackStatecxx . . $ StackFrameFSM#stackState. = EStartcxx . . $ StackFrameFSM#EStart.;
72 return (numCellsFromSubSPcxx . . $ StackFrameFSM#numCellsFromSubSP. + numCellsFromCallcxx . . $ StackFrameFSM#numCellsFromCall. + numCellsToAdd);
73 }
74 else { // not ESubSP
75 stackStatecxx . . $ StackFrameFSM#stackState. = EStartcxx . . $ StackFrameFSM#EStart.; // no locals
76 return (numCellsFromSubSPcxx . . $ StackFrameFSM#numCellsFromSubSP. + numCellsFromCallcxx . . $ StackFrameFSM#numCellsFromCall.);
77 }
78 break;
79 default:;
80 }
81 return 0; // don't add a frame yet
82 }