MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
Loading...
Searching...
No Matches
string.cpp
Go to the documentation of this file.
1
6#include <cstdio>
7#include <cstdlib>
8#include <cstring>
9#include <mxvm/icode.hpp>
10#include <mxvm/instruct.hpp>
11#include <string>
12
13static std::string getStringFromVar(mxvm::Program *program, const std::string &varName) {
14 if (!program->isVariable(varName)) {
15 throw mx::Exception("Argument must be a variable, got: " + varName);
16 }
17 mxvm::Variable &var = program->getVariable(varName);
19 return var.var_value.str_value;
20 }
22 mxvm::except_assert("Pointer argument '" + varName + "' is null", var.var_value.ptr_value != nullptr);
23 return std::string(reinterpret_cast<const char *>(var.var_value.ptr_value));
24 }
25 throw mx::Exception("Argument '" + varName + "' must be a string or pointer variable.");
26}
27
28static inline bool isStringLike(mxvm::Variable &v) {
30}
31static inline const char *asReadPtr(mxvm::Variable &v) {
33 mxvm::except_assert("null pointer", v.var_value.ptr_value != nullptr);
34 return reinterpret_cast<const char *>(v.var_value.ptr_value);
35 }
36 return v.var_value.str_value.c_str();
37}
38static inline char *asWritePtr(mxvm::Variable &v) {
40 mxvm::except_assert("null pointer", v.var_value.ptr_value != nullptr);
41 return reinterpret_cast<char *>(v.var_value.ptr_value);
42 }
43 return nullptr;
44}
45
46extern "C" void mxvm_string_strlen(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
47 if (operand.size() != 1) {
48 throw mx::Exception("strlen requires exactly 1 argument (string | pointer).");
49 }
50 std::string &name = operand[0].op;
51 if (!program->isVariable(name)) {
52 throw mx::Exception("strlen argument must be a declared variable (string | pointer): " + name);
53 }
54 mxvm::Variable &v = program->getVariable(name);
55
56 const char *src = nullptr;
57 switch (v.type) {
59 src = v.var_value.str_value.c_str();
60 break;
63 mxvm::except_assert("strlen: null pointer in variable '" + v.var_name + "'", v.var_value.ptr_value != nullptr);
64 src = reinterpret_cast<const char *>(v.var_value.ptr_value);
65 break;
66 default:
67 throw mx::Exception("strlen argument '" + v.var_name + "' must be string or pointer variable (got different type).");
68 }
69
70 int64_t length = static_cast<int64_t>(std::strlen(src));
71 program->vars["%rax"].type = mxvm::VarType::VAR_INTEGER;
72 program->vars["%rax"].var_value.type = mxvm::VarType::VAR_INTEGER;
73 program->vars["%rax"].var_value.int_value = length;
74}
75
76extern "C" void mxvm_string_strcmp(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
77 if (operand.size() != 2) {
78 throw mx::Exception("strcmp requires two pointer/string arguments.");
79 }
80 std::string &var1 = operand[0].op;
81 std::string &var2 = operand[1].op;
82
83 if (!program->isVariable(var1) || !program->isVariable(var2)) {
84 throw mx::Exception("strcmp arguments must be variables (pointer or string).");
85 }
86
87 mxvm::Variable &v1 = program->getVariable(var1);
88 mxvm::Variable &v2 = program->getVariable(var2);
89
90 const char *s1 = nullptr;
91 const char *s2 = nullptr;
92
94 mxvm::except_assert("strcmp: pointer: " + v1.var_name + " is null", (v1.var_value.ptr_value != nullptr));
95 s1 = reinterpret_cast<const char *>(v1.var_value.ptr_value);
96 } else if (v1.type == mxvm::VarType::VAR_STRING) {
97 s1 = v1.var_value.str_value.c_str();
98 } else {
99 throw mx::Exception("strcmp first argument must be a pointer or string variable.");
100 }
101
103 mxvm::except_assert("strcmp: pointer: " + v2.var_name + " is null", (v2.var_value.ptr_value != nullptr));
104 s2 = reinterpret_cast<const char *>(v2.var_value.ptr_value);
105 } else if (v2.type == mxvm::VarType::VAR_STRING) {
106 s2 = v2.var_value.str_value.c_str();
107 } else {
108 throw mx::Exception("strcmp second argument must be a pointer or string variable.");
109 }
110
111 int64_t cmp_result = strcmp(s1, s2);
112 program->vars["%rax"].type = mxvm::VarType::VAR_INTEGER;
113 program->vars["%rax"].var_value.type = mxvm::VarType::VAR_INTEGER;
114 program->vars["%rax"].var_value.int_value = cmp_result;
115}
116
117extern "C" void mxvm_string_strncpy(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
118 if (operand.size() != 3)
119 throw mx::Exception("strncpy requires (dest, src, len)");
120 if (!program->isVariable(operand[0].op) || !program->isVariable(operand[1].op))
121 throw mx::Exception("strncpy arguments must be variables");
122 mxvm::Variable &dest = program->getVariable(operand[0].op);
123 mxvm::Variable &src = program->getVariable(operand[1].op);
124
125 int64_t n = operand[2].op_value;
126 if (program->isVariable(operand[2].op)) {
127 mxvm::Variable &iv = program->getVariable(operand[2].op);
128 n = iv.var_value.int_value;
129 }
130
131 if (!isStringLike(dest))
132 throw mx::Exception("strncpy dest must be pointer or string");
133 if (!isStringLike(src))
134 throw mx::Exception("strncpy src must be pointer or string");
135
136 const char *sptr = asReadPtr(src);
137 if (dest.type == mxvm::VarType::VAR_POINTER) {
138 if (dest.var_value.buffer_size && (int64_t)dest.var_value.buffer_size < n + 1)
139 throw mx::Exception("strncpy dest buffer too small");
140 char *dptr = asWritePtr(dest);
141 std::strncpy(dptr, sptr, n);
142 dptr[n] = '\0';
143 } else {
144 dest.var_value.str_value.assign(sptr, (size_t)n);
145 }
146
147 program->vars["%rax"].type = mxvm::VarType::VAR_INTEGER;
148 program->vars["%rax"].var_value.int_value = n;
149}
150
151extern "C" void mxvm_string_strncat(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
152 if (operand.size() != 3)
153 throw mx::Exception("strncat requires (dest, src, len)");
154 if (!program->isVariable(operand[0].op) || !program->isVariable(operand[1].op))
155 throw mx::Exception("strncat arguments must be variables");
156 mxvm::Variable &dest = program->getVariable(operand[0].op);
157 mxvm::Variable &src = program->getVariable(operand[1].op);
158
159 int64_t n = operand[2].op_value;
160 if (program->isVariable(operand[2].op)) {
161 mxvm::Variable &iv = program->getVariable(operand[2].op);
162 n = iv.var_value.int_value;
163 }
164
165 if (!isStringLike(dest))
166 throw mx::Exception("strncat dest must be pointer or string");
167 if (!isStringLike(src))
168 throw mx::Exception("strncat src must be pointer or string");
169
170 const char *sptr = asReadPtr(src);
171 if (dest.type == mxvm::VarType::VAR_POINTER) {
172 if (dest.var_value.buffer_size) {
173 size_t have = std::strlen(reinterpret_cast<const char *>(dest.var_value.ptr_value));
174 if (have + (size_t)n + 1 > dest.var_value.buffer_size)
175 throw mx::Exception("strncat dest buffer too small");
176 }
177 std::strncat(reinterpret_cast<char *>(dest.var_value.ptr_value), sptr, n);
178 } else {
179 dest.var_value.str_value.append(sptr, (size_t)n);
180 }
181
182 program->vars["%rax"].type = mxvm::VarType::VAR_INTEGER;
183 program->vars["%rax"].var_value.int_value = n;
184}
185
186extern "C" void mxvm_string_snprintf(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
187 if (operand.size() < 4) {
188 throw mx::Exception("snprintf requires at least destination, size, format, and one argument.");
189 }
190 std::string &dest_var = operand[0].op;
191 int64_t n = operand[1].op_value;
192 std::string &fmt_var = operand[2].op;
193
194 if (!program->isVariable(dest_var) || !program->isVariable(fmt_var)) {
195 throw mx::Exception("snprintf destination: " + dest_var + " and format: " + fmt_var + " must be variables.");
196 }
197
198 if (program->isVariable(operand[1].op)) {
199 mxvm::Variable &iv = program->getVariable(operand[1].op);
200 n = iv.var_value.int_value;
201 }
202
203 mxvm::except_assert("snprintf size is zero", n != 0);
204 mxvm::Variable &dest = program->getVariable(dest_var);
205 mxvm::Variable &fmt = program->getVariable(fmt_var);
206
207 if (fmt.type != mxvm::VarType::VAR_STRING) {
208 throw mx::Exception("snprintf format must be a string variable.");
209 }
210
211 std::ostringstream oss;
212 size_t argIndex = 3;
213 const char *format = fmt.var_value.str_value.c_str();
214 char buffer[4096];
215
216 for (size_t i = 0; i < fmt.var_value.str_value.length(); ++i) {
217 if (format[i] == '%' && i + 1 < fmt.var_value.str_value.length()) {
218 size_t start = i;
219 size_t j = i + 1;
220 while (j < fmt.var_value.str_value.length() &&
221 (format[j] == '-' || format[j] == '+' || format[j] == ' ' || format[j] == '#' || format[j] == '0' ||
222 (format[j] >= '0' && format[j] <= '9') || format[j] == '.' ||
223 format[j] == 'l' || format[j] == 'h' || format[j] == 'z' || format[j] == 'j' || format[j] == 't')) {
224 ++j;
225 }
226 if (j < fmt.var_value.str_value.length() && format[j] == '%') {
227 oss << '%';
228 i = j;
229 continue;
230 }
231 if (j >= fmt.var_value.str_value.length())
232 break;
233 if (!std::isalpha(format[j])) {
234 oss << format[i];
235 continue;
236 }
237 std::string spec(format + start, format + j + 1);
238 if (argIndex < operand.size()) {
239 std::string &arg_var = operand[argIndex++].op;
240 if (!program->isVariable(arg_var)) {
241 throw mx::Exception("snprintf argument must be a variable.");
242 }
243 mxvm::Variable &arg = program->getVariable(arg_var);
244 if (arg.type == mxvm::VarType::VAR_INTEGER) {
245 std::snprintf(buffer, sizeof(buffer), spec.c_str(), arg.var_value.int_value);
247 std::snprintf(buffer, sizeof(buffer), spec.c_str(), arg.var_value.ptr_value);
248 } else if (arg.type == mxvm::VarType::VAR_FLOAT) {
249 std::snprintf(buffer, sizeof(buffer), spec.c_str(), arg.var_value.float_value);
250 } else if (arg.type == mxvm::VarType::VAR_STRING) {
251 std::snprintf(buffer, sizeof(buffer), spec.c_str(), arg.var_value.str_value.c_str());
252 } else if (arg.type == mxvm::VarType::VAR_BYTE) {
253 std::snprintf(buffer, sizeof(buffer), spec.c_str(), arg.var_value.int_value);
254 } else {
255 std::snprintf(buffer, sizeof(buffer), "%s", "(unsupported)");
256 }
257 oss << buffer;
258 } else {
259 oss << spec;
260 }
261 i = j;
262 } else {
263 oss << format[i];
264 }
265 }
266
267 if (dest.type == mxvm::VarType::VAR_POINTER) {
268 mxvm::except_assert("snprintf dest pointer is null", dest.var_value.ptr_value != nullptr);
269 std::strncpy(reinterpret_cast<char *>(dest.var_value.ptr_value), oss.str().c_str(), n);
270 if (n > 0) {
271 reinterpret_cast<char *>(dest.var_value.ptr_value)[n - 1] = '\0';
272 }
273 } else if (dest.type == mxvm::VarType::VAR_STRING) {
274 dest.var_value.str_value = oss.str().substr(0, n);
275 } else {
276 throw mx::Exception("snprintf destination must be a pointer or string variable.");
277 }
278
279 program->vars["%rax"].type = mxvm::VarType::VAR_INTEGER;
280 program->vars["%rax"].var_value.type = mxvm::VarType::VAR_INTEGER;
281 program->vars["%rax"].var_value.int_value = oss.str().length();
282}
283
284extern "C" void mxvm_string_strfind(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
285 if (operand.size() != 3)
286 throw mx::Exception("strfind requires (haystack, needle, start)");
287 if (!program->isVariable(operand[0].op) || !program->isVariable(operand[1].op))
288 throw mx::Exception("strfind arguments must be variables");
289 mxvm::Variable &hay = program->getVariable(operand[0].op);
290 mxvm::Variable &needle = program->getVariable(operand[1].op);
291
292 int64_t start = operand[2].op_value;
293 if (program->isVariable(operand[2].op)) {
294 mxvm::Variable &iv = program->getVariable(operand[2].op);
295 start = iv.var_value.int_value;
296 }
297
298 if (!isStringLike(hay) || !isStringLike(needle))
299 throw mx::Exception("strfind args must be pointer or string");
300
301 std::string H = asReadPtr(hay);
302 std::string N = asReadPtr(needle);
303
304 size_t pos = H.find(N, (size_t)start);
305 int64_t result = (pos == std::string::npos) ? -1 : (int64_t)pos;
306 program->vars["%rax"].type = mxvm::VarType::VAR_INTEGER;
307 program->vars["%rax"].var_value.int_value = result;
308}
309
310extern "C" void mxvm_string_substr(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
311 if (operand.size() != 5)
312 throw mx::Exception("substr requires 5 args");
313 if (!program->isVariable(operand[0].op) || !program->isVariable(operand[2].op))
314 throw mx::Exception("substr dest/src must be variables");
315 mxvm::Variable &dest = program->getVariable(operand[0].op);
316 mxvm::Variable &src = program->getVariable(operand[2].op);
317
318 if (!isStringLike(dest) || !isStringLike(src))
319 throw mx::Exception("substr dest/src must be pointer or string");
320
321 int64_t size = operand[1].op_value;
322 int64_t pos = operand[3].op_value;
323 int64_t len = operand[4].op_value;
324 if (program->isVariable(operand[1].op))
325 size = program->getVariable(operand[1].op).var_value.int_value;
326 if (program->isVariable(operand[3].op))
327 pos = program->getVariable(operand[3].op).var_value.int_value;
328 if (program->isVariable(operand[4].op))
329 len = program->getVariable(operand[4].op).var_value.int_value;
330
331 std::string S = asReadPtr(src);
332 if (pos < 0)
333 pos = 0;
334 std::string out = (pos > (int64_t)S.size()) ? "" : S.substr((size_t)pos, (size_t)len);
335
336 if (dest.type == mxvm::VarType::VAR_POINTER) {
337 mxvm::except_assert("substr dest ptr null", dest.var_value.ptr_value != nullptr);
338 if (size <= 0 || (dest.var_value.buffer_size && (size_t)size > dest.var_value.buffer_size))
339 size = (int64_t)dest.var_value.buffer_size;
340 std::strncpy(reinterpret_cast<char *>(dest.var_value.ptr_value), out.c_str(), (size_t)size);
341 if (size > 0)
342 reinterpret_cast<char *>(dest.var_value.ptr_value)[size - 1] = '\0';
343 } else {
344 dest.var_value.str_value = out.substr(0, (size_t)size);
345 }
346
347 program->vars["%rax"].type = mxvm::VarType::VAR_INTEGER;
348 program->vars["%rax"].var_value.int_value = (int64_t)out.size();
349}
350
351extern "C" void mxvm_string_strat(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
352 if (operand.size() == 2 && program->isVariable(operand[0].op)) {
353
354 int64_t pos = 0;
355 if (operand[1].type == mxvm::OperandType::OP_CONSTANT) {
356 pos = operand[1].op_value;
357 } else {
358 mxvm::Variable &v = program->getVariable(operand[1].op);
360 }
361 mxvm::Variable &var = program->getVariable(operand[0].op);
362 if (pos < 0 || static_cast<size_t>(pos) >= var.var_value.str_value.size()) {
363 throw mx::Exception("strat: index " + std::to_string(pos) + " out of bounds for string of length " + std::to_string(var.var_value.str_value.size()));
364 }
365 program->vars["%rax"].type = mxvm::VarType::VAR_INTEGER;
366 program->vars["%rax"].var_value.type = mxvm::VarType::VAR_INTEGER;
367 program->vars["%rax"].var_value.int_value = static_cast<int64_t>(var.var_value.str_value[static_cast<size_t>(pos)]);
368 }
369}
370
371extern "C" void mxvm_string_pos(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
372 if (operand.size() != 2)
373 throw mx::Exception("pos requires 2 arguments: (substr, s)");
374
375 std::string sub = getStringFromVar(program, operand[0].op);
376 std::string s = getStringFromVar(program, operand[1].op);
377
378 size_t position = s.find(sub);
379 int64_t result = (position == std::string::npos) ? 0 : static_cast<int64_t>(position + 1);
380
381 program->vars["%rax"].var_value.int_value = result;
382 program->vars["%rax"].type = mxvm::VarType::VAR_INTEGER;
383}
384
385extern "C" void mxvm_string_copy(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
386 if (operand.size() != 3)
387 throw mx::Exception("copy requires 3 arguments: (s, index, count)");
388
389 std::string s = getStringFromVar(program, operand[0].op);
390 int64_t index = program->getVariable(operand[1].op).var_value.int_value;
391 int64_t count = program->getVariable(operand[2].op).var_value.int_value;
392
393 if (index < 1 || static_cast<size_t>(index - 1) > s.size()) {
394 throw mx::Exception("copy: index " + std::to_string(index) + " out of bounds for string of length " + std::to_string(s.size()));
395 }
396 if (count < 0) {
397 throw mx::Exception("copy: count must be non-negative");
398 }
399 std::string result_str = s.substr(static_cast<size_t>(index - 1), static_cast<size_t>(count));
400
401 char *new_buf = static_cast<char *>(malloc(result_str.length() + 1));
402 if (!new_buf)
403 throw mx::Exception("malloc failed in copy()");
404 strcpy(new_buf, result_str.c_str());
405
406 program->vars["%rax"].var_value.ptr_value = new_buf;
407 program->vars["%rax"].var_value.ptr_size = 1;
408 program->vars["%rax"].var_value.ptr_count = static_cast<int64_t>(result_str.length() + 1);
409 program->vars["%rax"].var_value.owns = true;
410 program->vars["%rax"].type = mxvm::VarType::VAR_POINTER;
411}
412
413extern "C" void mxvm_string_insert(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
414 if (operand.size() != 3)
415 throw mx::Exception("insert requires 3 arguments: (source, dest, index)");
416
417 std::string source = getStringFromVar(program, operand[0].op);
418 std::string dest = getStringFromVar(program, operand[1].op);
419 int64_t index = program->getVariable(operand[2].op).var_value.int_value;
420
421 if (index < 1 || static_cast<size_t>(index - 1) > dest.size()) {
422 throw mx::Exception("insert: index " + std::to_string(index) + " out of bounds for string of length " + std::to_string(dest.size()));
423 }
424 dest.insert(static_cast<size_t>(index - 1), source);
425
426 char *new_buf = static_cast<char *>(malloc(dest.length() + 1));
427 if (!new_buf)
428 throw mx::Exception("malloc failed in insert()");
429 strcpy(new_buf, dest.c_str());
430
431 program->vars["%rax"].var_value.ptr_value = new_buf;
432 program->vars["%rax"].var_value.ptr_size = 1;
433 program->vars["%rax"].var_value.ptr_count = static_cast<int64_t>(dest.length() + 1);
434 program->vars["%rax"].var_value.owns = true;
435 program->vars["%rax"].type = mxvm::VarType::VAR_POINTER;
436}
437
438extern "C" void mxvm_string_delete(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
439 if (operand.size() != 3)
440 throw mx::Exception("delete requires 3 arguments: (s, index, count)");
441
442 std::string s = getStringFromVar(program, operand[0].op);
443 int64_t index = program->getVariable(operand[1].op).var_value.int_value;
444 int64_t count = program->getVariable(operand[2].op).var_value.int_value;
445
446 if (index < 1 || static_cast<size_t>(index - 1) > s.size()) {
447 throw mx::Exception("delete: index " + std::to_string(index) + " out of bounds for string of length " + std::to_string(s.size()));
448 }
449 if (count < 0) {
450 throw mx::Exception("delete: count must be non-negative");
451 }
452 s.erase(static_cast<size_t>(index - 1), static_cast<size_t>(count));
453
454 char *new_buf = static_cast<char *>(malloc(s.length() + 1));
455 if (!new_buf)
456 throw mx::Exception("malloc failed in delete()");
457 strcpy(new_buf, s.c_str());
458
459 program->vars["%rax"].var_value.ptr_value = new_buf;
460 program->vars["%rax"].var_value.ptr_size = 1;
461 program->vars["%rax"].var_value.ptr_count = static_cast<int64_t>(s.length() + 1);
462 program->vars["%rax"].var_value.owns = true;
463 program->vars["%rax"].type = mxvm::VarType::VAR_POINTER;
464}
465
477extern "C" void mxvm_string_inttostr(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
478 if (operand.size() != 1)
479 throw mx::Exception("inttostr requires 1 argument: (integer)");
480
481 int64_t val = program->getVariable(operand[0].op).var_value.int_value;
482 std::string result_str = std::to_string(val);
483
484 char *new_buf = static_cast<char *>(malloc(result_str.length() + 1));
485 if (!new_buf)
486 throw mx::Exception("malloc failed in inttostr()");
487 strcpy(new_buf, result_str.c_str());
488
489 // Free old owned pointer in %rax before overwriting
490 auto &rax = program->vars["%rax"];
491 if (rax.type == mxvm::VarType::VAR_POINTER && rax.var_value.ptr_value && rax.var_value.owns) {
492 std::free(rax.var_value.ptr_value);
493 }
494
495 rax.var_value.ptr_value = new_buf;
496 rax.var_value.ptr_size = 1;
497 rax.var_value.ptr_count = static_cast<int64_t>(result_str.length() + 1);
498 rax.var_value.owns = true;
500}
501
502extern "C" void mxvm_string_strtoint(mxvm::Program *program, std::vector<mxvm::Operand> &operand) {
503 if (operand.size() != 1)
504 throw mx::Exception("strtoint requires 1 argument: (string)");
505
506 std::string s = getStringFromVar(program, operand[0].op);
507 int64_t result = 0;
508 try {
509 result = std::stoll(s);
510 } catch (const std::exception &e) {
511 result = 0;
512 }
513
514 program->vars["%rax"].var_value.int_value = result;
515 program->vars["%rax"].type = mxvm::VarType::VAR_INTEGER;
516}
General-purpose exception with errno-aware factory method.
Definition exception.hpp:38
std::unordered_map< std::string, Variable > vars
variable symbol table
Definition icode.hpp:193
Complete MXVM program: instruction interpreter and native x64 code generator.
Definition icode.hpp:212
Variable & getVariable(const std::string &name)
Look up a variable by name, searching local scope then global.
bool isVariable(const std::string &name)
Check whether a variable exists in local or global scope.
int64_t pos(const char *substr, const char *s)
Definition cstring.c:51
Intermediate code representation, execution engine, and native x64 code generation (SysV + Win64).
Instruction set enum, operand/instruction structs, variable types, and Variable/Variable_Value defini...
void except_assert(std::string reason, bool value)
Assert a condition, throwing an Exception with the given reason on failure.
Definition icode.cpp:436
static std::string getStringFromVar(mxvm::Program *program, const std::string &varName)
Definition string.cpp:13
void mxvm_string_strat(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:351
static bool isStringLike(mxvm::Variable &v)
Definition string.cpp:28
void mxvm_string_strfind(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:284
void mxvm_string_snprintf(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:186
void mxvm_string_strncpy(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:117
void mxvm_string_copy(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:385
void mxvm_string_strcmp(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:76
void mxvm_string_substr(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:310
void mxvm_string_insert(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:413
void mxvm_string_pos(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:371
void mxvm_string_delete(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:438
void mxvm_string_strlen(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:46
void mxvm_string_inttostr(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Convert an integer to its decimal string representation.
Definition string.cpp:477
void mxvm_string_strncat(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:151
static char * asWritePtr(mxvm::Variable &v)
Definition string.cpp:38
void mxvm_string_strtoint(mxvm::Program *program, std::vector< mxvm::Operand > &operand)
Definition string.cpp:502
static const char * asReadPtr(mxvm::Variable &v)
Definition string.cpp:31
uint64_t buffer_size
declared buffer size
Definition instruct.hpp:221
std::string str_value
Definition instruct.hpp:211
A named variable with type, value, and optional object association.
Definition instruct.hpp:292
std::string var_name
Definition instruct.hpp:294
Variable_Value var_value
Definition instruct.hpp:295