ROSE 0.11.145.317
sageInterfaceAda.h
1
2
3#ifndef _SAGEINTERFACE_ADA_H
4#define _SAGEINTERFACE_ADA_H 1
5
6#include "sage3basic.hhh"
7#include "sageInterface.h"
8
9#include <tuple>
10
11#include <boost/optional.hpp>
12
13namespace SageInterface
14{
15
17namespace Ada
18{
19 template <class SageRefExp>
20 static inline
21 auto symOf(const SageRefExp& n) -> decltype( *n.get_symbol() )
22 {
23 auto* symp = n.get_symbol();
24 ASSERT_not_null(symp);
25
26 return *symp;
27 }
28
29 template <class SageSymbol>
30 static inline
31 auto declOf(const SageSymbol& n) -> decltype( *n.get_declaration() )
32 {
33 auto* dclp = n.get_declaration();
34 ASSERT_not_null(dclp);
35
36 return *dclp;
37 }
38
39 static inline
41 {
42 return declOf(symOf(n));
43 }
44
45 static inline
46 SgInitializedName& declOf(const SgVarRefExp& n)
47 {
48 return declOf(symOf(n));
49 }
50
51
52 // \todo normalize Sage nodes that use this function
53 // and make them go through symbols, like any other
54 // ref exp.
55 template <class SageAdaRefExp>
56 static inline
57 auto declOfRef(const SageAdaRefExp& n) -> decltype( *n.get_decl() )
58 {
59 auto* dclp = n.get_decl();
60 ASSERT_not_null(dclp);
61
62 return *dclp;
63 }
64
65 static inline
67 {
68 return declOfRef(n);
69 }
70
71 static inline
73 {
74 return declOfRef(n);
75 }
76
77 static inline
78 SgAdaTaskSpecDecl& declOf(const SgAdaTaskRefExp& n)
79 {
80 SgAdaTaskSpecDecl* res = isSgAdaTaskSpecDecl(&declOfRef(n));
81
82 ASSERT_not_null(res);
83 return *res;
84 }
85
86 static inline
88 {
89 SgAdaProtectedSpecDecl* res = isSgAdaProtectedSpecDecl(&declOfRef(n));
90
91 ASSERT_not_null(res);
92 return *res;
93 }
94
95 static inline
96 SgLabelStatement& declOf(const SgLabelRefExp& n)
97 {
98 return declOf(symOf(n));
99 }
100
101
102/*
103 inline
104 SgVariableDeclaration& declOf(const SgVariableSymbol& n)
105 {
106 SgNode* varnode = SG_DEREF(n.get_declaration()).get_parent();
107
108 return SG_DEREF(isSgVariableDeclaration(varnode));
109 }
110
111 inline
112 SgVariableDeclaration& declOf(const SgVarRefExp& n)
113 {
114 return declOf(symOf(n));
115 }
116*/
117
118 static inline
119 SgName nameOf(const SgSymbol& sy)
120 {
121 return sy.get_name();
122 }
123
124
125 template <class SageRefExp>
126 static inline
127 auto nameOf(const SageRefExp& n) -> decltype( nameOf(symOf(n)) )
128 {
129 return nameOf(symOf(n));
130 }
131
132 static inline
133 SgName nameOf(const SgEnumVal& n)
134 {
135 return n.get_name();
136 }
137
138 static inline
139 SgName nameOf(const SgAdaUnitRefExp& n)
140 {
141 return SageInterface::get_name(n.get_decl());
142 }
143
144
145/*
146 inline
147 SgName
148 nameOf(const SgAdaRenamingDecl& n)
149 {
150 return n.get_name();
151 }
152*/
153
154
155/*
156 inline
157 SgName nameOf(const SgImportStatement& import)
158 {
159 const SgExpressionPtrList& lst = import.get_import_list();
160 ROSE_ASSERT(lst.size() == 1);
161
162 return nameOf(SG_DEREF(isSgVarRefExp(lst.back())));
163 }
164*/
165
168
169
170 extern const std::string roseOperatorPrefix;
171 extern const std::string packageStandardName;
172 extern const std::string durationTypeName;
173 extern const std::string exceptionName;
174
183
187 bool unconstrained(const SgArrayType* ty);
188 bool unconstrained(const SgArrayType& ty);
190
194 bool anonymousAccess(const SgType* ty);
195 bool anonymousAccess(const SgType& ty);
197
198 using StatementRange = std::pair<SgDeclarationStatementPtrList::iterator, SgDeclarationStatementPtrList::iterator>;
199
209 StatementRange
210 declsInPackage(SgGlobal& globalScope, const std::string& mainFile);
211
212 StatementRange
213 declsInPackage(SgGlobal& globalScope, const SgSourceFile& mainFile);
215
216
224
226 using FlatArrayTypeBase = std::tuple<SgArrayType*, SgExpressionPtrList, bool >;
227
229 {
230 using base = FlatArrayTypeBase;
231 using base::base;
232
233 SgArrayType* type() const { return std::get<0>(*this); }
234 SgExpressionPtrList const& dims() const { return std::get<1>(*this); }
235 SgExpressionPtrList& dims() { return std::get<1>(*this); }
236 bool constrained() const { return std::get<2>(*this); }
237 void constrained(bool b) { std::get<2>(*this) = b; }
238 };
239
251
257
263 SgType& standardType(const std::string& name);
264
265 using RecordFieldBase = std::tuple<const SgSymbol*>;
266
267 struct RecordField : RecordFieldBase
268 {
269 using base = RecordFieldBase;
270 using base::base;
271
272 const SgSymbol& symbol() const;
273 const SgSymbol& originalSymbol() const;
274 const SgClassDefinition& record() const;
275 bool inherited() const { return isSgAliasSymbol(&symbol()); }
276 bool discriminant() const;
277 };
278
279
285 std::vector<RecordField>
287
288 std::vector<RecordField>
291
292
294 template <class SageLocatedNode>
295 struct IfInfo : std::tuple<SgExpression*, SageLocatedNode*>
296 {
297 using base = std::tuple<SgExpression*, SageLocatedNode*>;
298 using base::base;
299
300 SgExpression* condition() const { return std::get<0>(*this); }
301 SageLocatedNode* trueBranch() const { return std::get<1>(*this); }
302 bool isElse() const { return condition() == nullptr; }
303 };
304
309
311 std::vector<IfExpressionInfo>
313
315 std::vector<IfStatementInfo>
317
321 long long int
323
324
328
336 SgRangeExp* range(const SgAdaAttributeExp* rangeAttribute);
337 SgRangeExp* range(const SgAdaAttributeExp& rangeAttribute);
339
345
351
352
358
364
370
376
383
394
398 SgStatementPtrList::iterator declarationLimit(SgStatementPtrList& list);
399 SgStatementPtrList::iterator declarationLimit(SgBasicBlock& block);
400 SgStatementPtrList::iterator declarationLimit(SgBasicBlock* block);
401 SgStatementPtrList::const_iterator declarationLimit(const SgStatementPtrList& list);
402 SgStatementPtrList::const_iterator declarationLimit(const SgBasicBlock& block);
403 SgStatementPtrList::const_iterator declarationLimit(const SgBasicBlock* block);
405
414
415
424
425
431
434 bool isOutInoutArgument(const SgFunctionCallExp& call, const SgExpression& arg);
435 bool isOutInoutArgument(const SgFunctionCallExp* call, const SgExpression* arg);
437
438
439
442 bool isModularType(const SgType& ty);
443 bool isModularType(const SgType* ty);
444 bool isIntegerType(const SgType& ty);
445 bool isIntegerType(const SgType* ty);
448 bool isDiscreteType(const SgType* ty);
449 bool isDiscreteType(const SgType& ty);
450 bool isBooleanType(const SgType* ty);
451 bool isBooleanType(const SgType& ty);
453
458 bool isFixedType(const SgType* ty);
459 bool isFixedType(const SgType& ty);
461
468 bool isScalarType(const SgType* ty);
469 bool isScalarType(const SgType& ty);
471
477
485
490 bool isDecimalFixedType(const SgType* ty);
491 bool isDecimalFixedType(const SgType& ty);
493
494
500 boost::optional<bool>
502
503 boost::optional<bool>
506
507
520
527
535
536
543
549
555
561
562 using TypeDescriptionBase = std::tuple<SgType*, bool, std::vector<SgAdaTypeConstraint*> >;
563
564 struct TypeDescription : TypeDescriptionBase
565 {
566 static constexpr bool classwide = true;
567
568 using base = TypeDescriptionBase;
569
570 explicit
571 TypeDescription(SgType& ty, bool polymorph = false, std::vector<SgAdaTypeConstraint*> constr = {})
572 : base(&ty, polymorph, std::move(constr))
573 {}
574
575 explicit
576 TypeDescription(SgType* ty = nullptr)
577 : base(ty, false, {})
578 {}
579
581 SgType* typerep() const { return std::get<0>(*this); }
582
585
588
589 bool polymorphic() const { return std::get<1>(*this); }
590
591 const std::vector<SgAdaTypeConstraint*>&
592 toplevelConstraints() const & { return std::get<2>(*this); }
593
594 std::vector<SgAdaTypeConstraint*>
595 toplevelConstraints() && { return std::move(std::get<2>(*this)); }
596 };
597
604
612
621
622 using DominantArgInfoBase = std::tuple<const SgType*, std::size_t>;
623
624 struct DominantArgInfo : DominantArgInfoBase
625 {
626 using base = DominantArgInfoBase;
627 using base::base;
628
629 const SgType* type() const { return std::get<0>(*this); }
630 std::size_t pos() const { return std::get<1>(*this); }
631 };
632
634 operatorArgumentWithNamedRootIfAvail(const SgTypePtrList& argtypes);
635
636 using OperatorScopeInfoBase = std::tuple<SgScopeStatement*, std::size_t>;
637
638 struct OperatorScopeInfo : OperatorScopeInfoBase
639 {
640 using base = OperatorScopeInfoBase;
641 using base::base;
642
643 // the scope associated with the dominant parameter
644 SgScopeStatement* scope() const { return std::get<0>(*this); }
645
646 // the position of the dominant parameter in the parameter list
647 std::size_t argpos() const { return std::get<1>(*this); }
648 };
649
657 operatorScope(const std::string& opname, const SgTypePtrList& argtypes);
658
659
669 operatorScope(const std::string& opname, const SgType& ty);
670
672 operatorScope(const std::string& opname, const SgType* ty);
674
675
683
685 using ImportedUnitResultBase = std::tuple< std::string,
687 const SgAdaRenamingDecl*,
688 const SgExpression*
689 >;
690
692 {
693 using base = ImportedUnitResultBase;
694 using base::base;
695
696 const std::string& name() const { return std::get<0>(*this); }
697
698 const SgDeclarationStatement& decl() const
699 {
700 ASSERT_not_null(std::get<1>(*this));
701 return *(std::get<1>(*this));
702 }
703
704 const SgAdaRenamingDecl* renamingDecl() const { return std::get<2>(*this); }
705
706 const SgExpression& unitref() const
707 {
708 ASSERT_not_null(std::get<3>(*this));
709 return *std::get<3>(*this);
710 }
711 };
712
714 std::vector<ImportedUnitResult>
716
717
720
722 SgAdaPackageSpec* findPackageSpec(const std::string& s);
723
725 SgType* findType(const SgScopeStatement& scope, const std::string& typeName);
726
729 SgType* findType(const std::string& scopeName, const std::string& typeName);
730
734 std::string convertRoseOperatorNameToAdaName(const std::string& nameInRose);
735
739 std::string convertRoseOperatorNameToAdaOperator(const std::string& nameInRose);
740
743 SgExpressionPtrList::const_iterator,
744 SgExpressionPtrList::const_iterator
745 >;
746
748 {
749 using base = AggregateInfoBase;
750 using base::base;
751
753 SgAdaAncestorInitializer* ancestor() const { return std::get<0>(*this); }
754
756 SgExpressionPtrList::const_iterator begin() const { return std::get<1>(*this); }
757
759 SgExpressionPtrList::const_iterator end() const { return std::get<2>(*this); }
760
762 bool nullRecord() const { return begin() == end(); }
763 };
764
771
772
779
780
783 bool isFunction(const SgFunctionType& ty);
784 bool isFunction(const SgFunctionType* ty);
788
796
797
803
809
810 using PrimitiveParameterDescBase = std::tuple<size_t, const SgInitializedName*, const SgDeclarationStatement*>;
811
812 struct PrimitiveParameterDesc : PrimitiveParameterDescBase
813 {
814 using base = PrimitiveParameterDescBase;
815 using base::base;
816
818 size_t
819 pos() const { return std::get<0>(*this); }
820
822 const SgInitializedName*
823 name() const { return std::get<1>(*this); }
824
827 typeDeclaration() const { return std::get<2>(*this); }
828 };
829
848 std::vector<PrimitiveParameterDesc>
850
851 std::vector<PrimitiveParameterDesc>
854
855 using PrimitiveSignatureElementsDescBase = std::tuple< const SgDeclarationStatement*
856 , std::vector<PrimitiveParameterDesc>
857 >;
858
859 struct PrimitiveSignatureElementsDesc : PrimitiveSignatureElementsDescBase
860 {
861 using base = PrimitiveSignatureElementsDescBase;
862 using base::base;
863
865 result() const { return std::get<0>(*this); }
866
867 const std::vector<PrimitiveParameterDesc>&
868 parameters() const & { return std::get<1>(*this); }
869
870 std::vector<PrimitiveParameterDesc>
871 parameters() && { return std::move(std::get<1>(*this)); }
872 };
873
879
883
884
891
894
897
901
911 SgExpressionPtrList
912 normalizedCallArguments2(const SgFunctionCallExp& n, const SgFunctionParameterList& arglist, bool withDefaultArguments = false);
913
924 SgExpressionPtrList
925 normalizedCallArguments(const SgFunctionCallExp& n, bool withDefaultArguments = false);
927
936
940
941
949 std::size_t
951
952
965 std::tuple<const SgScopeStatement*, const SgSymbol*>
966 findSymbolInContext(std::string id, const SgScopeStatement& scope, const SgScopeStatement* limit = nullptr);
968
969
970
980 overridingScope(const SgExprListExp& args, const std::vector<PrimitiveParameterDesc>& primitiveArgs);
981
983 overridingScope(const SgExprListExp* args, const std::vector<PrimitiveParameterDesc>& primitiveArgs);
985
992
995
1005
1009
1010
1014
1025
1038 SgType*
1039 baseType(const SgType& ty);
1040
1041 SgType*
1042 baseType(const SgType* ty);
1044
1045
1056
1060
1069 SgEnumType*
1071
1072 SgEnumType*
1075
1076
1079
1082
1090
1091
1101 size_t
1102 positionalArgumentLimit(const SgExpressionPtrList& arglst);
1103
1104 size_t
1106
1107 size_t
1110
1119
1130 const SgFunctionType& drvFunTy,
1131 const SgNamedType& dervTy
1132 );
1133
1135 bool isAttribute(const SgAdaAttributeExp& attr, const std::string& attrname);
1136
1141
1149 isPragma(const SgPragmaDeclaration& prgdcl, const std::string& pragmaname);
1150
1152 SgNodePtrList unparsedChildren(SgNode& n);
1153
1154
1168 void simpleTraversal(std::function<void(SgNode*)>&& fn, SgNode* root);
1169 void simpleTraversal(std::function<void(SgNode*)>&& fn, StatementRange roots);
1171
1174 void conversionTraversal(std::function<void(SgNode*)>&& fn, SgNode* root);
1175 void conversionTraversal(std::function<void(SgNode*)>&& fn, StatementRange roots);
1177
1178
1184
1187 long long int convertIntegerLiteral(const char* img);
1188
1189 std::string convertStringLiteral(const char* img);
1190
1191 long double convertRealLiteral(const char* img);
1192
1193 char convertCharLiteral(const char* img);
1195
1204 struct ScopePath : private std::vector<const SgScopeStatement*>
1205 {
1206 using base = std::vector<const SgScopeStatement*>;
1207 using base::base;
1208
1209 using base::const_reverse_iterator;
1210 using base::reverse_iterator;
1211 using base::const_iterator;
1212 using base::value_type;
1213 using base::reference;
1214
1215 using base::end;
1216 using base::begin;
1217 using base::rend;
1218 using base::rbegin;
1219
1220 using base::size;
1221 using base::back;
1222
1224 void push_back(base::value_type ptr)
1225 {
1226 ROSE_ASSERT(isSgScopeStatement(ptr) || isSgDeclarationStatement(ptr));
1227 ROSE_ASSERT(!isSgGlobal(ptr));
1228
1229 base::push_back(ptr);
1230 }
1231 };
1232
1239
1243 // void copyFileInfo(SgExpression& tgt, const SgExpression& src);
1245
1257
1259 // \todo mv into Ada to C++ converter
1260 void convertAdaToCxxComments(SgNode* root, bool cxxLineComments = true);
1261
1263 // \todo mv into Ada to C++ converter
1265
1274 // \todo mv into Ada to C++ converter
1275 void convertToOperatorRepresentation(SgNode* root, bool convertCallSyntax = false, bool convertNamedArguments = false);
1276} // Ada
1277} // SageInterface
1278
1279#endif /* _SAGEINTERFACE_ADA_H */
This class represents the concept of a block (not a basic block from control flow analysis).
This class represents the concept of a class definition in C++.
This class represents the concept of a C trinary conditional expression (e.g. "test ?...
This class represents the concept of a declaration statement.
This class represents the concept of an enum declaration.
This class represents the concept of a C and C++ expression list.
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes,...
This class represents the variable declaration or variable initialization withn a for loop.
This class represents the concept of a for loop.
This class represents the concept of a C++ function call (which is an expression).
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,...
This class represents the concept of a declaration list.
This class represents the function being called and must be assembled in the SgFunctionCall with the ...
This class represents a type for all functions.
This class represents the concept of a namespace definition.
This class represents the concept of an "if" construct.
This class represents the notion of a declared variable.
This class represents the concept of a C or C++ label statement.
This class represents the notion of an expression or statement which has a position within the source...
This class represents strings within the IR nodes.
This class represents the base class for all IR nodes within Sage III.
This class represents the concept of a C Assembler statement (untested).
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope,...
This class represents the notion of a statement.
This class represents the concept of a name within the compiler.
virtual SgName get_name() const =0
Access function for getting name from declarations or types internally.
This class represents the concept of try statement within the try-catch support for exception handlin...
This class represents the base class for all types.
This class represents the variable refernece in expressions.
This class represents the concept of a C or C++ variable declaration.
bool tryFollowsDeclarativeBlock(const SgTryStmt &n)
returns true iff n is a try block following a declarative region
std::string convertRoseOperatorNameToAdaOperator(const std::string &nameInRose)
takes a function name as used in ROSE and converts it to an operator in Ada (i.e.,...
void conversionTraversal(std::function< void(SgNode *)> &&fn, SgNode *root)
bool systemPackage(const SgScopeStatement &n)
returns true if the scope n is part of a system package
bool isFixedType(const SgType *ty)
returns if the type ty is a fixed point type
SgAdaPackageBody & getBodyDefinition(const SgAdaPackageSpec &spec)
returns the body definition (scope) of the package specification
bool isBooleanType(const SgType *ty)
return if the type ty is the corresponding universal type representation in ROSE
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 ...
PrimitiveSignatureElementsDesc primitiveSignatureElements(const SgFunctionDeclaration &)
returns the descriptions for result type and parameters that make an operation primitive.
FlatArrayType getArrayTypeInfo(SgType *atype)
returns a flattened representation of Ada array types.
SgFunctionSymbol * findPubliclyVisibleFunction(SgFunctionSymbol &fnsym, const SgFunctionType &drvFunTy, const SgNamedType &dervTy)
finds the function symbol for a publicly accessible function.
bool denotesRange(const SgExpression &e)
returns true if the expression e denotes a range
bool resolvesToFixedType(const SgType *ty)
returns if the type ty resolves to a fixed point type
std::tuple< SgAdaAncestorInitializer *, SgExpressionPtrList::const_iterator, SgExpressionPtrList::const_iterator > AggregateInfoBase
Details of expression aggregates.
StatementRange declsInPackage(SgGlobal &globalScope, const std::string &mainFile)
returns all statements/declarations in the global scope that were defined in the source file.
SgExpressionPtrList normalizedCallArguments2(const SgFunctionCallExp &n, const SgFunctionParameterList &arglist, bool withDefaultArguments=false)
returns a list of arguments with named arguments placed at the correct position by taking into accoun...
std::string convertStringLiteral(const char *img)
converts text to constant values
std::vector< IfExpressionInfo > flattenIfExpressions(const SgConditionalExp &n)
returns a flat representation of if expressions
void convertToCaseSensitiveSymbolTables(SgNode *root)
converts all symbol tables from case insensitive to case sensitive
SgAdaDiscriminatedTypeDecl * getAdaDiscriminatedTypeDecl(const SgDeclarationStatement &n)
returns the SgAdaDiscriminatedTypeDecl iff n is discriminated null otherwise
void copyFileInfo(SgLocatedNode &tgt, const SgLocatedNode &src)
copies the source code location from src to tgt.
bool isObjectRenaming(const SgAdaRenamingDecl *dcl)
returns true iff ty refers to an object renaming
void setSourcePositionInSubtreeToCompilerGenerated(SgLocatedNode *n)
sets source position in entire subtree of n to compiler generated
AggregateInfo splitAggregate(const SgExprListExp &exp)
returns the ancestor initializer, if exp refers to an extension aggregate null otherwise
bool isFloatingPointType(const SgType &ty)
return if the type ty is the corresponding universal type representation in ROSE
const SgFunctionType * functionType(const SgFunctionSymbol *fnsy)
returns the static type of the function symbol fnsy
void simpleTraversal(std::function< void(SgNode *)> &&fn, SgNode *root)
Traverses all AST nodes in an unspecified order.
bool isAnyAccessAttribute(const SgAdaAttributeExp &attr)
tests if attr is an access attribute
size_t positionalArgumentLimit(const SgExpressionPtrList &arglst)
finds the one past the last positional argument (aka the first named argument position).
SgScopeStatement * logicalParentScope(const SgScopeStatement &s)
returns the logical parent scope of a scope s.
SgAdaPackageSpecDecl * renamedPackage(const SgAdaRenamingDecl &n)
returns a package spec decl if the declaration n renames a package returns nullptr otherwise
SgExprListExp * isPragma(const SgPragmaDeclaration &prgdcl, const std::string &pragmaname)
tests if prgdcl is a pragma with name pragmaname.
bool isSeparatedDefinition(const SgFunctionDeclaration &n)
returns true iff n is a separated function definition is separated
SgExpression * underlyingExpr(const SgStatement *s)
returns the expression of an expression statement, or nullptr if s is some other node
std::tuple< SgArrayType *, SgExpressionPtrList, bool > FlatArrayTypeBase
defines the result type for getArrayTypeInfo
long long int convertIntegerLiteral(const char *img)
converts text to constant values
SgScopeStatement * pkgStandardScope()
do not use, this is temporary
bool isSeparatedBody(const SgDeclarationStatement &n)
returns true iff n is a unit definition that has been separated
bool isScalarType(const SgType *ty)
returns true if ty refers to a scalar type
SgDeclarationStatement * associatedDeclaration(const SgSymbol &n)
returns the associated declaration for symbol n or nullptr if there is none.
SgAdaPackageSpec * findPackageSpec(const std::string &s)
returns the scope of a package spec
const SgVariableDeclaration * exceptionTypeDecl(const SgVariableDeclaration &n)
returns n or a pointer to n if n declares an exception type.
SgType * findType(const SgScopeStatement &scope, const std::string &typeName)
returns the type representation of a type named typeName in scope scope.
bool explicitNullProcedure(const SgFunctionDefinition &fndef)
returns true, iff fndef is the body of an explicit null procedure
SgEnumType * characterBaseType(SgEnumType *ty)
checks if the type is based on one of the Standard character types.
bool isDiscreteType(const SgType *ty)
return if the type ty is the corresponding universal type representation in ROSE
bool explicitNullRecord(const SgClassDefinition &recdef)
returns true, iff recdef is the body of an explicit null record
OperatorScopeInfo operatorScope(const std::string &opname, const SgTypePtrList &argtypes)
returns the scope where an operator with name opname and argument types in argtypes shall be declared...
bool unconstrained(const SgArrayType *ty)
tests if ty is an unconstrained array
bool isDiscreteArrayType(const SgType &ty)
returns true if ty refers to a discrete array type
std::vector< PrimitiveParameterDesc > primitiveParameterPositions(const SgFunctionDeclaration &fn)
returns the descriptions for parameters that make an operation primitive.
std::tuple< const SgScopeStatement *, const SgSymbol * > findSymbolInContext(std::string id, const SgScopeStatement &scope, const SgScopeStatement *limit=nullptr)
finds the symbol with Naming tips in the context of scope or its logical parents in the range [scope,...
void convertToOperatorRepresentation(SgNode *root, bool convertCallSyntax=false, bool convertNamedArguments=false)
converts AST from a function call representation to operator form for fundamental operator declaratio...
SgFunctionParameterList * calleeParameterList(const SgFunctionCallExp &n)
returns the function parameter list of the associated callee (if available).
boost::optional< bool > booleanConstant(const SgExpression *e)
if e denotes an Ada boolean constant, it is returned; otherwise an empty result is returned.
bool isIntegerType(const SgType &ty)
return if the type ty is the corresponding universal type representation in ROSE
bool isReverseForLoop(const SgForStatement *n)
returns true, iff n is a reverse for loop; returns false otherwise
const SgScopeStatement * canonicalScope(const SgScopeStatement *scope)
returns the canonical scope of some Ada scope scope.
SgAdaGenericDecl & getGenericDecl(const SgAdaGenericInstanceDecl &n)
Returns SgAdaGenericDecl for a given SgAdaGenericInstanceDecl.
SgAdaGenericDecl * isGenericDecl(const SgDeclarationStatement &n)
Returns the SgAdaGenericDecl node that makes a declaration (either function/procedure or package) gen...
SgType & standardType(const std::string &name)
returns a type from the standard package with name name.
bool isModularType(const SgType &ty)
return if the type ty is the corresponding universal type representation in ROSE
bool unitRefDenotesGenericInstance(const SgAdaUnitRefExp &n)
returns true iff n refers to a generic declaration from inside said declaration false otherwise (e....
bool anonymousAccess(const SgType *ty)
tests if ty is an anonymous access type
bool isFunction(const SgFunctionType &ty)
returns true iff ty refers to a function type (as opposed to procedure)
bool isAttribute(const SgAdaAttributeExp &attr, const std::string &attrname)
tests if attr is an attribute with name attrname.
std::tuple< std::string, const SgDeclarationStatement *, const SgAdaRenamingDecl *, const SgExpression * > ImportedUnitResultBase
describes properties of imported units
char convertCharLiteral(const char *img)
converts text to constant values
SgRangeExp * range(const SgAdaAttributeExp *rangeAttribute)
returns a range for the range attribute rangeAttribute.
long double convertRealLiteral(const char *img)
converts text to constant values
bool isExceptionRenaming(const SgAdaRenamingDecl *dcl)
returns true iff ty refers to an exception renaming
std::vector< IfStatementInfo > flattenIfStatements(const SgIfStmt &n)
returns a flat representation of if-elsif-else statements
bool isDecimalFixedType(const SgType *ty)
returns if the type ty is a decimal fixed point type
TypeDescription typeOfExpr(const SgExpression &)
returns the type of an expression corrects for some peculiarities in the AST
SgType * baseOfAccessType(const SgType *ty)
returns the base type if ty is an access type
bool blockExistsInSource(const SgBasicBlock *blk)
checks if the block blk is present in the Ada source code.
SgStatementPtrList::iterator declarationLimit(SgStatementPtrList &list)
returns the iterator to one past the last declaration (the limit) in the statement sequence.
std::vector< RecordField > getAllRecordFields(const SgClassDefinition &rec)
returns all fields (defined and inherited) of a record.
SgAdaPackageSpec & getSpecificationDefinition(const SgAdaPackageBody &body)
returns the specification definition (scope) of the package body
long long int staticIntegralValue(const SgExpression *n)
integer constant folding
SgNodePtrList unparsedChildren(SgNode &n)
returns a container of children nodes that are relevant for unparsing.
bool isPackageTryBlock(const SgTryStmt &n)
returns true iff n is an Ada package try block
SgType * baseType(const SgType &ty)
returns the base type of a type ty
bool hasSeparatedBody(const SgDeclarationStatement &dcl)
tests if the declaration decl corresponds to a stub (aka separated unit)
std::size_t normalizedArgumentPosition(const SgFunctionCallExp &call, const SgExpression &arg)
returns the parameter position of arg in the callee, after the parameters have been normalized.
int firstLastDimension(SgExprListExp &args)
returns an integer value for args[0] as used by type attributes first and last
bool isOutInoutArgument(const SgFunctionCallExp &call, const SgExpression &arg)
returns true if arg is used as l-value in the call
bool withPrivateDefinition(const SgDeclarationStatement *dcl)
tests if the declaration dcl defines a public type that is completed in a private section.
bool sameCanonicalScope(const SgScopeStatement *lhs, const SgScopeStatement *rhs)
tests if lhs and have the same canonical scope.
void convertAdaToCxxComments(SgNode *root, bool cxxLineComments=true)
/}
ScopePath pathToGlobal(const SgScopeStatement &n)
Constructs a path from a scope statement to the top-level (global) scope.
SgAdaPackageSpecDecl & getSpecificationDeclaration(const SgAdaPackageBodyDecl &bodyDecl)
returns the declaration node for the package specification
SgExpression * boundsExpression(SgType &atype)
returns the bounds expression of a type
const SgScopeStatement * correspondingBody(const SgScopeStatement *scope)
returns the body scope (aka definition) of a task, package, or protected object.
std::vector< ImportedUnitResult > importedUnits(const SgImportStatement &impdcl)
queries properties of all units in an import statement
SgScopeStatement * declarationScope(const SgType *ty)
returns the scope where type ty has been declared
SgEnumDeclaration * baseEnumDeclaration(const SgType *ty)
finds the underlying enum declaration of a type ty
TypeDescription typeRoot(SgType &)
returns the most fundamental type after skipping subtypes, typedefs, etc.
SgAdaPackageBodyDecl & getPackageBodyDeclaration(const SgAdaPackageSpecDecl &specDecl)
returns the declaration node for the package body, if available
bool hasUnknownDiscriminants(const SgAdaDiscriminatedTypeDecl &n)
returns true iff n has an unknown discriminant part
std::string convertRoseOperatorNameToAdaName(const std::string &nameInRose)
takes a function name as used in ROSE and converts it to a name in Ada (i.e., '"' + operator_text + '...
SgExpressionPtrList normalizedCallArguments(const SgFunctionCallExp &n, bool withDefaultArguments=false)
attempts to identify the argument list automatically and uses it to invoke the preceding normalizedCa...
Functions that are useful when operating on the AST.
Definition sageBuilder.h:25
std::string get_name(const SgNode *node)
Generate a useful name to describe the SgNode.
SgExpressionPtrList::const_iterator begin() const
returns the remaining range-begin without the ancestor initializer (if it existed)
SgExpressionPtrList::const_iterator end() const
returns the underlying's list end iterator
bool nullRecord() const
returns if the remaining range (w/o the ancestor initializer) indicates a null record.
SgAdaAncestorInitializer * ancestor() const
returns the ancestor initializer iff it exists, otherwise null
represents a branch in an if elsif else context (either statement or expression).
const SgDeclarationStatement * typeDeclaration() const
the associated type declaration
const SgInitializedName * name() const
the parameter's name in form of an SgInitializedName
size_t pos() const
the position within the parameter list
stores a path from an innermost scope to the global scope (not part of the path) in form of a sequenc...
void push_back(base::value_type ptr)
overload vector's push_back to check element validity
SgType * typerep() const
the type, nullptr if it could not be found
SgType * dominantTyperep() const
returns the dominant type. i.e., the definition
SgType & typerep_ref() const
asserts that the type exists and returns the reference