allow (and discard) explicit reference on instructions that do not accept explicit references

pull/22/head
Marc Zinnschlag 11 years ago
parent 9de2922d22
commit 697bda6371

@ -38,7 +38,7 @@ namespace Compiler
}
bool Extensions::isInstruction (int keyword, std::string& argumentType,
bool explicitReference) const
bool& explicitReference) const
{
std::map<int, Instruction>::const_iterator iter = mInstructions.find (keyword);
@ -46,7 +46,7 @@ namespace Compiler
return false;
if (explicitReference && iter->second.mCodeExplicit==-1)
return false;
explicitReference = false;
argumentType = iter->second.mArguments;
return true;

@ -52,8 +52,10 @@ namespace Compiler
/// types.
bool isInstruction (int keyword, std::string& argumentType,
bool explicitReference) const;
bool& explicitReference) const;
///< Is this keyword registered with a function? If yes, return argument types.
/// \param explicitReference In: has explicit reference; Out: set to false, if
/// explicit reference is not available for this instruction.
void registerFunction (const std::string& keyword, char returnType,
const std::string& argumentType, int code, int codeExplicit = -1);

@ -234,8 +234,15 @@ namespace Compiler
{
std::string argumentType;
if (extensions->isInstruction (keyword, argumentType, mState==ExplicitState))
bool hasExplicit = mState==ExplicitState;
if (extensions->isInstruction (keyword, argumentType, hasExplicit))
{
if (!hasExplicit && mState==ExplicitState)
{
getErrorHandler().warning ("stray explicit reference (ignoring it)", loc);
mExplicit.clear();
}
int optionals = mExprParser.parseArguments (argumentType, scanner, mCode, true);
extensions->generateInstructionCode (keyword, mCode, mLiterals, mExplicit, optionals);
@ -271,6 +278,14 @@ namespace Compiler
}
}
if (mState==ExplicitState)
{
// drop stray explicit reference
getErrorHandler().warning ("stray explicit reference (ignoring it)", loc);
mState = BeginState;
mExplicit.clear();
}
if (mState==BeginState)
{
switch (keyword)

Loading…
Cancel
Save