Graph.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include "decompiler/Graph.h"
  16. #include "decompiler/Engine.h"
  17. IsJump::IsJump(){is_jump = false;};
  18. IsJump::IsJump(bool jump): is_jump(jump){};
  19. CodeLine::CodeLine(const std::string& line, bool unindent_before, bool indent_after):
  20. line(line), unindent_before(unindent_before), indent_after(indent_after){}
  21. Group::Group(): stack_level(-1), type(GROUP_TYPE_NORMAL){}
  22. Group::Group(GraphVertex vertex, InstIterator start, InstIterator end, GroupPtr prev){
  23. this->vertex = vertex;
  24. this->start = start;
  25. this->end = end;
  26. stack_level = -1;
  27. type = GROUP_TYPE_NORMAL;
  28. this->prev = prev.get();
  29. start_else = false;
  30. if (prev != NULL) prev->next = this;
  31. next = NULL;
  32. coalesced_else = false;
  33. }
  34. GraphProperties::GraphProperties(Engine *engine, const Graph &graph): engine(engine), graph(&graph)
  35. {}
  36. GraphProperties::GraphProperties(const GraphProperties& rhs){*this = rhs;}
  37. GraphProperties& GraphProperties::operator = (const GraphProperties& rhs){
  38. if (this != &rhs){
  39. engine = rhs.engine;
  40. graph = rhs.graph;
  41. }
  42. return *this;
  43. }
  44. void GraphProperties::operator()(std::ostream& out) const{
  45. out << "node [shape=record]" << std::endl;
  46. for (
  47. FuncMap::iterator fn = engine->functions.begin();
  48. fn != engine->functions.end();
  49. ++ fn
  50. ){
  51. int index = (boost::get(boost::vertex_index, *graph, fn->second.vertex));
  52. out << "XXX" << index << " [shape=none, label=\"\", height=0]" << std::endl;
  53. out << "XXX" << index << " -> " << index << std::endl;
  54. }
  55. }