moved
This commit is contained in:
57
Sapfor/_src/Utils/DefUseList.h
Normal file
57
Sapfor/_src/Utils/DefUseList.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
struct DefUseList
|
||||
{
|
||||
private:
|
||||
int type; // def(0) or use(1)
|
||||
SgStatement *place;
|
||||
SgExpression *expr;
|
||||
SgFile *file;
|
||||
std::pair<SgSymbol*, std::string> paramOfFunction;
|
||||
int parameterPosition;
|
||||
std::pair<SgSymbol*, std::string> varName;
|
||||
int parameterPositionInFunction;
|
||||
|
||||
public:
|
||||
explicit DefUseList(int type, SgStatement *place, SgExpression *expr, SgFile *file,
|
||||
const std::pair<SgSymbol*, std::string> &inFuncParam,
|
||||
const std::pair<SgSymbol*, std::string> &varName,
|
||||
const int parameterPosition, const int paramenterPostionInFunction) :
|
||||
type(type), place(place), expr(expr), file(file), paramOfFunction(inFuncParam), varName(varName),
|
||||
parameterPosition(parameterPosition), parameterPositionInFunction(paramenterPostionInFunction)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool isDef() const { return type == 0; }
|
||||
bool isUse() const { return type == 1; }
|
||||
std::string getVar() const { return varName.second; }
|
||||
SgSymbol* getVarS() const { return varName.first; }
|
||||
SgFile* getFile() const { return file; }
|
||||
SgStatement* getPlace() const { return place; }
|
||||
SgExpression* getExpr() const { return expr; }
|
||||
std::string getParamOfFunction() const { return paramOfFunction.second; }
|
||||
SgSymbol* getParamOfFunctionS() const { return paramOfFunction.first; }
|
||||
int getParameterPosition() const { return parameterPosition; }
|
||||
int getParameterPositionInFunction() const { return parameterPositionInFunction; }
|
||||
|
||||
void print(FILE *fileOut = NULL, const bool onlyPositiveLine = false) const
|
||||
{
|
||||
if (onlyPositiveLine && place->lineNumber() < 0)
|
||||
return;
|
||||
if (fileOut == NULL)
|
||||
{
|
||||
printf("%s: [file: %s, line: %d], '%s' ", (type == 0) ? "DEF" : "USE", file->filename(), place->lineNumber(), varName.second.c_str());
|
||||
if (parameterPosition != -1)
|
||||
printf(" under call of '%s' function on %d position of args (alt pos %d)", paramOfFunction.second.c_str(), parameterPosition, parameterPositionInFunction);
|
||||
printf("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(fileOut, "%s: [file: %s, line: %d], '%s' ", (type == 0) ? "DEF" : "USE", file->filename(), place->lineNumber(), varName.second.c_str());
|
||||
if (parameterPosition != -1)
|
||||
fprintf(fileOut, " under call of '%s' function on %d position of args (alt pos %d)", paramOfFunction.second.c_str(), parameterPosition, parameterPositionInFunction);
|
||||
fprintf(fileOut, "\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user