forked from mirror/openmw-tes3mp
even better error checking for extensions with explicit references
This commit is contained in:
parent
7f48c64efe
commit
0f742ce7f9
4 changed files with 17 additions and 7 deletions
|
@ -331,7 +331,7 @@ namespace Compiler
|
||||||
char returnType;
|
char returnType;
|
||||||
std::string argumentType;
|
std::string argumentType;
|
||||||
|
|
||||||
if (extensions->isFunction (keyword, returnType, argumentType))
|
if (extensions->isFunction (keyword, returnType, argumentType, true))
|
||||||
{
|
{
|
||||||
mTokenLoc = loc;
|
mTokenLoc = loc;
|
||||||
parseArguments (argumentType, scanner);
|
parseArguments (argumentType, scanner);
|
||||||
|
@ -434,7 +434,7 @@ namespace Compiler
|
||||||
char returnType;
|
char returnType;
|
||||||
std::string argumentType;
|
std::string argumentType;
|
||||||
|
|
||||||
if (extensions->isFunction (keyword, returnType, argumentType))
|
if (extensions->isFunction (keyword, returnType, argumentType, false))
|
||||||
{
|
{
|
||||||
mTokenLoc = loc;
|
mTokenLoc = loc;
|
||||||
parseArguments (argumentType, scanner);
|
parseArguments (argumentType, scanner);
|
||||||
|
|
|
@ -21,25 +21,33 @@ namespace Compiler
|
||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Extensions::isFunction (int keyword, char& returnType, std::string& argumentType) const
|
bool Extensions::isFunction (int keyword, char& returnType, std::string& argumentType,
|
||||||
|
bool explicitReference) const
|
||||||
{
|
{
|
||||||
std::map<int, Function>::const_iterator iter = mFunctions.find (keyword);
|
std::map<int, Function>::const_iterator iter = mFunctions.find (keyword);
|
||||||
|
|
||||||
if (iter==mFunctions.end())
|
if (iter==mFunctions.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (explicitReference && iter->second.mCodeExplicit==-1)
|
||||||
|
return false;
|
||||||
|
|
||||||
returnType = iter->second.mReturn;
|
returnType = iter->second.mReturn;
|
||||||
argumentType = iter->second.mArguments;
|
argumentType = iter->second.mArguments;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Extensions::isInstruction (int keyword, std::string& argumentType) const
|
bool Extensions::isInstruction (int keyword, std::string& argumentType,
|
||||||
|
bool explicitReference) const
|
||||||
{
|
{
|
||||||
std::map<int, Instruction>::const_iterator iter = mInstructions.find (keyword);
|
std::map<int, Instruction>::const_iterator iter = mInstructions.find (keyword);
|
||||||
|
|
||||||
if (iter==mInstructions.end())
|
if (iter==mInstructions.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (explicitReference && iter->second.mCodeExplicit==-1)
|
||||||
|
return false;
|
||||||
|
|
||||||
argumentType = iter->second.mArguments;
|
argumentType = iter->second.mArguments;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,13 @@ namespace Compiler
|
||||||
/// - if no match is found 0 is returned.
|
/// - if no match is found 0 is returned.
|
||||||
/// - keyword must be all lower case.
|
/// - keyword must be all lower case.
|
||||||
|
|
||||||
bool isFunction (int keyword, char& returnType, std::string& argumentType) const;
|
bool isFunction (int keyword, char& returnType, std::string& argumentType,
|
||||||
|
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.
|
||||||
|
|
||||||
bool isInstruction (int keyword, std::string& argumentType) const;
|
bool isInstruction (int keyword, std::string& argumentType,
|
||||||
|
bool explicitReference) const;
|
||||||
///< Is this keyword registered with a function? If yes, return argument types.
|
///< Is this keyword registered with a function? If yes, return argument types.
|
||||||
|
|
||||||
void registerFunction (const std::string& keyword, char returnType,
|
void registerFunction (const std::string& keyword, char returnType,
|
||||||
|
|
|
@ -163,7 +163,7 @@ namespace Compiler
|
||||||
{
|
{
|
||||||
std::string argumentType;
|
std::string argumentType;
|
||||||
|
|
||||||
if (extensions->isInstruction (keyword, argumentType))
|
if (extensions->isInstruction (keyword, argumentType, mState==ExplicitState))
|
||||||
{
|
{
|
||||||
mExprParser.parseArguments (argumentType, scanner, mCode, true);
|
mExprParser.parseArguments (argumentType, scanner, mCode, true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue