Permalink
Browse files

Refactoring. Includes some previous changes that were not committed.

  • Loading branch information...
franapoli committed Oct 26, 2012
1 parent 56c8d8a commit dfdf4dd2ecc5db9a61aa8769b93a9fb73a2e60cb
Showing with 1,021 additions and 3,944 deletions.
  1. +79 −79 AdjMatrix.cpp
  2. +4 −2 AdjMatrix.h
  3. +6 −2 CallStack.h
  4. +19 −23 Edge.cpp
  5. +20 −9 Edge.h
  6. +43 −58 Edgeset.cpp
  7. +2 −2 Edgeset.h
  8. +17 −13 Environment.h
  9. +220 −215 Frame.cpp
  10. +12 −11 Frame.h
  11. +158 −191 Graph.cpp
  12. +42 −30 Graph.h
  13. +63 −77 Linkable.cpp
  14. +34 −29 Linkable.h
  15. +14 −16 NameSpace.cpp
  16. +13 −10 NameSpace.h
  17. +49 −47 Node.cpp
  18. +91 −84 Node.h
  19. +55 −72 Nodeset.cpp
  20. +39 −22 Nodeset.h
  21. +17 −13 SymbolTable.h
  22. +0 −50 dapsl.ll
  23. +0 −2,100 dapsl.tab.cc
  24. +0 −61 dapsl.tab.hh
  25. +0 −168 dapsl.yy
  26. +2 −7 globals.h
  27. +22 −25 main.cc → main.cpp
  28. +0 −24 main.h
  29. +0 −435 nodes.cc
  30. +0 −69 nodes.h
View
@@ -15,100 +15,100 @@ using namespace std;
AdjMatrix::AdjMatrix() {
// TODO Auto-generated constructor stub
-
}
AdjMatrix::~AdjMatrix() {
- for(int i=0;i<_n;i++)
+ for (int i = 0; i < _n; i++)
delete (*_mat)[i];
delete *_mat;
delete _mat;
}
AdjMatrix::AdjMatrix(int n, int m) {
- _n=n;
- _m=m;
- _mat= new int **;
- (*_mat)= new int *[n];
-
- for(int i=0;i<n;i++) {
- (*_mat)[i]=new int [m];
- for(int j=0;j<m;j++)
- (*_mat)[i][j]=0;
- }
+ _n = n;
+ _m = m;
+ _mat = new int **;
+ (*_mat) = new int *[n];
+
+ for (int i = 0; i < n; i++) {
+ (*_mat)[i] = new int[m];
+ for (int j = 0; j < m; j++)
+ (*_mat)[i][j] = 0;
+ }
}
/* THE FOLLOWING WORKS BUT NOW THE SAME IS DONE IN Graph.cpp
-void AdjMatrix::toDot(Nodeset &Ns, string fname) {
- FILE *fid;
- Nodeset::iterator i;
- Nodeset::iterator j;
- int ii=0, ij=0;
- fid=fopen((string(fname)).c_str(), "w");
- string attr_string="";
- std::map<std::string, std::string>::iterator mapit;
- std::map<std::string, std::string> attribs;
-
- fprintf(fid, "digraph G {\n");
- fprintf(fid, "node [shape=box, style=rounded];\n");
- fprintf(fid, "rankdir=LR;\n");
-
-
-
- for(i=Ns.begin(); i!=Ns.end(); ++i){
- attr_string = "[ label = ";
- attr_string += i->getName();
-
- attribs = i->GetAttributes();
- for(mapit = attribs.begin(); mapit!=attribs.end(); mapit++){
- attr_string += ", ";
- attr_string += (mapit -> first).c_str();
- attr_string += " = ";
- attr_string += (mapit -> second).c_str();
- }
- attr_string += "] ";
-
- fprintf(fid, "%d %s;\n", i->getId(), attr_string.c_str());
- //fprintf(fid, "%d [ label = \"%s\", color = \"%s\" ];\n", i->getId(), i->getName().c_str(), i->GetAttribute("color").c_str());
-
-
- }
-
-
- for (ii=0, i=Ns.begin(); ii<_n; ++ii, ++i){ // process ARCs
- for (ij=0; ij<_m; ++ij) {
- if((*_mat)[ii][ij]) {
- bool found = false;
- attribs = i->GetAttributes();
- for(mapit = attribs.begin(); mapit!=attribs.end(); mapit++){
- if(mapit->first == "LEAF_FLAGS" && mapit->second == "F") {
- fprintf(fid, "%d->%d [arrowhead = \"empty\"];\n", ii, ij);
- found = true;
- }
- }
- if (!found)
- fprintf(fid, "%d->%d;\n", ii, ij);
- }
- }
- }
- fprintf(fid, "}");
- fclose(fid);
-
-
-}
-*/
-void AdjMatrix::Set(unsigned i, unsigned j)
-{
- (*_mat)[i][j]=1;
+ void AdjMatrix::toDot(Nodeset &Ns, string fname) {
+ FILE *fid;
+ Nodeset::iterator i;
+ Nodeset::iterator j;
+ int ii=0, ij=0;
+ fid=fopen((string(fname)).c_str(), "w");
+ string attr_string="";
+ std::map<std::string, std::string>::iterator mapit;
+ std::map<std::string, std::string> attribs;
+
+ fprintf(fid, "digraph G {\n");
+ fprintf(fid, "node [shape=box, style=rounded];\n");
+ fprintf(fid, "rankdir=LR;\n");
+
+
+
+ for(i=Ns.begin(); i!=Ns.end(); ++i){
+ attr_string = "[ label = ";
+ attr_string += i->getName();
+
+ attribs = i->GetAttributes();
+ for(mapit = attribs.begin(); mapit!=attribs.end(); mapit++){
+ attr_string += ", ";
+ attr_string += (mapit -> first).c_str();
+ attr_string += " = ";
+ attr_string += (mapit -> second).c_str();
+ }
+ attr_string += "] ";
+
+ fprintf(fid, "%d %s;\n", i->getId(), attr_string.c_str());
+ //fprintf(fid, "%d [ label = \"%s\", color = \"%s\" ];\n", i->getId(), i->getName().c_str(), i->GetAttribute("color").c_str());
+
+
+ }
+
+
+ for (ii=0, i=Ns.begin(); ii<_n; ++ii, ++i){ // process ARCs
+ for (ij=0; ij<_m; ++ij) {
+ if((*_mat)[ii][ij]) {
+ bool found = false;
+ attribs = i->GetAttributes();
+ for(mapit = attribs.begin(); mapit!=attribs.end(); mapit++){
+ if(mapit->first == "LEAF_FLAGS" && mapit->second == "F") {
+ fprintf(fid, "%d->%d [arrowhead = \"empty\"];\n", ii, ij);
+ found = true;
+ }
+ }
+ if (!found)
+ fprintf(fid, "%d->%d;\n", ii, ij);
+ }
+ }
+ }
+ fprintf(fid, "}");
+ fclose(fid);
+
+
+ }
+ */
+void AdjMatrix::set(unsigned i, unsigned j) {
+ (*_mat)[i][j] = 1;
}
-ostream& AdjMatrix::operator>>(std::ostream &){
- int j,i;
+ostream& AdjMatrix::operator>>(std::ostream &o) {
+ int j, i;
- for(i=0; i<_n; i++){
- for(j=0; j<_m-1; j++)
- cout << (*_mat)[i][j] << ",";
- cout <<(*_mat)[i][j] << endl;
+ for (i = 0; i < _n; i++) {
+ for (j = 0; j < _m - 1; j++)
+ o << (*_mat)[i][j] << ",";
+ o << (*_mat)[i][j] << endl;
}
+
+ return o;
}
View
@@ -16,9 +16,11 @@ class AdjMatrix {
AdjMatrix();
virtual ~AdjMatrix();
AdjMatrix(int n, int m);
- int *&operator[](unsigned i) {return *_mat[i];}
+ int *&operator[](unsigned i) {
+ return *_mat[i];
+ }
//void toDot(Nodeset &ns, string fname);
- void Set(unsigned, unsigned);
+ void set(unsigned, unsigned);
ostream& operator>>(std::ostream &);
private:
View
@@ -12,11 +12,15 @@
#include <stack>
#include "Linkable.h"
-class CallStack : public std::stack<Frame>{
+class CallStack: public std::stack<Frame> {
public:
CallStack();
virtual ~CallStack();
- Linkable &Run(void) {Linkable &g = top().Run(); pop(); return g;}
+ Linkable &Run(void) {
+ Linkable &g = top().run();
+ pop();
+ return g;
+ }
};
#endif /* CALLSTACK_H_ */
View
@@ -9,45 +9,42 @@
#include "Graph.h"
#include <assert.h>
-unsigned Edge::_lastsocketid=0;
+unsigned Edge::_lastsocketid = 0;
Edge::Edge() {
// TODO Auto-generated constructor stub
_socketid = ++_lastsocketid;
}
/*Edge::Edge(Node & n1, Node & n2)
-{
- _srcnodeid=n1.getId();
- _dstnodeid=n2.getId();
- n2._issource = false;
- n1._issink = false;
-}*/
+ {
+ _srcnodeid=n1.getId();
+ _dstnodeid=n2.getId();
+ n2._issource = false;
+ n1._issink = false;
+ }*/
-Edge::Edge(unsigned id1, unsigned id2)
-{
- _srcnodeid=id1;
- _dstnodeid=id2;
+Edge::Edge(unsigned id1, unsigned id2) {
+ _srcnodeid = id1;
+ _dstnodeid = id2;
_socketid = ++_lastsocketid;
//n2._issource = false;
//n1._issink = false;
}
-Edge::Edge(unsigned id1, unsigned id2, unsigned eid)
-{
- _srcnodeid=id1;
- _dstnodeid=id2;
+Edge::Edge(unsigned id1, unsigned id2, unsigned eid) {
+ _srcnodeid = id1;
+ _dstnodeid = id2;
_socketid = eid;
//assert(eid>=_lastsocketid);
//n2._issource = false;
//n1._issink = false;
}
-
Edge::~Edge() {
// TODO Auto-generated destructor stub
}
-ostream & Edge::operator>>(std::ostream &str){
+ostream & Edge::operator>>(std::ostream &str) {
str << "E";
str << _socketid;
str << "[";
@@ -58,11 +55,10 @@ ostream & Edge::operator>>(std::ostream &str){
return str;
}
-
- /*Node & Edge::getSrcNode(void)
-{return _mygraph->findNode(_srcnodeid);}
-*/
+/*Node & Edge::getSrcNode(void)
+ {return _mygraph->findNode(_srcnodeid);}
+ */
/*Node & Edge::getDstNode(void)
-{return _mygraph->findNode(_dstnodeid);}
-*/
+ {return _mygraph->findNode(_dstnodeid);}
+ */
View
29 Edge.h
@@ -10,7 +10,6 @@
#include "Node.h"
-
class Edge {
friend class Edgeset;
@@ -24,12 +23,26 @@ class Edge {
//Node & getSrcNode(void);
//Node & getDstNode(void);
- unsigned int getSrcNodeId(void){return _srcnodeid;}
- unsigned int getDstNodeId(void){return _dstnodeid;}
- void setSrcNodeId(unsigned id){_srcnodeid=id;}
- void setDstNodeId(unsigned id){_dstnodeid=id;}
- unsigned int getId(void){return _socketid;}
- void shiftId(int s){_socketid+=s; if (_socketid>_lastsocketid) _lastsocketid=_socketid;}
+ unsigned int getSrcNodeId(void) {
+ return _srcnodeid;
+ }
+ unsigned int getDstNodeId(void) {
+ return _dstnodeid;
+ }
+ void setSrcNodeId(unsigned id) {
+ _srcnodeid = id;
+ }
+ void setDstNodeId(unsigned id) {
+ _dstnodeid = id;
+ }
+ unsigned int getId(void) {
+ return _socketid;
+ }
+ void shiftId(int s) {
+ _socketid += s;
+ if (_socketid > _lastsocketid)
+ _lastsocketid = _socketid;
+ }
private:
unsigned int _srcnodeid;
@@ -40,6 +53,4 @@ class Edge {
};
-
-
#endif /* EDGE_H_ */
Oops, something went wrong.

0 comments on commit dfdf4dd

Please sign in to comment.