3 #ifndef _SAGEINTERFACE_ADA_H
4 #define _SAGEINTERFACE_ADA_H 1
6 #include "sage3basic.hhh"
7 #include "sageInterface.h"
20 template <
class SageRefExp>
21 auto symOf(
const SageRefExp& n) -> decltype( *n.get_symbol() )
23 auto* symp = n.get_symbol();
24 ASSERT_not_null(symp);
29 template <
class SageSymbol>
30 auto declOf(
const SageSymbol& n) -> decltype( *n.get_declaration() )
32 auto* dclp = n.get_declaration();
33 ASSERT_not_null(dclp);
41 return declOf(symOf(n));
47 return declOf(symOf(n));
54 template <
class SageAdaRefExp>
55 auto declOfRef(
const SageAdaRefExp& n) -> decltype( *n.get_decl() )
57 auto* dclp = n.get_decl();
58 ASSERT_not_null(dclp);
90 return declOf(symOf(n));
117 template <
class SageRefExp>
119 auto nameOf(
const SageRefExp& n) -> decltype( nameOf(symOf(n)) )
121 return nameOf(symOf(n));
124 template <
class SageRefExp>
126 auto nameOf(
const SageRefExp& n) -> decltype( n.get_decl()->get_name() )
128 return declOf(n).get_name();
169 extern const std::string roseOperatorPrefix;
170 extern const std::string packageStandardName;
171 extern const std::string durationTypeName;
172 extern const std::string exceptionName;
190 using StatementRange = std::pair<SgDeclarationStatementPtrList::iterator, SgDeclarationStatementPtrList::iterator>;
218 struct FlatArrayType : std::tuple<SgArrayType*, std::vector<SgExpression*> >
220 using base = std::tuple<SgArrayType*, std::vector<SgExpression*> >;
223 SgArrayType* type()
const {
return std::get<0>(*this); }
224 std::vector<SgExpression*>
const& dims()
const {
return std::get<1>(*this); }
225 std::vector<SgExpression*>& dims() {
return std::get<1>(*this); }
243 using base = std::tuple<const SgSymbol*>;
247 const SgSymbol& originalSymbol()
const;
249 bool inherited()
const {
return isSgAliasSymbol(&symbol()); }
250 bool discriminant()
const;
259 std::vector<RecordField>
262 std::vector<RecordField>
268 template <
class SageLocatedNode>
269 struct IfInfo : std::tuple<SgExpression*, SageLocatedNode*>
271 using base = std::tuple<SgExpression*, SageLocatedNode*>;
274 SgExpression* condition()
const {
return std::get<0>(*this); }
275 SageLocatedNode* trueBranch()
const {
return std::get<1>(*this); }
276 bool isElse()
const {
return condition() ==
nullptr; }
285 std::vector<IfExpressionInfo>
289 std::vector<IfStatementInfo>
356 SgStatementPtrList::const_iterator
declarationLimit(
const SgStatementPtrList& list);
494 using base = std::tuple<SgType*, bool>;
497 SgType* typerep()
const {
return std::get<0>(*this); }
498 SgType& typerep_ref()
const;
499 bool polymorphic()
const {
return std::get<1>(*this); }
519 using base = std::tuple<const SgType*, std::size_t>;
522 const SgType* type()
const {
return std::get<0>(*this); }
523 std::size_t pos()
const {
return std::get<1>(*this); }
527 operatorArgumentWithNamedRootIfAvail(
const SgTypePtrList& argtypes);
531 using base = std::tuple<SgScopeStatement*, std::size_t>;
538 std::size_t argpos()
const {
return std::get<1>(*this); }
548 operatorScope(
const std::string& opname,
const SgTypePtrList& argtypes);
576 struct ImportedUnitResult : std::tuple<std::string, const SgDeclarationStatement*, const SgAdaRenamingDecl*>
578 using base = std::tuple<std::string, const SgDeclarationStatement*, const SgAdaRenamingDecl*>;
581 const std::string& name()
const {
return std::get<0>(*this); }
585 ASSERT_not_null(std::get<1>(*
this));
586 return *(std::get<1>(*this));
616 SgExpressionPtrList::const_iterator,
617 SgExpressionPtrList::const_iterator
621 SgExpressionPtrList::const_iterator,
622 SgExpressionPtrList::const_iterator
627 SgAdaAncestorInitializer*
ancestor()
const {
return std::get<0>(*this); }
630 SgExpressionPtrList::const_iterator
begin()
const {
return std::get<1>(*this); }
633 SgExpressionPtrList::const_iterator
end()
const {
return std::get<2>(*this); }
686 using base = std::tuple<size_t, const SgInitializedName*>;
691 pos()
const {
return std::get<0>(*this); }
695 name()
const {
return std::get<1>(*this); }
700 std::vector<PrimitiveParameterDesc>
703 std::vector<PrimitiveParameterDesc>
740 std::tuple<const SgScopeStatement*, const SgSymbol*>
bool isSeparatedDefinition(const SgFunctionDeclaration &n)
returns true iff n is a separated function definition is separated
describes properties of imported units
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
const SgScopeStatement * canonicalScope(const SgScopeStatement *scope)
returns the canonical scope of some Ada scope scope.
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 unitRefDenotesGenericInstance(const SgAdaUnitRefExp &n)
returns true iff n refers to a generic declaration from inside said declaration false otherwise (e...
SgScopeStatement * logicalParentScope(const SgScopeStatement &s)
returns the logical parent scope of a scope s.
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...
StatementRange declsInPackage(SgGlobal &globalScope, const std::string &mainFile)
returns all statements/declarations in the global scope that were defined in the source file...
std::string convertStringLiteral(const char *img)
converts text to constant values
This class represents the base class for all types.
bool tryFollowsDeclarativeBlock(const SgTryStmt &n)
returns true iff n is a try block following a declarative region
int firstLastDimension(SgExprListExp &args)
returns an integer value for args[0] as used by type attributes first and last
This class represents the concept of an enum declaration.
SgAdaPackageSpecDecl & getSpecificationDeclaration(const SgAdaPackageBodyDecl &bodyDecl)
returns the declaration node for the package specification
This class represents the notion of a declared variable.
bool explicitNullProcedure(const SgFunctionDefinition &fndef)
returns true, iff fndef is the body of an explicit null procedure
void convertToCaseSensitiveSymbolTables(SgNode *root)
converts all symbol tables from case insensitive to case sensitive
bool isFixedType(const SgType *ty)
returns if the type ty is a fixed point type
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.).
TypeDescription typeRoot(SgType &)
returns the most fundamental type after skipping subtypes, typedefs, etc.
This class represents the concept of a C and C++ expression list.
SgStatementPtrList::iterator declarationLimit(SgStatementPtrList &list)
returns the iterator to one past the last declaration (the limit) in the statement sequence...
Details of expression aggregates.
std::string get_name(const SgNode *node)
Generate a useful name to describe the SgNode.
SgExpression * underlyingExpr(const SgStatement *s)
returns the expression of an expression statement, or nullptr if s is some other node ...
SgAdaGenericDecl & getGenericDecl(const SgAdaGenericInstanceDecl &n)
Returns SgAdaGenericDecl for a given SgAdaGenericInstanceDecl.
SgRangeExp * range(const SgAdaAttributeExp *rangeAttribute)
returns a range for the range attribute rangeAttribute.
size_t pos() const
the position within the parameter list
bool hasUnknownDiscriminants(const SgAdaDiscriminatedTypeDecl &n)
returns true iff n has an unknown discriminant part
This class represents the concept of a C trinary conditional expression (e.g. "test ...
SgAdaGenericDecl * isGenericDecl(const SgDeclarationStatement &n)
Returns the SgAdaGenericDecl node that makes a declaration (either function/procedure or package) gen...
bool isModularType(const SgType &ty)
return if the type ty is the corresponding universal type representation in ROSE
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes, since similar to statement, expressions have a concrete location within the user's source code.
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 + '...
bool explicitNullRecord(const SgClassDefinition &recdef)
returns true, iff recdef is the body of an explicit null record
defines the result type for getArrayTypeInfo
SgEnumDeclaration * baseEnumDeclaration(SgType *ty)
finds the underlying enum declaration of a type ty
This class represents the concept of a name within the compiler.
bool resolvesToFixedType(const SgType *ty)
returns if the type ty resolves to a fixed point type
SgScopeStatement * pkgStandardScope()
do not use, this is temporary
const SgInitializedName * name() const
the parameter's name in form of an SgInitializedName
This class represents the concept of a class definition in C++.
This class represents strings within the IR nodes.
SgAdaPackageSpecDecl * renamedPackage(const SgAdaRenamingDecl &n)
returns a package spec decl if the declaration n renames a package returns nullptr otherwise ...
ImportedUnitResult importedUnit(const SgImportStatement &impdcl)
queries properties of an imported unit
bool isDecimalFixedType(const SgType *ty)
returns if the type ty is a decimal fixed point type
Functions that are useful when operating on the AST.
bool isExceptionRenaming(const SgAdaRenamingDecl *dcl)
returns true iff ty refers to an exception renaming
bool withPrivateDefinition(const SgDeclarationStatement *dcl)
tests if the declaration dcl defines a public type that is completed in a private section...
bool isBooleanType(const SgType *ty)
return if the type ty is the corresponding universal type representation in ROSE
represents a branch in an if elsif else context (either statement or expression). ...
SgExpressionPtrList normalizedCallArguments(const SgFunctionCallExp &n)
returns a list of arguments with named arguments placed at the correct position
std::vector< IfStatementInfo > flattenIfStatements(SgIfStmt &n)
returns a flat representation of if-elsif-else statements
This class represents the base class for all IR nodes within Sage III.
long double convertRealLiteral(const char *img)
converts text to constant values
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
This class represents the concept of a block (not a basic block from control flow analysis)...
This class represents the notion of a statement.
This class represents the concept of a namespace definition.
long long int staticIntegralValue(SgExpression *n)
integer constant folding
const SgExpression & importedElement(const SgImportStatement &n)
returns the imported element (i.e., the first entry in n's import_list
TypeDescription typeOfExpr(SgExpression &)
returns the type of an expression corrects for some peculiarities in the AST
bool isScalarType(const SgType *ty)
returns true if ty refers to a scalar type
bool unconstrained(const SgArrayType *ty)
tests if ty is an unconstrained array
bool isDiscreteType(const SgType *ty)
return if the type ty is the corresponding universal type representation in ROSE
This class represents a type for all functions.
const SgFunctionType * functionType(const SgFunctionSymbol *fnsy)
returns the static type of the function symbol fnsy
SgDeclarationStatement * associatedDeclaration(const SgSymbol &n)
returns the associated declaration for symbol n or nullptr if there is none.
This class represents the concept of an "if" construct.
bool isFloatingPointType(const SgType &ty)
return if the type ty is the corresponding universal type representation in ROSE
size_t positionalArgumentLimit(const SgExpressionPtrList &arglst)
finds the one past the last positional argument (aka the first named argument position).
std::vector< IfExpressionInfo > flattenIfExpressions(SgConditionalExp &n)
returns a flat representation of if expressions
void convertToOperatorRepresentation(SgNode *root, bool convertCallSyntax=false, bool convertNamedArguments=false)
converts AST from a function call representation to operator form for fundamental operator declaratio...
This class represents the variable refernece in expressions.
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...
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., operator_text).
SgExpressionPtrList::const_iterator end() const
returns the underlying's list end iterator
SgExpressionPtrList::const_iterator begin() const
returns the remaining range-begin without the ancestor initializer (if it existed) ...
bool isFunction(const SgFunctionType &ty)
returns true iff ty refers to a function type (as opposed to procedure)
AggregateInfo splitAggregate(const SgExprListExp &exp)
returns the ancestor initializer, if exp refers to an extension aggregate null otherwise ...
const SgScopeStatement * correspondingBody(const SgScopeStatement *scope)
returns the body scope (aka definition) of a task, package, or protected object.
This class represents the function being called and must be assembled in the SgFunctionCall with the ...
This class represents the concept of try statement within the try-catch support for exception handlin...
std::vector< RecordField > getAllRecordFields(const SgClassDefinition &rec)
returns all fields (defined and inherited) of a record.
SgAdaPackageBodyDecl & getPackageBodyDeclaration(const SgAdaPackageSpecDecl &specDecl)
returns the declaration node for the package body, if available
bool hasSeparatedBody(const SgDeclarationStatement &dcl)
tests if the declaration decl corresponds to a stub (aka separated unit)
char convertCharLiteral(const char *img)
converts text to constant values
SgScopeStatement * declarationScope(const SgType *ty)
returns the scope where type ty has been declared
bool isObjectRenaming(const SgAdaRenamingDecl *dcl)
returns true iff ty refers to an object renaming
SgAdaDiscriminatedTypeDecl * getAdaDiscriminatedTypeDecl(const SgDeclarationStatement &n)
returns the SgAdaDiscriminatedTypeDecl iff n is discriminated null otherwise
bool nullRecord() const
returns if the remaining range (w/o the ancestor initializer) indicates a null record.
std::vector< PrimitiveParameterDesc > primitiveParameterPositions(const SgFunctionDeclaration &)
returns the descriptions for parameters that make an operation primitive
bool sameCanonicalScope(const SgScopeStatement *lhs, const SgScopeStatement *rhs)
tests if lhs and have the same canonical scope.
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 ...
bool isSeparatedBody(const SgDeclarationStatement &n)
returns true iff n is a unit definition that has been separated
This class represents the concept of a C or C++ label statement.
long long int convertIntegerLiteral(const char *img)
converts text to constant values
This class represents the concept of a C++ function call (which is an expression).
bool isDiscreteArrayType(const SgType &ty)
returns true if ty refers to a discrete array type
SgAdaAncestorInitializer * ancestor() const
returns the ancestor initializer iff it exists, otherwise null
This class represents the concept of a declaration statement.
virtual SgName get_name() const =0
Access function for getting name from declarations or types internally.
void convertAdaToCxxComments(SgNode *root, bool cxxLineComments=true)
converts all Ada style comments to C++ comments
FlatArrayType getArrayTypeInfo(SgType *atype)
returns a flattened representation of Ada array types.
bool isIntegerType(const SgType &ty)
return if the type ty is the corresponding universal type representation in ROSE