-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParameterList.cpp
More file actions
60 lines (41 loc) · 2 KB
/
ParameterList.cpp
File metadata and controls
60 lines (41 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Created by David Ehley, Jesse Karakash, Aaron Diaz, Abel Rodarte on 2/1/18.
// Current Compiler for Stage 1 and Stage 2
// Assignment 5
// 5-4-2018
#include <iostream>
#include <iomanip>
#include "ParameterList.h"
/* note a vector is used here instead of a unordered map in order to maintain the
order of the parameters */
void ParameterList::add(SymTab *node) {
// add the table data we got from treenode.cpp into the vector
vecMap.push_back(node);
}
void ParameterList::printVec(string str) {
vector<SymTab *>::iterator vecIT = vecMap.begin(); // initializing the vector iterator
int countVec =0; // keeps track of what vector row we are currently in
bool checkIsEmpty = true; //boolean to check if there are parameters or not
//iterating through the vector
while (vecIT != vecMap.end()){
//comparing scopes
if (str == vecMap[countVec]->scope) {
//this makes sure the parameter label only gets printed out once per function
if(checkIsEmpty == true){
cout << "Parameters" << endl;
cout << "Name Type Size Scope Address" << endl;
//if we got this far, there are parameters so flip the checker
checkIsEmpty = false;
}
//print out the row with formatting added
cout << left << setw(12) << vecMap[countVec]->name << left << setw(12) << vecMap[countVec]->type
<< left << setw(12) << vecMap[countVec]->size << left << setw(12) << vecMap[countVec]->scope
<< left << setw(12) << vecMap[countVec]->address << endl;
}
countVec++; //move to the next entry
vecIT++; // advance the iterator
}
// if checkIsEmpty hasnt been flipped by this point, there are no parameters for the function
if(checkIsEmpty == true){
cout<< "Parameters -- Parameter list is empty for this function" << endl;
}
}