bump simplecpp
This commit is contained in:
parent
a007ba7d3c
commit
31ef266036
|
@ -202,14 +202,15 @@ simplecpp::TokenList::~TokenList()
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplecpp::TokenList::operator=(const TokenList &other)
|
simplecpp::TokenList &simplecpp::TokenList::operator=(const TokenList &other)
|
||||||
{
|
{
|
||||||
if (this == &other)
|
if (this != &other) {
|
||||||
return;
|
clear();
|
||||||
clear();
|
for (const Token *tok = other.cfront(); tok; tok = tok->next)
|
||||||
for (const Token *tok = other.cfront(); tok; tok = tok->next)
|
push_back(new Token(*tok));
|
||||||
push_back(new Token(*tok));
|
sizeOfType = other.sizeOfType;
|
||||||
sizeOfType = other.sizeOfType;
|
}
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplecpp::TokenList::clear()
|
void simplecpp::TokenList::clear()
|
||||||
|
@ -1023,25 +1024,25 @@ namespace simplecpp {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expand macro. This will recursively expand inner macros.
|
* Expand macro. This will recursively expand inner macros.
|
||||||
* @param output destination tokenlist
|
* @param output destination tokenlist
|
||||||
* @param rawtok macro token
|
* @param rawtok macro token
|
||||||
* @param macros list of macros
|
* @param macros list of macros
|
||||||
* @param files the files
|
* @param inputFiles the input files
|
||||||
* @return token after macro
|
* @return token after macro
|
||||||
* @throw Can throw wrongNumberOfParameters or invalidHashHash
|
* @throw Can throw wrongNumberOfParameters or invalidHashHash
|
||||||
*/
|
*/
|
||||||
const Token * expand(TokenList * const output,
|
const Token * expand(TokenList * const output,
|
||||||
const Token * rawtok,
|
const Token * rawtok,
|
||||||
const std::map<TokenString,Macro> ¯os,
|
const std::map<TokenString,Macro> ¯os,
|
||||||
std::vector<std::string> &files) const {
|
std::vector<std::string> &inputFiles) const {
|
||||||
std::set<TokenString> expandedmacros;
|
std::set<TokenString> expandedmacros;
|
||||||
|
|
||||||
TokenList output2(files);
|
TokenList output2(inputFiles);
|
||||||
|
|
||||||
if (functionLike() && rawtok->next && rawtok->next->op == '(') {
|
if (functionLike() && rawtok->next && rawtok->next->op == '(') {
|
||||||
// Copy macro call to a new tokenlist with no linebreaks
|
// Copy macro call to a new tokenlist with no linebreaks
|
||||||
const Token * const rawtok1 = rawtok;
|
const Token * const rawtok1 = rawtok;
|
||||||
TokenList rawtokens2(files);
|
TokenList rawtokens2(inputFiles);
|
||||||
rawtokens2.push_back(new Token(rawtok->str, rawtok1->location));
|
rawtokens2.push_back(new Token(rawtok->str, rawtok1->location));
|
||||||
rawtok = rawtok->next;
|
rawtok = rawtok->next;
|
||||||
rawtokens2.push_back(new Token(rawtok->str, rawtok1->location));
|
rawtokens2.push_back(new Token(rawtok->str, rawtok1->location));
|
||||||
|
@ -1084,7 +1085,7 @@ namespace simplecpp {
|
||||||
const std::map<TokenString,Macro>::const_iterator macro = macros.find(macro2tok->str);
|
const std::map<TokenString,Macro>::const_iterator macro = macros.find(macro2tok->str);
|
||||||
if (macro == macros.end() || !macro->second.functionLike())
|
if (macro == macros.end() || !macro->second.functionLike())
|
||||||
break;
|
break;
|
||||||
TokenList rawtokens2(files);
|
TokenList rawtokens2(inputFiles);
|
||||||
const Location loc(macro2tok->location);
|
const Location loc(macro2tok->location);
|
||||||
while (macro2tok) {
|
while (macro2tok) {
|
||||||
Token *next = macro2tok->next;
|
Token *next = macro2tok->next;
|
||||||
|
@ -1640,7 +1641,7 @@ namespace simplecpp {
|
||||||
return nextTok;
|
return nextTok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isReplaced(const std::set<std::string> &expandedmacros) const {
|
static bool isReplaced(const std::set<std::string> &expandedmacros) {
|
||||||
// return true if size > 1
|
// return true if size > 1
|
||||||
std::set<std::string>::const_iterator it = expandedmacros.begin();
|
std::set<std::string>::const_iterator it = expandedmacros.begin();
|
||||||
if (it == expandedmacros.end())
|
if (it == expandedmacros.end())
|
||||||
|
@ -1760,7 +1761,7 @@ static bool isAbsolutePath(const std::string &path)
|
||||||
{
|
{
|
||||||
if (path.length() >= 3 && path[0] > 0 && std::isalpha(path[0]) && path[1] == ':' && (path[2] == '\\' || path[2] == '/'))
|
if (path.length() >= 3 && path[0] > 0 && std::isalpha(path[0]) && path[1] == ':' && (path[2] == '\\' || path[2] == '/'))
|
||||||
return true;
|
return true;
|
||||||
return path.length() > 1U && (path[0] == '/' || path[0] == '/');
|
return path.length() > 1U && (path[0] == '/' || path[0] == '\\');
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define realFilename(f) f
|
#define realFilename(f) f
|
||||||
|
|
|
@ -52,6 +52,8 @@ namespace simplecpp {
|
||||||
public:
|
public:
|
||||||
explicit Location(const std::vector<std::string> &f) : files(f), fileIndex(0), line(1U), col(0U) {}
|
explicit Location(const std::vector<std::string> &f) : files(f), fileIndex(0), line(1U), col(0U) {}
|
||||||
|
|
||||||
|
Location(const Location &loc) : files(loc.files), fileIndex(loc.fileIndex), line(loc.line), col(loc.col) {}
|
||||||
|
|
||||||
Location &operator=(const Location &other) {
|
Location &operator=(const Location &other) {
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
fileIndex = other.fileIndex;
|
fileIndex = other.fileIndex;
|
||||||
|
@ -77,14 +79,15 @@ namespace simplecpp {
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& file() const {
|
const std::string& file() const {
|
||||||
static const std::string temp;
|
return fileIndex < files.size() ? files[fileIndex] : emptyFileName;
|
||||||
return fileIndex < files.size() ? files[fileIndex] : temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string> &files;
|
const std::vector<std::string> &files;
|
||||||
unsigned int fileIndex;
|
unsigned int fileIndex;
|
||||||
unsigned int line;
|
unsigned int line;
|
||||||
unsigned int col;
|
unsigned int col;
|
||||||
|
private:
|
||||||
|
const std::string emptyFileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,6 +150,9 @@ namespace simplecpp {
|
||||||
void printOut() const;
|
void printOut() const;
|
||||||
private:
|
private:
|
||||||
TokenString string;
|
TokenString string;
|
||||||
|
|
||||||
|
// Not implemented - prevent assignment
|
||||||
|
Token &operator=(const Token &tok);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Output from preprocessor */
|
/** Output from preprocessor */
|
||||||
|
@ -173,13 +179,13 @@ namespace simplecpp {
|
||||||
TokenList(std::istream &istr, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = 0);
|
TokenList(std::istream &istr, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = 0);
|
||||||
TokenList(const TokenList &other);
|
TokenList(const TokenList &other);
|
||||||
~TokenList();
|
~TokenList();
|
||||||
void operator=(const TokenList &other);
|
TokenList &operator=(const TokenList &other);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
bool empty() const {
|
bool empty() const {
|
||||||
return !frontToken;
|
return !frontToken;
|
||||||
}
|
}
|
||||||
void push_back(Token *token);
|
void push_back(Token *tok);
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
std::string stringify() const;
|
std::string stringify() const;
|
||||||
|
@ -246,7 +252,7 @@ namespace simplecpp {
|
||||||
void constFoldComparison(Token *tok);
|
void constFoldComparison(Token *tok);
|
||||||
void constFoldBitwise(Token *tok);
|
void constFoldBitwise(Token *tok);
|
||||||
void constFoldLogicalOp(Token *tok);
|
void constFoldLogicalOp(Token *tok);
|
||||||
void constFoldQuestionOp(Token **tok);
|
void constFoldQuestionOp(Token **tok1);
|
||||||
|
|
||||||
std::string readUntil(std::istream &istr, const Location &location, const char start, const char end, OutputList *outputList);
|
std::string readUntil(std::istream &istr, const Location &location, const char start, const char end, OutputList *outputList);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue