Replace mwscript program serialization into a vector with simple struct

Mostly to avoid string literal lookup by index with iteration over all preciding
literals and calling strlen. This is very inefficient. In genral this makes code
much more straightforward but also makes it portable since now int and float of
different sizes are properly supported.
This commit is contained in:
elsid 2023-01-10 04:10:18 +01:00
parent 60eede6a1d
commit b88f0d2dbd
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
21 changed files with 93 additions and 162 deletions

View file

@ -17,18 +17,11 @@ namespace Compiler
std::vector<std::string> mStrings;
public:
int getIntegerSize() const;
///< Return size of integer block (in bytes).
const std::vector<Interpreter::Type_Integer>& getIntegers() const { return mIntegers; }
int getFloatSize() const;
///< Return size of float block (in bytes).
const std::vector<Interpreter::Type_Float>& getFloats() const { return mFloats; }
int getStringSize() const;
///< Return size of string block (in bytes).
void append(std::vector<Interpreter::Type_Code>& code) const;
///< Apepnd literal blocks to code.
/// \note code blocks will be padded for 32-bit alignment.
const std::vector<std::string>& getStrings() const { return mStrings; }
int addInteger(Interpreter::Type_Integer value);
///< add integer liternal and return index.