1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-06 21:45:35 +00:00

ignore unused explicit references for functions

This commit is contained in:
Marc Zinnschlag 2014-02-12 13:53:59 +01:00
parent 6e2e4d1adf
commit a85d3c7dcb
4 changed files with 25 additions and 7 deletions

View file

@ -397,8 +397,15 @@ namespace Compiler
char returnType; char returnType;
std::string argumentType; std::string argumentType;
if (extensions->isFunction (keyword, returnType, argumentType, true)) bool hasExplicit = true;
if (extensions->isFunction (keyword, returnType, argumentType, hasExplicit))
{ {
if (!hasExplicit)
{
getErrorHandler().warning ("stray explicit reference (ignoring it)", loc);
mExplicit.clear();
}
start(); start();
mTokenLoc = loc; mTokenLoc = loc;
@ -519,7 +526,9 @@ namespace Compiler
char returnType; char returnType;
std::string argumentType; std::string argumentType;
if (extensions->isFunction (keyword, returnType, argumentType, false)) bool hasExplicit = false;
if (extensions->isFunction (keyword, returnType, argumentType, hasExplicit))
{ {
mTokenLoc = loc; mTokenLoc = loc;
int optionals = parseArguments (argumentType, scanner); int optionals = parseArguments (argumentType, scanner);

View file

@ -22,7 +22,7 @@ namespace Compiler
} }
bool Extensions::isFunction (int keyword, char& returnType, std::string& argumentType, bool Extensions::isFunction (int keyword, char& returnType, std::string& argumentType,
bool explicitReference) const bool& explicitReference) const
{ {
std::map<int, Function>::const_iterator iter = mFunctions.find (keyword); std::map<int, Function>::const_iterator iter = mFunctions.find (keyword);
@ -30,7 +30,7 @@ namespace Compiler
return false; return false;
if (explicitReference && iter->second.mCodeExplicit==-1) if (explicitReference && iter->second.mCodeExplicit==-1)
return false; explicitReference = false;
returnType = iter->second.mReturn; returnType = iter->second.mReturn;
argumentType = iter->second.mArguments; argumentType = iter->second.mArguments;

View file

@ -47,9 +47,11 @@ namespace Compiler
/// - keyword must be all lower case. /// - keyword must be all lower case.
bool isFunction (int keyword, char& returnType, std::string& argumentType, bool isFunction (int keyword, char& returnType, std::string& argumentType,
bool explicitReference) const; bool& explicitReference) const;
///< Is this keyword registered with a function? If yes, return return and argument ///< Is this keyword registered with a function? If yes, return return and argument
/// types. /// types.
/// \param explicitReference In: has explicit reference; Out: set to false, if
/// explicit reference is not available for this instruction.
bool isInstruction (int keyword, std::string& argumentType, bool isInstruction (int keyword, std::string& argumentType,
bool& explicitReference) const; bool& explicitReference) const;

View file

@ -279,9 +279,16 @@ namespace Compiler
char returnType; char returnType;
std::string argumentType; std::string argumentType;
if (extensions->isFunction (keyword, returnType, argumentType, bool hasExplicit = !mExplicit.empty();
!mExplicit.empty()))
if (extensions->isFunction (keyword, returnType, argumentType, hasExplicit))
{ {
if (!hasExplicit && !mExplicit.empty())
{
getErrorHandler().warning ("stray explicit reference (ignoring it)", loc);
mExplicit.clear();
}
scanner.putbackKeyword (keyword, loc); scanner.putbackKeyword (keyword, loc);
parseExpression (scanner, loc); parseExpression (scanner, loc);
mState = EndState; mState = EndState;