ROSE  0.11.66.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  using StatementRange = std::pair<SgDeclarationStatementPtrList::iterator, SgDeclarationStatementPtrList::iterator>;
36 
46  StatementRange
47  declsInPackage(SgGlobal& globalScope, const std::string& mainFile);
48 
49  StatementRange
50  declsInPackage(SgGlobal& globalScope, const SgSourceFile& mainFile);
52 
53 
63  FlatArrayType getArrayTypeInfo(SgType* atype);
64  //~ FlatArrayType flattenArrayType(SgType& atype);
66 
74  SgRangeExp* range(const SgAdaAttributeExp* rangeAttribute);
75  SgRangeExp* range(const SgAdaAttributeExp& rangeAttribute);
77 
83 
89 
93  SgStatementPtrList::iterator declarationLimit(SgStatementPtrList& list);
94  SgStatementPtrList::iterator declarationLimit(SgBasicBlock& block);
95  SgStatementPtrList::iterator declarationLimit(SgBasicBlock* block);
96  SgStatementPtrList::const_iterator declarationLimit(const SgStatementPtrList& list);
97  SgStatementPtrList::const_iterator declarationLimit(const SgBasicBlock& block);
98  SgStatementPtrList::const_iterator declarationLimit(const SgBasicBlock* block);
100 
106  bool isFunctionTryBlock(const SgTryStmt& n);
107  bool isFunctionTryBlock(const SgTryStmt* n);
109 
110 
116 
123 
130 
131 
134  bool isFunction(const SgFunctionType& ty);
135  bool isFunction(const SgFunctionType* ty);
137 
138  //
139  // Ada Variant processing
140 
141  struct VariantInfo : std::tuple<SgExprListExp*, int>
142  {
143  using base = std::tuple<SgExprListExp*, int>;
144  using base::base;
145 
147  SgExprListExp* variants() const { return std::get<0>(*this); }
148 
150  int depth() const { return std::get<1>(*this); }
151  };
152 
154  VariantInfo
156 
158  int getSharedControlDepth(const VariantInfo& prev, const VariantInfo& next);
159 
161  bool haveSameConditionAt(const VariantInfo& prev, const VariantInfo& next, int i);
162 
163  struct VariantEntry : std::tuple<SgVarRefExp*, SgExprListExp*>
164  {
165  using base = std::tuple<SgVarRefExp*, SgExprListExp*>;
166  using base::base;
167 
168  SgVarRefExp* control() const { return std::get<0>(*this); }
169  SgExprListExp* conditions() const { return std::get<1>(*this); }
170  };
171 
173  VariantEntry getVariant(const VariantInfo& prev, int i);
174 
177  SgDeclarationStatementPtrList::const_iterator
178  findVariantConditionChange( SgDeclarationStatementPtrList::const_iterator begin,
179  SgDeclarationStatementPtrList::const_iterator end,
180  const SgAdaVariantFieldDecl* lastVariant
181  );
182 
183  //
184 
185 
186  struct PrimitiveParameterDesc : std::tuple<size_t, const SgInitializedName*>
187  {
188  using base = std::tuple<size_t, const SgInitializedName*>;
189  using base::base;
190 
192  size_t
193  pos() const { return std::get<0>(*this); }
194 
196  const SgInitializedName*
197  name() const { return std::get<1>(*this); }
198  };
199 
202  std::vector<PrimitiveParameterDesc>
204 
205  std::vector<PrimitiveParameterDesc>
208 
218  overridingScope(const SgExprListExp& args, const std::vector<PrimitiveParameterDesc>& primitiveArgs);
219 
221  overridingScope(const SgExprListExp* args, const std::vector<PrimitiveParameterDesc>& primitiveArgs);
223 
230  baseDeclaration(SgType& ty);
231 
233  baseDeclaration(SgType* ty);
235 
237  bool explicitNullProcedure(const SgFunctionDefinition& fndef);
238 
240  bool explicitNullRecord(const SgClassDefinition& recdef);
241 
251  size_t
253 
254  size_t
257 
258 
260  // \todo mv into Ada to C++ converter
261  void convertAdaToCxxComments(SgNode* root, bool cxxLineComments = true);
262 
265 
268  int convertIntLiteral(const char* img);
269 
270  std::string convertStringLiteral(const char* img);
271 
272  long double convertRealLiteral(const char* img);
273 
274  char convertCharLiteral(const char* img);
276 
277 
278 
279 } // Ada
280 } // SageInterface
281 
282 #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
SgAdaPackageSymbol * renamedPackageSymbol(const SgAdaRenamingDecl &n)
returns a package symbol if the declaration n renames a package returns nullptr otherwise ...
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 public 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
SgDeclarationStatement * baseDeclaration(SgType &ty)
finds the type declaration of a type
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
char convertCharLiteral(const char *img)
converts text to constant values
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:9627
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)...
This class represents the concept of a namespace definition.
bool explicitNullRecord(const SgClassDefinition &recdef)
returns true, iff recdef is the body of an explicit null record
This class represents a type for all functions.
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
StatementRange declsInPackage(SgGlobal &globalScope, const std::string &mainFile)
returns all statements/declarations in the global scope that were defined in the source file...
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 isFunction(const SgFunctionType &ty)
returns true iff ty refers to a function type (as opposed to procedure)
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