ROSE  0.11.50.0
sageInterfaceAda.h
1 
2 
3 #ifndef _SAGEINTERFACE_ADA_H
4 #define _SAGEINTERFACE_ADA_H 1
5 
6 #include "sage3basic.hhh"
7 
8 #include <tuple>
9 
10 namespace SageInterface
11 {
12 
14 namespace ada
15 {
17  typedef std::pair<SgArrayType*, std::vector<SgExpression*> > FlatArrayType;
18 
27 
31  bool unconstrained(const SgArrayType* ty);
32  bool unconstrained(const SgArrayType& ty);
34 
35 
45  FlatArrayType getArrayTypeInfo(SgType* atype);
46  //~ FlatArrayType flattenArrayType(SgType& atype);
48 
56  SgRangeExp* range(const SgAdaAttributeExp* rangeAttribute);
57  SgRangeExp* range(const SgAdaAttributeExp& rangeAttribute);
59 
65 
71 
75  SgStatementPtrList::iterator declarationLimit(SgStatementPtrList& list);
76  SgStatementPtrList::iterator declarationLimit(SgBasicBlock& block);
77  SgStatementPtrList::iterator declarationLimit(SgBasicBlock* block);
78  SgStatementPtrList::const_iterator declarationLimit(const SgStatementPtrList& list);
79  SgStatementPtrList::const_iterator declarationLimit(const SgBasicBlock& block);
80  SgStatementPtrList::const_iterator declarationLimit(const SgBasicBlock* block);
82 
88  bool isFunctionTryBlock(const SgTryStmt& n);
89  bool isFunctionTryBlock(const SgTryStmt* n);
91 
92 
98 
105 
106  //
107  // Ada Variant processing
108 
109  struct VariantInfo : std::tuple<SgExprListExp*, int>
110  {
111  using base = std::tuple<SgExprListExp*, int>;
112  using base::base;
113 
115  SgExprListExp* variants() const { return std::get<0>(*this); }
116 
118  int depth() const { return std::get<1>(*this); }
119  };
120 
122  VariantInfo
124 
126  int getSharedControlDepth(const VariantInfo& prev, const VariantInfo& next);
127 
129  bool haveSameConditionAt(const VariantInfo& prev, const VariantInfo& next, int i);
130 
131  struct VariantEntry : std::tuple<SgVarRefExp*, SgExprListExp*>
132  {
133  using base = std::tuple<SgVarRefExp*, SgExprListExp*>;
134  using base::base;
135 
136  SgVarRefExp* control() const { return std::get<0>(*this); }
137  SgExprListExp* conditions() const { return std::get<1>(*this); }
138  };
139 
141  VariantEntry getVariant(const VariantInfo& prev, int i);
142 
145  SgDeclarationStatementPtrList::const_iterator
146  findVariantConditionChange( SgDeclarationStatementPtrList::const_iterator begin,
147  SgDeclarationStatementPtrList::const_iterator end,
148  const SgAdaVariantFieldDecl* lastVariant
149  );
150 
151  //
152 
153 
154  struct PrimitiveParameterDesc : std::tuple<size_t, const SgInitializedName*>
155  {
156  using base = std::tuple<size_t, const SgInitializedName*>;
157  using base::base;
158 
160  size_t
161  pos() const { return std::get<0>(*this); }
162 
164  const SgInitializedName*
165  name() const { return std::get<1>(*this); }
166  };
167 
170  std::vector<PrimitiveParameterDesc>
172 
173  std::vector<PrimitiveParameterDesc>
176 
186  overridingScope(const SgExprListExp& args, const std::vector<PrimitiveParameterDesc>& primitiveArgs);
187 
189  overridingScope(const SgExprListExp* args, const std::vector<PrimitiveParameterDesc>& primitiveArgs);
191 
193  bool explicitNullProcedure(const SgFunctionDefinition& fndef);
194 
196  bool explicitNullRecord(const SgClassDefinition& recdef);
197 
207  size_t
209 
210  size_t
213 
214 
216  // \todo mv into Ada to C++ converter
217  void convertAdaToCxxComments(SgNode* root, bool cxxLineComments = true);
218 
221 
224  int convertIntLiteral(const char* img);
225 
226  std::string convertStringLiteral(const char* img);
227 
228  long double convertRealLiteral(const char* img);
230 
231 
232 
233 } // Ada
234 } // SageInterface
235 
236 #endif /* _SAGEINTERFACE_ADA_H */
SgDeclarationStatementPtrList::const_iterator findVariantConditionChange(SgDeclarationStatementPtrList::const_iterator begin, SgDeclarationStatementPtrList::const_iterator end, const SgAdaVariantFieldDecl *lastVariant)
finds the next statement in the range [begin, end) that has a different variant condition than lastVa...
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
int getSharedControlDepth(const VariantInfo &prev, const VariantInfo &next)
get the depth of shared of control variables
const SgInitializedName * name() const
the parameters name in form of an SgInitializedName
SgRangeExp * range(const SgAdaAttributeExp *rangeAttribute)
returns a range for the range attribute rangeAttribute.
VariantInfo variantInfo(const SgAdaVariantFieldDecl *n)
returns basic information about the variant declaration
This class represents the base class for all types.
bool withPrivateDefinition(const SgDeclarationStatement *dcl)
tests if the declaration dcl defines a type that is completed in a private section.
This class represents the notion of a declared variable.
std::string convertStringLiteral(const char *img)
converts text to constant values
This class represents the concept of a function declaration statement.
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
This class represents the concept of a C and C++ expression list.
long double convertRealLiteral(const char *img)
converts text to constant values
bool hasUnknownDiscriminants(const SgAdaDiscriminatedTypeDecl &n)
returns true iff n has an unknown discriminant part
This class represents the concept of a class definition in C++.
Functions that are useful when operating on the AST.
Definition: sageBuilder.h:25
bool unconstrained(const SgArrayType *ty)
tests if ty is an unconstrained array
bool isFunctionTryBlock(const SgTryStmt &n)
returns true iff n is an Ada try block
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:9555
int depth() const
the variant nesting level
void convertToCaseSensitiveSymbolTables(SgNode *root)
converts all symbol tables from case insensitive to case sensitive
std::vector< PrimitiveParameterDesc > primitiveParameterPositions(const SgFunctionDeclaration &)
returns the descriptions for parameters that make an operations primitive
This class represents the concept of a block (not a basic block from control flow analysis)...
bool explicitNullRecord(const SgClassDefinition &recdef)
returns true, iff recdef is the body of an explicit null record
SgAdaPackageSpecDecl & getSpecificationDeclaration(const SgAdaPackageBodyDecl &bodyDecl)
returns the declaration node for the package specification
SgStatementPtrList::iterator declarationLimit(SgStatementPtrList &list)
returns the iterator to one past the last declaration (the limit) in the statement sequence...
int convertIntLiteral(const char *img)
converts text to constant values
This class represents the variable refernece in expressions.
SgExprListExp * variants() const
the exprlist condition
size_t positionalArgumentLimit(const SgExprListExp &args)
finds the one past the last positional argument (aka the first named argument position).
bool haveSameConditionAt(const VariantInfo &prev, const VariantInfo &next, int i)
test if prev and next have the same variant condition at position i
SgScopeStatement * overridingScope(const SgExprListExp &args, const std::vector< PrimitiveParameterDesc > &primitiveArgs)
returns the overriding scope of a primitive function based on the associated arguments as defined by ...
SgAdaPackageBodyDecl & getBodyDeclaration(const SgAdaPackageSpecDecl &specDecl)
returns the declaration node for the package body, if available
This class represents the concept of try statement within the try-catch support for exception handlin...
SgAdaDiscriminatedTypeDecl * getAdaDiscriminatedTypeDecl(const SgDeclarationStatement &n)
returns the SgAdaDiscriminatedTypeDecl iff n is discriminated null otherwise
std::pair< SgArrayType *, std::vector< SgExpression * > > FlatArrayType
defines the result type for flattenArrayType
void convertAdaToCxxComments(SgNode *root, bool cxxLineComments=true)
converts all Ada style comments to C++ comments
VariantEntry getVariant(const VariantInfo &prev, int i)
get the control/conditions of the i th entry.
bool explicitNullProcedure(const SgFunctionDefinition &fndef)
returns true, iff fndef is the body of an explicit null procedure
This class represents the concept of a declaration statement.
FlatArrayType getArrayTypeInfo(SgType *atype)
returns a flattened representation of Ada array types.
size_t pos() const
the position within the parameter list