mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2024-12-28 00:15:06 +00:00
b88f0d2dbd
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.
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
#ifndef COMPILER_LITERALS_H_INCLUDED
|
|
#define COMPILER_LITERALS_H_INCLUDED
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <components/interpreter/types.hpp>
|
|
|
|
namespace Compiler
|
|
{
|
|
/// \brief Literal values.
|
|
|
|
class Literals
|
|
{
|
|
std::vector<Interpreter::Type_Integer> mIntegers;
|
|
std::vector<Interpreter::Type_Float> mFloats;
|
|
std::vector<std::string> mStrings;
|
|
|
|
public:
|
|
const std::vector<Interpreter::Type_Integer>& getIntegers() const { return mIntegers; }
|
|
|
|
const std::vector<Interpreter::Type_Float>& getFloats() const { return mFloats; }
|
|
|
|
const std::vector<std::string>& getStrings() const { return mStrings; }
|
|
|
|
int addInteger(Interpreter::Type_Integer value);
|
|
///< add integer liternal and return index.
|
|
|
|
int addFloat(Interpreter::Type_Float value);
|
|
///< add float literal and return value.
|
|
|
|
int addString(const std::string& value);
|
|
///< add string literal and return value.
|
|
|
|
void clear();
|
|
///< remove all literals.
|
|
};
|
|
}
|
|
|
|
#endif
|