From 0f742ce7f9deb3fed38ff1d21d61b6c27e6776ed Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 10 Jul 2010 12:31:00 +0200 Subject: [PATCH] even better error checking for extensions with explicit references --- components/compiler/exprparser.cpp | 4 ++-- components/compiler/extensions.cpp | 12 ++++++++++-- components/compiler/extensions.hpp | 6 ++++-- components/compiler/lineparser.cpp | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index db7f8a2d2..d0138078e 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -331,7 +331,7 @@ namespace Compiler char returnType; std::string argumentType; - if (extensions->isFunction (keyword, returnType, argumentType)) + if (extensions->isFunction (keyword, returnType, argumentType, true)) { mTokenLoc = loc; parseArguments (argumentType, scanner); @@ -434,7 +434,7 @@ namespace Compiler char returnType; std::string argumentType; - if (extensions->isFunction (keyword, returnType, argumentType)) + if (extensions->isFunction (keyword, returnType, argumentType, false)) { mTokenLoc = loc; parseArguments (argumentType, scanner); diff --git a/components/compiler/extensions.cpp b/components/compiler/extensions.cpp index 8aef21407..78ae0fdfd 100644 --- a/components/compiler/extensions.cpp +++ b/components/compiler/extensions.cpp @@ -21,24 +21,32 @@ namespace Compiler 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::const_iterator iter = mFunctions.find (keyword); if (iter==mFunctions.end()) return false; + if (explicitReference && iter->second.mCodeExplicit==-1) + return false; + returnType = iter->second.mReturn; argumentType = iter->second.mArguments; return true; } - bool Extensions::isInstruction (int keyword, std::string& argumentType) const + bool Extensions::isInstruction (int keyword, std::string& argumentType, + bool explicitReference) const { std::map::const_iterator iter = mInstructions.find (keyword); if (iter==mInstructions.end()) return false; + + if (explicitReference && iter->second.mCodeExplicit==-1) + return false; argumentType = iter->second.mArguments; return true; diff --git a/components/compiler/extensions.hpp b/components/compiler/extensions.hpp index f1a856818..85a761951 100644 --- a/components/compiler/extensions.hpp +++ b/components/compiler/extensions.hpp @@ -44,11 +44,13 @@ namespace Compiler /// - if no match is found 0 is returned. /// - 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 /// 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. void registerFunction (const std::string& keyword, char returnType, diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 3be38bce4..22f7f458d 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -163,7 +163,7 @@ namespace Compiler { std::string argumentType; - if (extensions->isInstruction (keyword, argumentType)) + if (extensions->isInstruction (keyword, argumentType, mState==ExplicitState)) { mExprParser.parseArguments (argumentType, scanner, mCode, true);