forked from mirror/openmw-tes3mp
workaround for incorrect argument order for PositionCell instruction
This commit is contained in:
parent
af54bb9623
commit
6a745c014f
3 changed files with 71 additions and 7 deletions
|
@ -3,11 +3,8 @@
|
||||||
|
|
||||||
namespace Compiler
|
namespace Compiler
|
||||||
{
|
{
|
||||||
// constructor
|
ErrorHandler::ErrorHandler()
|
||||||
|
: mWarnings (0), mErrors (0), mWarningsMode (1), mDowngradeErrors (false) {}
|
||||||
ErrorHandler::ErrorHandler() : mWarnings (0), mErrors (0), mWarningsMode (1) {}
|
|
||||||
|
|
||||||
// destructor
|
|
||||||
|
|
||||||
ErrorHandler::~ErrorHandler() {}
|
ErrorHandler::~ErrorHandler() {}
|
||||||
|
|
||||||
|
@ -49,6 +46,12 @@ namespace Compiler
|
||||||
|
|
||||||
void ErrorHandler::error (const std::string& message, const TokenLoc& loc)
|
void ErrorHandler::error (const std::string& message, const TokenLoc& loc)
|
||||||
{
|
{
|
||||||
|
if (mDowngradeErrors)
|
||||||
|
{
|
||||||
|
warning (message, loc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
++mErrors;
|
++mErrors;
|
||||||
report (message, loc, ErrorMessage);
|
report (message, loc, ErrorMessage);
|
||||||
}
|
}
|
||||||
|
@ -72,4 +75,21 @@ namespace Compiler
|
||||||
{
|
{
|
||||||
mWarningsMode = mode;
|
mWarningsMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ErrorHandler::downgradeErrors (bool downgrade)
|
||||||
|
{
|
||||||
|
mDowngradeErrors = downgrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ErrorDowngrade::ErrorDowngrade (ErrorHandler& handler) : mHandler (handler)
|
||||||
|
{
|
||||||
|
mHandler.downgradeErrors (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorDowngrade::~ErrorDowngrade()
|
||||||
|
{
|
||||||
|
mHandler.downgradeErrors (false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace Compiler
|
||||||
int mWarnings;
|
int mWarnings;
|
||||||
int mErrors;
|
int mErrors;
|
||||||
int mWarningsMode;
|
int mWarningsMode;
|
||||||
|
bool mDowngradeErrors;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -66,6 +67,26 @@ namespace Compiler
|
||||||
|
|
||||||
void setWarningsMode (int mode);
|
void setWarningsMode (int mode);
|
||||||
///< // 0 ignore, 1 rate as warning, 2 rate as error
|
///< // 0 ignore, 1 rate as warning, 2 rate as error
|
||||||
|
|
||||||
|
/// Treat errors as warnings.
|
||||||
|
void downgradeErrors (bool downgrade);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ErrorDowngrade
|
||||||
|
{
|
||||||
|
ErrorHandler& mHandler;
|
||||||
|
|
||||||
|
/// not implemented
|
||||||
|
ErrorDowngrade (const ErrorDowngrade&);
|
||||||
|
|
||||||
|
/// not implemented
|
||||||
|
ErrorDowngrade& operator= (const ErrorDowngrade&);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
ErrorDowngrade (ErrorHandler& handler);
|
||||||
|
|
||||||
|
~ErrorDowngrade();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "generator.hpp"
|
#include "generator.hpp"
|
||||||
#include "extensions.hpp"
|
#include "extensions.hpp"
|
||||||
#include "declarationparser.hpp"
|
#include "declarationparser.hpp"
|
||||||
|
#include "exception.hpp"
|
||||||
|
|
||||||
namespace Compiler
|
namespace Compiler
|
||||||
{
|
{
|
||||||
|
@ -292,9 +293,31 @@ namespace Compiler
|
||||||
mExplicit.clear();
|
mExplicit.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int optionals = mExprParser.parseArguments (argumentType, scanner, mCode);
|
int optionals = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ErrorDowngrade errorDowngrade (getErrorHandler());
|
||||||
|
std::vector<Interpreter::Type_Code> code;
|
||||||
|
optionals = mExprParser.parseArguments (argumentType, scanner, code);
|
||||||
|
mCode.insert (mCode.begin(), code.begin(), code.end());
|
||||||
|
extensions->generateInstructionCode (keyword, mCode, mLiterals,
|
||||||
|
mExplicit, optionals);
|
||||||
|
}
|
||||||
|
catch (const SourceException& exception)
|
||||||
|
{
|
||||||
|
// Ignore argument exceptions for positioncell.
|
||||||
|
/// \todo add option to disable this
|
||||||
|
if (Misc::StringUtils::lowerCase (loc.mLiteral)=="positioncell")
|
||||||
|
{
|
||||||
|
SkipParser skip (getErrorHandler(), getContext());
|
||||||
|
scanner.scan (skip);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
extensions->generateInstructionCode (keyword, mCode, mLiterals, mExplicit, optionals);
|
|
||||||
mState = EndState;
|
mState = EndState;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue