MCPcopy Create free account
hub / github.com/boostorg/spirit / print_assembler

Method print_assembler

example/qi/compiler_tutorial/calc8/compiler.cpp:58–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56 }
57
58 void program::print_assembler() const
59 {
60 std::vector<int>::const_iterator pc = code.begin();
61
62 std::vector<std::string> locals(variables.size());
63 typedef std::pair<std::string, int> pair;
64 BOOST_FOREACH(pair const& p, variables)
65 {
66 locals[p.second] = p.first;
67 std::cout << " local "
68 << p.first << ", @" << p.second << std::endl;
69 }
70
71 std::map<std::size_t, std::string> lines;
72 std::set<std::size_t> jumps;
73
74 while (pc != code.end())
75 {
76 std::string line;
77 std::size_t address = pc - code.begin();
78
79 switch (*pc++)
80 {
81 case op_neg:
82 line += " op_neg";
83 break;
84
85 case op_not:
86 line += " op_not";
87 break;
88
89 case op_add:
90 line += " op_add";
91 break;
92
93 case op_sub:
94 line += " op_sub";
95 break;
96
97 case op_mul:
98 line += " op_mul";
99 break;
100
101 case op_div:
102 line += " op_div";
103 break;
104
105 case op_eq:
106 line += " op_eq";
107 break;
108
109 case op_neq:
110 line += " op_neq";
111 break;
112
113 case op_lt:
114 line += " op_lt";
115 break;

Callers 1

mainFunction · 0.45

Calls 4

beginMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected