MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
Loading...
Searching...
No Matches
string.cpp File Reference

String module C++ runtime bindings for the MXVM interpreter. More...

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <mxvm/icode.hpp>
#include <mxvm/instruct.hpp>
#include <string>
Include dependency graph for string.cpp:

Go to the source code of this file.

Functions

static std::string getStringFromVar (mxvm::Program *program, const std::string &varName)
static bool isStringLike (mxvm::Variable &v)
static const char * asReadPtr (mxvm::Variable &v)
static char * asWritePtr (mxvm::Variable &v)
void mxvm_string_strlen (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_strcmp (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_strncpy (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_strncat (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_snprintf (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_strfind (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_substr (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_strat (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_pos (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_copy (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_insert (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_delete (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
void mxvm_string_inttostr (mxvm::Program *program, std::vector< mxvm::Operand > &operand)
 Convert an integer to its decimal string representation.
void mxvm_string_strtoint (mxvm::Program *program, std::vector< mxvm::Operand > &operand)

Detailed Description

String module C++ runtime bindings for the MXVM interpreter.

Author
Jared Bruni

Definition in file string.cpp.

Function Documentation

◆ asReadPtr()

◆ asWritePtr()

char * asWritePtr ( mxvm::Variable & v)
inlinestatic

◆ getStringFromVar()

◆ isStringLike()

bool isStringLike ( mxvm::Variable & v)
inlinestatic

◆ mxvm_string_copy()

void mxvm_string_copy ( mxvm::Program * program,
std::vector< mxvm::Operand > & operand )

◆ mxvm_string_delete()

void mxvm_string_delete ( mxvm::Program * program,
std::vector< mxvm::Operand > & operand )

◆ mxvm_string_insert()

void mxvm_string_insert ( mxvm::Program * program,
std::vector< mxvm::Operand > & operand )

◆ mxvm_string_inttostr()

void mxvm_string_inttostr ( mxvm::Program * program,
std::vector< mxvm::Operand > & operand )

Convert an integer to its decimal string representation.

Allocates a new heap buffer for the result string and returns it via rax as a pointer. Frees any previously-owned pointer in rax before overwriting to prevent memory leaks from repeated calls (e.g. inttostr(score) inside a render loop).

Parameters
programVM program context.
operandSingle operand: the integer variable to convert.

Definition at line 477 of file string.cpp.

References mxvm::Program::getVariable(), mxvm::Variable_Value::int_value, mxvm::VAR_POINTER, mxvm::Variable::var_value, and mxvm::Base::vars.

◆ mxvm_string_pos()

void mxvm_string_pos ( mxvm::Program * program,
std::vector< mxvm::Operand > & operand )

Definition at line 371 of file string.cpp.

References getStringFromVar(), mxvm::VAR_INTEGER, and mxvm::Base::vars.

◆ mxvm_string_snprintf()

◆ mxvm_string_strat()

◆ mxvm_string_strcmp()

◆ mxvm_string_strfind()

◆ mxvm_string_strlen()

◆ mxvm_string_strncat()

◆ mxvm_string_strncpy()

◆ mxvm_string_strtoint()

void mxvm_string_strtoint ( mxvm::Program * program,
std::vector< mxvm::Operand > & operand )

Definition at line 502 of file string.cpp.

References getStringFromVar(), mxvm::VAR_INTEGER, and mxvm::Base::vars.

◆ mxvm_string_substr()