Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type

The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID

Slowly going through all the changes to make, still hundreds of errors

a lot of functions/structures use std::string or stringview to designate an ID. So it takes time

Continues slowly replacing ids. There are technically more and more compilation errors

I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type

Continue moving forward, changes to the stores

slowly moving along

Starting to see the fruit of those changes.

still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.

More replacements. Things are starting to get easier

I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.

Still moving forward, and for the first time error count is going down!

Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably

Cells are back to using string for the name, haven't fixed everything yet. Many other changes

Under the bar of 400 compilation errors.

more good progress <100 compile errors!

More progress

Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string

some more progress on other fronts

Mostly game settings clean

one error opened a lot of other errors. Down to 18, but more will prbably appear

only link errors left??

Fixed link errors

OpenMW compiles, and launches, with some issues, but still!
This commit is contained in:
fteppe 2022-09-25 13:17:09 +02:00 committed by florent.teppe
parent 8b0eba8906
commit 125b21de20
411 changed files with 2911 additions and 2593 deletions

View file

@ -2,6 +2,10 @@
#define COMPILER_CONTEXT_H_INCLUDED
#include <string>
namespace ESM
{
struct RefId;
}
namespace Compiler
{
@ -29,13 +33,13 @@ namespace Compiler
virtual char getGlobalType(const std::string& name) const = 0;
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
virtual std::pair<char, bool> getMemberType(const std::string& name, const std::string& id) const = 0;
virtual std::pair<char, bool> getMemberType(const std::string& name, const ESM::RefId& id) const = 0;
///< Return type of member variable \a name in script \a id or in script of reference of
/// \a id
/// \return first: 'l: long, 's': short, 'f': float, ' ': does not exist.
/// second: true: script of reference
virtual bool isId(const std::string& name) const = 0;
virtual bool isId(const ESM::RefId& name) const = 0;
///< Does \a name match an ID, that can be referenced?
};
}

View file

@ -8,6 +8,7 @@
#include <stdexcept>
#include <components/misc/strings/lower.hpp>
#include <components/esm/refid.hpp>
#include "context.hpp"
#include "discardparser.hpp"
@ -204,13 +205,13 @@ namespace Compiler
mMemberOp = false;
std::string name2 = Misc::StringUtils::lowerCase(name);
std::string id = Misc::StringUtils::lowerCase(mExplicit);
auto id = ESM::RefId::stringRefId(mExplicit);
std::pair<char, bool> type = getContext().getMemberType(name2, id);
if (type.first != ' ')
{
Generator::fetchMember(mCode, mLiterals, type.first, name2, id, !type.second);
Generator::fetchMember(mCode, mLiterals, type.first, name2, id.getRefIdString(), !type.second);
mNextOperand = false;
mExplicit.clear();
@ -302,31 +303,30 @@ namespace Compiler
{
start();
std::string name2 = Misc::StringUtils::lowerCase(name);
char type = mLocals.getType(name2);
char type = mLocals.getType(name);
if (type != ' ')
{
Generator::fetchLocal(mCode, type, mLocals.getIndex(name2));
Generator::fetchLocal(mCode, type, mLocals.getIndex(name));
mNextOperand = false;
mOperands.push_back(type == 'f' ? 'f' : 'l');
return true;
}
type = getContext().getGlobalType(name2);
type = getContext().getGlobalType(name);
if (type != ' ')
{
Generator::fetchGlobal(mCode, mLiterals, type, name2);
Generator::fetchGlobal(mCode, mLiterals, type, name);
mNextOperand = false;
mOperands.push_back(type == 'f' ? 'f' : 'l');
return true;
}
if (mExplicit.empty() && getContext().isId(name2))
if (mExplicit.empty() && getContext().isId(ESM::RefId::stringRefId(name)))
{
mExplicit = name2;
mExplicit = name;
return true;
}
@ -334,7 +334,7 @@ namespace Compiler
// Convert the string to a number even if it's impossible and use it as a number literal.
// Can't use stof/atof or to_string out of locale concerns.
float number;
std::stringstream stream(name2);
std::stringstream stream(name);
stream >> number;
stream.str(std::string());
stream.clear();

View file

@ -3,6 +3,7 @@
#include <memory>
#include <components/misc/strings/lower.hpp>
#include <components/esm/refid.hpp>
#include "context.hpp"
#include "declarationparser.hpp"
@ -126,7 +127,7 @@ namespace Compiler
if (mState == SetMemberVarState)
{
mMemberName = Misc::StringUtils::lowerCase(name);
std::pair<char, bool> type = getContext().getMemberType(mMemberName, mName);
std::pair<char, bool> type = getContext().getMemberType(mMemberName, ESM::RefId::stringRefId(mName));
if (type.first != ' ')
{
@ -169,7 +170,7 @@ namespace Compiler
return true;
}
if (mState == BeginState && getContext().isId(name))
if (mState == BeginState && getContext().isId(ESM::RefId::stringRefId(name)))
{
mState = PotentialExplicitState;
mExplicit = Misc::StringUtils::lowerCase(name);
@ -224,7 +225,7 @@ namespace Compiler
if (mState == SetMemberVarState)
{
mMemberName = loc.mLiteral;
std::pair<char, bool> type = getContext().getMemberType(mMemberName, mName);
std::pair<char, bool> type = getContext().getMemberType(mMemberName, ESM::RefId::stringRefId(mName));
if (type.first != ' ')
{

View file

@ -3,6 +3,7 @@
#include <sstream>
#include <components/debug/debuglog.hpp>
#include <components/esm/refid.hpp>
#include "tokenloc.hpp"