Class AstInterface#
Defined in File AstInterface.h
Inheritance Relationships#
Derived Type#
public CPPAstInterface(Class CPPAstInterface)
Class Documentation#
-
class AstInterface#
provides an abstract interface to access/modify AST nodes.
Subclassed by CPPAstInterface
Public Types
-
enum OperatorEnum#
Values:
-
enumerator OP_NONE#
-
enumerator UOP_MINUS#
-
enumerator UOP_ADDR#
-
enumerator UOP_DEREF#
-
enumerator UOP_ALLOCATE#
-
enumerator UOP_NOT#
-
enumerator UOP_CAST#
-
enumerator UOP_INCR1#
-
enumerator UOP_DECR1#
-
enumerator UOP_BIT_COMPLEMENT#
-
enumerator BOP_DOT_ACCESS#
-
enumerator BOP_ARROW_ACCESS#
-
enumerator BOP_TIMES#
-
enumerator BOP_DIVIDE#
-
enumerator BOP_MOD#
-
enumerator BOP_PLUS#
-
enumerator BOP_MINUS#
-
enumerator BOP_EQ#
-
enumerator BOP_LE#
-
enumerator BOP_LT#
-
enumerator BOP_NE#
-
enumerator BOP_GT#
-
enumerator BOP_GE#
-
enumerator BOP_AND#
-
enumerator BOP_OR#
-
enumerator BOP_BIT_AND#
-
enumerator BOP_BIT_OR#
-
enumerator BOP_BIT_RSHIFT#
-
enumerator BOP_BIT_LSHIFT#
-
enumerator OP_ARRAY_ACCESS#
-
enumerator OP_ASSIGN#
-
enumerator OP_UNKNOWN#
-
enumerator OP_NONE#
-
enum TraversalOrderType#
Values:
-
enumerator PreOrder#
-
enumerator PostOrder#
-
enumerator ReversePreOrder#
-
enumerator ReversePostOrder#
-
enumerator PreAndPostOrder#
-
enumerator PreOrder#
-
typedef void *Ast#
-
typedef std::vector<AstNodeType> AstTypeList#
Public Functions
-
inline AstInterface(AstInterfaceImpl *__impl)#
-
inline ~AstInterface()#
-
inline AstInterfaceImpl *get_impl()#
-
AstNodePtr GetRoot() const#
-
inline AstNodePtr getNULL() const#
-
void SetRoot(const AstNodePtr &root)#
-
void AttachObserver(AstObserver *ob)#
-
void DetachObserver(AstObserver *ob)#
-
bool get_fileInfo(const AstNodePtr &n, std::string *fname = 0, int *lineno = 0)#
-
void InsertStmt(const AstNodePtr &orig, const AstNodePtr &n, bool before = true, bool extractFromBlock = false)#
-
void InsertAnnot(const AstNodePtr &n, const std::string &annot, bool before = true)#
-
bool ReplaceAst(const AstNodePtr &orig, const AstNodePtr &n)#
-
bool RemoveStmt(const AstNodePtr &n)#
-
void FreeAstTree(const AstNodePtr &n)#
-
AstNodePtr CopyAstTree(const AstNodePtr &n)#
-
void SetParent(const AstNodePtr &n, const AstNodePtr &p)#
-
AstNodePtr GetParent(const AstNodePtr &n)#
-
AstNodePtr GetPrevStmt(const AstNodePtr &s)#
-
AstNodePtr GetNextStmt(const AstNodePtr &s)#
-
bool IsDecls(const AstNodePtr &s)#
-
bool IsVariableDecl(const AstNodePtr &exp, AstList *vars = 0, AstList *inits = 0)#
-
bool IsExecutableStmt(const AstNodePtr &s)#
-
AstNodePtr GetBlockFirstStmt(const AstNodePtr &n)#
-
AstNodePtr GetBlockLastStmt(const AstNodePtr &n)#
-
int GetBlockSize(const AstNodePtr &n)#
-
AstNodePtr CreateBlock(const AstNodePtr &orig = AstNodePtr())#
-
void BlockAppendStmt(AstNodePtr &b, const AstNodePtr &s, bool flatten_s = false)#
-
void BlockPrependStmt(AstNodePtr &b, const AstNodePtr &s)#
-
bool IsPostTestLoop(const AstNodePtr &s)#
-
AstNodePtr CreateLoop(const AstNodePtr &cond, const AstNodePtr &body)#
-
AstNodePtr CreateLoop(const AstNodePtr &ivar, const AstNodePtr &lb, const AstNodePtr &ub, const AstNodePtr &step, const AstNodePtr &stmts, bool negativeStep)#
-
AstNodePtr CreateIf(const AstNodePtr &__cond, const AstNodePtr &__if_stmt, const AstNodePtr &__else_stmt = AST_NULL) const#
Creates if-else-statement, or if-statement (if __else_stmt is null).
-
AstNodePtr CreateReadStatement(const AstList &__refs) const#
Creates a statement that reads __refs from stdin.
-
AstNodePtr CreateWriteStatement(const AstList &__vals) const#
Creates a statement that writes __refs to stdout.
-
AstNodePtr CreatePrintStatement(const AstList &__vals) const#
Creates a statement that prints __refs to stdout.
-
AstNodePtr CreateNullStatement() const#
Creates an empty statement.
-
bool IsGoto(const AstNodePtr &s, AstNodePtr *dest = 0)#
Check whether $s$ is a jump (goto, return, continue, break, etc) stmt; if yes, grab the jump destination in ‘dest’.
-
bool IsGotoBefore(const AstNodePtr &s)#
-
bool IsGotoAfter(const AstNodePtr &s)#
-
bool IsLabelStatement(const AstNodePtr &s)#
-
bool IsReturn(const AstNodePtr &s, AstNodePtr *val = 0)#
-
bool GetFunctionCallSideEffect(const AstNodePtr &fc, CollectObject<AstNodePtr> &collectmod, CollectObject<AstNodePtr> &collectread)#
-
bool IsFunctionCall(const AstNodePtr &s, AstNodePtr *f = 0, AstList *args = 0, AstList *outargs = 0, AstTypeList *paramtypes = 0, AstNodeType *returntype = 0)#
Returns true iff s is a function call, false otherwise. But also attempts to extract a bunch of info about the call.
-
bool IsMin(const AstNodePtr &exp)#
-
bool IsMax(const AstNodePtr &exp)#
-
AstNodePtr CreateFunctionCall(const std::string &func, AstList::const_iterator args_begin, AstList::const_iterator args_end)#
-
AstNodePtr CreateFunctionCall(const AstNodePtr &func, AstList::const_iterator args_begin, AstList::const_iterator args_end)#
-
AstNodePtr GetFunctionDefinition(const AstNodePtr &n, std::string *name = 0)#
-
AstNodePtr CreateAssignment(const AstNodePtr &lhs, const AstNodePtr &rhs)#
-
bool IsIOInputStmt(const AstNodePtr &s, AstList *varlist = 0)#
-
bool IsIOOutputStmt(const AstNodePtr &s, AstList *explist = 0)#
-
bool IsMemoryAccess(const AstNodePtr &s)#
-
AstNodeType GetExpressionType(const AstNodePtr &s)#
-
bool IsConstInt(const AstNodePtr &exp, int *value = 0)#
-
AstNodePtr CreateConstInt(int val)#
-
bool IsConstant(const AstNodePtr &exp, std::string *valtype = 0, std::string *value = 0)#
Check whether $exp$ is a constant value of type int, float, string, etc.
-
AstNodePtr CreateConstant(const std::string &valtype, const std::string &val)#
Create AST for constant values of types int, bool, string, float, etc. as well as names of variable and function references. e.g: CreateConstant(“memberfunction”,”floatArray::length”)
-
bool IsSameVarRef(const AstNodePtr &v1, const AstNodePtr &v2)#
-
std::string NewVar(const AstNodeType &t, const std::string &name = "", bool makeunique = false, bool delayInsert = true, const AstNodePtr &declLoc = AstNodePtr(), const AstNodePtr &init = AstNodePtr())#
-
void AddNewVarDecls()#
-
void CopyNewVarDecls(const AstNodePtr &nblock, bool clearNewVars = true)#
-
AstNodePtr CreateVarRef(std::string varname, const AstNodePtr &declLoc = AstNodePtr())#
-
bool IsScalarType(const AstNodeType &t)#
-
bool IsPointerType(const AstNodeType &t)#
-
AstNodeType GetType(const std::string &name)#
-
bool IsCompatibleType(const AstNodeType &t1, const AstNodeType &t2)#
-
bool GetArrayBound(const AstNodePtr &arrayname, int dim, int &lb, int &ub)#
-
AstNodeType GetArrayType(const AstNodeType &base, const AstList &indexsize)#
-
AstNodePtr CreateAllocateArray(const AstNodePtr &arr, const AstNodeType &elemtype, const AstList &indexsize)#
-
AstNodePtr CreateDeleteArray(const AstNodePtr &arr)#
-
bool IsBinaryOp(const AstNodePtr &exp, OperatorEnum *opr = 0, AstNodePtr *opd1 = 0, AstNodePtr *opd2 = 0)#
-
bool IsUnaryOp(const AstNodePtr &exp, OperatorEnum *op = 0, AstNodePtr *opd = 0)#
-
AstNodePtr CreateBinaryOP(OperatorEnum op, const AstNodePtr &a0, const AstNodePtr &a2)#
-
AstNodePtr CreateUnaryOP(OperatorEnum op, const AstNodePtr &arg)#
-
inline AstNodePtr GetParentBlock(const AstNodePtr &__n)#
Returns the enclosing block.
-
inline AstNodePtr GetParentStatement(const AstNodePtr &__n)#
Returns the enclosing statement.
Public Static Functions
-
static std::string toString(OperatorEnum op)#
-
static std::string AstToString(const AstNodePtr &s, bool unparseClassName = true)#
-
static std::string getAstLocation(const AstNodePtr &s)#
-
static std::string unparseToString(const AstNodePtr &s)#
-
static AstList GetChildrenList(const AstNodePtr &n)#
-
static bool IsStatement(const AstNodePtr &s)#
-
static bool IsExprStmt(const AstNodePtr &n, AstNodePtr *exp = 0)#
-
static bool IsBlock(const AstNodePtr &exp)#
-
static AstList GetBlockStmtList(const AstNodePtr &n)#
-
static bool IsLoop(const AstNodePtr &s, AstNodePtr *init = 0, AstNodePtr *cond = 0, AstNodePtr *incr = 0, AstNodePtr *body = 0)#
-
static bool IsFortranLoop(const AstNodePtr &s, AstNodePtr *ivar = 0, AstNodePtr *lb = 0, AstNodePtr *ub = 0, AstNodePtr *step = 0, AstNodePtr *body = 0)#
Check whether $s$ is a Fortran-style loop in the form: for (ivar=lb;ivar<=ub;ivar+=step)
-
static bool IsIf(const AstNodePtr &s, AstNodePtr *cond = 0, AstNodePtr *truebody = 0, AstNodePtr *falsebody = 0)#
-
static bool IsFunctionDefinition(const AstNodePtr &s, std::string *name = 0, AstList *params = 0, AstList *outpars = 0, AstNodePtr *body = 0, AstTypeList *paramtypes = 0, AstNodeType *returntype = 0)#
-
static bool IsAssignment(const AstNodePtr &s, AstNodePtr *lhs = 0, AstNodePtr *rhs = 0, bool *readlhs = 0)#
-
static AstNodePtr IsExpression(const AstNodePtr &s, AstNodeType *exptype = 0)#
-
static SgNode *SkipCasting(SgNode *exp)#
If there is a case, extract the operand and return it, otherwise return exp.
-
static bool IsVarRef(const AstNodePtr &exp, AstNodeType *vartype = 0, std::string *varname = 0, AstNodePtr *scope = 0, bool *isglobal = 0)#
Check whether $exp$ is a variable reference; If yes, return type, name, scope, and global/local etc.
-
static std::string GetVarName(const AstNodePtr &exp)#
-
static std::string GetScopeName(const AstNodePtr &scope)#
-
static bool IsArrayType(const AstNodeType &t, int *dim = 0, AstNodeType *base = 0, std::string *annotation = 0)#
-
static void GetTypeInfo(const AstNodeType &t, std::string *name = 0, std::string *stripname = 0, int *size = 0)#
-
static inline std::string GetTypeName(const AstNodeType &t)#
-
static inline std::string GetBaseTypeName(const AstNodeType &t)#
-
static bool IsArrayAccess(const AstNodePtr &s, AstNodePtr *array = 0, AstList *index = 0)#
-
static AstNodePtr CreateArrayAccess(const AstNodePtr &arr, const AstNodePtr &index)#
-
static bool IsFortranLanguage()#
Protected Attributes
-
AstInterfaceImpl *impl#
-
enum OperatorEnum#