mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +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.
63 lines
1.1 KiB
C++
63 lines
1.1 KiB
C++
#include "output.hpp"
|
|
|
|
#include <algorithm>
|
|
#include <cassert>
|
|
#include <iterator>
|
|
|
|
#include "locals.hpp"
|
|
|
|
namespace Compiler
|
|
{
|
|
Output::Output(Locals& locals)
|
|
: mLocals(locals)
|
|
{
|
|
}
|
|
|
|
Interpreter::Program Output::getProgram() const
|
|
{
|
|
return Interpreter::Program{
|
|
.mInstructions = mCode,
|
|
.mIntegers = mLiterals.getIntegers(),
|
|
.mFloats = mLiterals.getFloats(),
|
|
.mStrings = mLiterals.getStrings(),
|
|
};
|
|
}
|
|
|
|
const Literals& Output::getLiterals() const
|
|
{
|
|
return mLiterals;
|
|
}
|
|
|
|
const std::vector<Interpreter::Type_Code>& Output::getCode() const
|
|
{
|
|
return mCode;
|
|
}
|
|
|
|
const Locals& Output::getLocals() const
|
|
{
|
|
return mLocals;
|
|
}
|
|
|
|
Literals& Output::getLiterals()
|
|
{
|
|
return mLiterals;
|
|
}
|
|
|
|
std::vector<Interpreter::Type_Code>& Output::getCode()
|
|
{
|
|
return mCode;
|
|
}
|
|
|
|
Locals& Output::getLocals()
|
|
{
|
|
return mLocals;
|
|
}
|
|
|
|
void Output::clear()
|
|
{
|
|
mLiterals.clear();
|
|
mCode.clear();
|
|
mLocals.clear();
|
|
}
|
|
}
|