}
}
-void TParseContext::notifyLineDirective(int line, bool has_source, int source)
+void TParseContext::notifyLineDirective(int curLineNo, int newLineNo, bool hasSource, int sourceNum)
{
if (lineCallback) {
- lineCallback(line, has_source, source);
+ lineCallback(curLineNo, newLineNo, hasSource, sourceNum);
}
}
void notifyVersion(int line, int version, const char* type_string);
void notifyErrorDirective(int line, const char* error_message);
- void notifyLineDirective(int line, bool has_source, int source);
+ void notifyLineDirective(int curLineNo, int newLineNo, bool hasSource, int sourceNum);
// The following are implemented in Versions.cpp to localize version/profile/stage/extensions control
void initializeExtensionBehavior();
void setVersionCallback(const std::function<void(int, int, const char*)>& func) { versionCallback = func; }
void setPragmaCallback(const std::function<void(int, const TVector<TString>&)>& func) { pragmaCallback = func; }
- void setLineCallback(const std::function<void(int, bool, int)>& func) { lineCallback = func; }
+ void setLineCallback(const std::function<void(int, int, bool, int)>& func) { lineCallback = func; }
void setExtensionCallback(const std::function<void(int, const char*, const char*)>& func) { extensionCallback = func; }
void setErrorCallback(const std::function<void(int, const char*)>& func) { errorCallback = func; }
// These, if set, will be called when a line, pragma ... is preprocessed.
// They will be called with any parameters to the original directive.
- std::function<void(int, bool, int)> lineCallback;
+ std::function<void(int, int, bool, int)> lineCallback;
std::function<void(int, const TVector<TString>&)> pragmaCallback;
std::function<void(int, int, const char*)> versionCallback;
std::function<void(int, const char*, const char*)> extensionCallback;
adjustLine(line);
outputStream << "#extension " << extension << " : " << behavior;
});
- parseContext.setLineCallback([&lastLine, &outputStream, &parseContext](
- int newLineNo, bool hasSource, int sourceNum) {
+ parseContext.setLineCallback([&adjustLine, &lastLine, &outputStream, &parseContext](
+ int curLineNo, int newLineNo, bool hasSource, int sourceNum) {
// SourceNum is the number of the source-string that is being parsed.
- if (lastLine != -1) {
- outputStream << std::endl;
- }
+ adjustLine(curLineNo);
outputStream << "#line " << newLineNo;
if (hasSource) {
outputStream << " " << sourceNum;
// "#line line source-string-number"
int token = scanToken(ppToken);
+ const int directiveLoc = ppToken->loc.line;
if (token == '\n') {
parseContext.error(ppToken->loc, "must by followed by an integral literal", "#line", "");
return token;
}
}
if (!fileErr && !lineErr) {
- parseContext.notifyLineDirective(lineToken, hasFile, fileRes);
+ parseContext.notifyLineDirective(directiveLoc, lineToken, hasFile, fileRes);
}
token = extraTokenCheck(lineAtom, ppToken, token);