MCPcopy Create free account
hub / github.com/WallBreaker2/op / stringcompute

Function stringcompute

libop/memory/ProcessMemory.cpp:147–198  ·  view source on GitHub ↗

like AA+BB+DD-CC*cc. Use size_t so x64 absolute addresses parse correctly.

Source from the content-addressed store, hash-verified

145
146// like AA+BB+DD-CC*cc. Use size_t so x64 absolute addresses parse correctly.
147size_t stringcompute(const wchar_t *s) {
148 if (!s || !*s)
149 return 0;
150 wstring num;
151 vector<size_t> ns;
152 vector<wchar_t> os;
153 while (true) {
154 if (*s && !is_op(*s)) {
155 num.push_back(*s++);
156 continue;
157 }
158
159 if (!num.empty()) {
160 ns.push_back(parse_hex_word(num));
161 num.clear();
162 }
163
164 if (*s == 0)
165 break;
166
167 if (ns.empty()) {
168 os.push_back(*s++);
169 continue;
170 }
171
172 if (!os.empty()) {
173 const wchar_t pending = os.back();
174 if (get_op_prior(pending) >= get_op_prior(*s)) {
175 const size_t num2 = pop_back_value(ns);
176 const size_t num1 = pop_back_value(ns);
177 const wchar_t popped = pop_back_value(os);
178 ns.push_back(do_op_ptr(num1, num2, popped));
179 continue;
180 }
181 }
182
183 os.push_back(*s++);
184 }
185
186 while (!os.empty()) {
187 if (ns.size() < 2)
188 break;
189 const size_t num2 = pop_back_value(ns);
190 const size_t num1 = pop_back_value(ns);
191 const wchar_t popped = pop_back_value(os);
192 ns.push_back(do_op_ptr(num1, num2, popped));
193 }
194
195 if (ns.empty())
196 return 0;
197 return ns.back();
198}
199
200} // namespace
201

Callers 1

str2addressMethod · 0.85

Calls 8

is_opFunction · 0.85
parse_hex_wordFunction · 0.85
get_op_priorFunction · 0.85
pop_back_valueFunction · 0.85
do_op_ptrFunction · 0.85
emptyMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected