ROSE  0.11.98.0
Classes | Typedefs | Functions | Variables
SageInterface::ada Namespace Reference

Description

Contains Ada-specific functionality.

Classes

struct  AggregateInfo
 Details of expression aggregates. More...
 
struct  IfInfo
 represents a branch in an if elsif else context (either statement or expression). More...
 
struct  PrimitiveParameterDesc
 

Typedefs

using StatementRange = std::pair< SgDeclarationStatementPtrList::iterator, SgDeclarationStatementPtrList::iterator >
 
using FlatArrayType = std::pair< SgArrayType *, std::vector< SgExpression * > >
 defines the result type for getArrayTypeInfo
 
using IfExpressionInfo = IfInfo< SgExpression >
 returns a sequence of if (x) then value the last else does not have
 
using IfStatementInfo = IfInfo< SgStatement >
 

Functions

std::vector< IfExpressionInfoflattenIfExpressions (SgConditionalExp &n)
 returns a flat representation of if expressions
 
std::vector< IfStatementInfoflattenIfStatements (SgIfStmt &n)
 returns a flat representation of if-elsif-else statements
 
long long int staticIntegralValue (SgExpression *n)
 integer constant folding More...
 
SgExpressionunderlyingExpr (const SgStatement *s)
 returns the expression of an expression statement, or nullptr if s is some other node
 
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 + '"'). More...
 
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). More...
 
bool explicitNullProcedure (const SgFunctionDefinition &fndef)
 returns true, iff fndef is the body of an explicit null procedure
 
bool explicitNullRecord (const SgClassDefinition &recdef)
 returns true, iff recdef is the body of an explicit null record
 
void convertAdaToCxxComments (SgNode *root, bool cxxLineComments=true)
 converts all Ada style comments to C++ comments
 
void convertToCaseSensitiveSymbolTables (SgNode *root)
 converts all symbol tables from case insensitive to case sensitive
 
void convertToOperatorRepresentation (SgNode *root, bool convertCallSyntax=false, bool convertNamedArguments=false)
 converts AST from a function call representation to operator form for fundamental operator declarations. More...
 
bool withPrivateDefinition (const SgDeclarationStatement *dcl)
 tests if the declaration dcl defines a public type that is completed in a private section. More...
 
bool withPrivateDefinition (const SgDeclarationStatement &dcl)
 tests if the declaration dcl defines a public type that is completed in a private section. More...
 
bool unconstrained (const SgArrayType *ty)
 tests if ty is an unconstrained array More...
 
bool unconstrained (const SgArrayType &ty)
 tests if ty is an unconstrained array More...
 
StatementRange declsInPackage (SgGlobal &globalScope, const std::string &mainFile)
 returns all statements/declarations in the global scope that were defined in the source file. More...
 
StatementRange declsInPackage (SgGlobal &globalScope, const SgSourceFile &mainFile)
 returns all statements/declarations in the global scope that were defined in the source file. More...
 
int firstLastDimension (SgExprListExp &args)
 returns an integer value for args[0] as used by type attributes first and last More...
 
int firstLastDimension (SgExprListExp *args)
 returns an integer value for args[0] as used by type attributes first and last More...
 
FlatArrayType getArrayTypeInfo (SgType *atype)
 returns a flattened representation of Ada array types. More...
 
SgRangeExprange (const SgAdaAttributeExp *rangeAttribute)
 returns a range for the range attribute rangeAttribute. More...
 
SgRangeExprange (const SgAdaAttributeExp &rangeAttribute)
 returns a range for the range attribute rangeAttribute. More...
 
SgAdaPackageSpecDeclgetSpecificationDeclaration (const SgAdaPackageBodyDecl &bodyDecl)
 returns the declaration node for the package specification
 
SgAdaPackageSpecDeclgetSpecificationDeclaration (const SgAdaPackageBodyDecl *bodyDecl)
 returns the declaration node for the package specification
 
SgAdaPackageBodyDeclgetBodyDeclaration (const SgAdaPackageSpecDecl &specDecl)
 returns the declaration node for the package body, if available
 
SgAdaPackageBodyDeclgetBodyDeclaration (const SgAdaPackageSpecDecl *specDecl)
 returns the declaration node for the package body, if available
 
SgStatementPtrList::iterator declarationLimit (SgStatementPtrList &list)
 returns the iterator to one past the last declaration (the limit) in the statement sequence.
 
SgStatementPtrList::iterator declarationLimit (SgBasicBlock &block)
 returns the iterator to one past the last declaration (the limit) in the statement sequence.
 
SgStatementPtrList::iterator declarationLimit (SgBasicBlock *block)
 returns the iterator to one past the last declaration (the limit) in the statement sequence.
 
SgStatementPtrList::const_iterator declarationLimit (const SgStatementPtrList &list)
 returns the iterator to one past the last declaration (the limit) in the statement sequence.
 
SgStatementPtrList::const_iterator declarationLimit (const SgBasicBlock &block)
 returns the iterator to one past the last declaration (the limit) in the statement sequence.
 
SgStatementPtrList::const_iterator declarationLimit (const SgBasicBlock *block)
 returns the iterator to one past the last declaration (the limit) in the statement sequence.
 
bool isFunctionTryBlock (const SgTryStmt &n)
 returns true iff n is an Ada function try block More...
 
bool isFunctionTryBlock (const SgTryStmt *n)
 returns true iff n is an Ada function try block More...
 
bool isPackageTryBlock (const SgTryStmt &n)
 returns true iff n is an Ada package try block More...
 
bool isPackageTryBlock (const SgTryStmt *n)
 returns true iff n is an Ada package try block More...
 
bool hasUnknownDiscriminants (const SgAdaDiscriminatedTypeDecl &n)
 returns true iff n has an unknown discriminant part
 
bool hasUnknownDiscriminants (const SgAdaDiscriminatedTypeDecl *n)
 returns true iff n has an unknown discriminant part
 
bool isModularType (const SgType &ty)
 return if the type ty is the corresponding universal type representation in ROSE
 
bool isModularType (const SgType *ty)
 return if the type ty is the corresponding universal type representation in ROSE
 
bool isIntegerType (const SgType &ty)
 return if the type ty is the corresponding universal type representation in ROSE
 
bool isIntegerType (const SgType *ty)
 return if the type ty is the corresponding universal type representation in ROSE
 
bool isFloatingPointType (const SgType &ty)
 return if the type ty is the corresponding universal type representation in ROSE
 
bool isFloatingPointType (const SgType *ty)
 return if the type ty is the corresponding universal type representation in ROSE
 
bool isDiscreteType (const SgType *ty)
 return if the type ty is the corresponding universal type representation in ROSE
 
bool isDiscreteType (const SgType &ty)
 return if the type ty is the corresponding universal type representation in ROSE
 
bool isFixedType (const SgType *ty)
 returns if the type ty is a fixed point type More...
 
bool isFixedType (const SgType &ty)
 returns if the type ty is a fixed point type More...
 
bool isDecimalFixedType (const SgType *ty)
 returns if the type ty is a decimal fixed point type More...
 
bool isDecimalFixedType (const SgType &ty)
 returns if the type ty is a decimal fixed point type More...
 
SgAdaGenericDeclisGenericDecl (const SgDeclarationStatement &n)
 Returns the SgAdaGenericDecl node that makes a declaration (either function/procedure or package) generic. More...
 
SgAdaGenericDeclisGenericDecl (const SgDeclarationStatement *n)
 Returns the SgAdaGenericDecl node that makes a declaration (either function/procedure or package) generic. More...
 
SgAdaGenericDeclgetGenericDecl (const SgAdaGenericInstanceDecl &n)
 Returns SgAdaGenericDecl for a given SgAdaGenericInstanceDecl. More...
 
SgAdaGenericDeclgetGenericDecl (const SgAdaGenericInstanceDecl *n)
 Returns SgAdaGenericDecl for a given SgAdaGenericInstanceDecl. More...
 
SgAdaDiscriminatedTypeDeclgetAdaDiscriminatedTypeDecl (const SgDeclarationStatement &n)
 returns the SgAdaDiscriminatedTypeDecl iff n is discriminated null otherwise
 
SgAdaDiscriminatedTypeDeclgetAdaDiscriminatedTypeDecl (const SgDeclarationStatement *n)
 returns the SgAdaDiscriminatedTypeDecl iff n is discriminated null otherwise
 
bool hasSeparatedBody (const SgDeclarationStatement &dcl)
 tests if the declaration decl corresponds to a stub (aka separated unit)
 
bool hasSeparatedBody (const SgDeclarationStatement *dcl)
 tests if the declaration decl corresponds to a stub (aka separated unit)
 
bool isSeparatedBody (const SgDeclarationStatement &n)
 returns true iff n is a unit definition that has been separated
 
bool isSeparatedBody (const SgDeclarationStatement *n)
 returns true iff n is a unit definition that has been separated
 
SgTypetypeRoot (SgType &)
 returns the most fundamental type after skipping derived types, subtypes, typedefs, etc.
 
SgTypetypeRoot (SgType *)
 returns the most fundamental type after skipping derived types, subtypes, typedefs, etc.
 
SgTypetypeOfExpr (SgExpression &)
 returns the type of an expression corrects for some peculiarities in the AST More...
 
SgTypetypeOfExpr (SgExpression *)
 returns the type of an expression corrects for some peculiarities in the AST More...
 
SgScopeStatementscopeOfTypedecl (const SgType &ty)
 returns the scope where ty was defined
 
SgScopeStatementscopeOfTypedecl (const SgType *ty)
 returns the scope where ty was defined
 
AggregateInfo splitAggregate (const SgExprListExp &exp)
 returns the ancestor initializer, if exp refers to an extension aggregate null otherwise
 
AggregateInfo splitAggregate (const SgExprListExp *exp)
 returns the ancestor initializer, if exp refers to an extension aggregate null otherwise
 
SgAdaPackageSpecDeclrenamedPackage (const SgAdaRenamingDecl &n)
 returns a package spec decl if the declaration n renames a package returns nullptr otherwise
 
SgAdaPackageSpecDeclrenamedPackage (const SgAdaRenamingDecl *n)
 returns a package spec decl if the declaration n renames a package returns nullptr otherwise
 
bool isFunction (const SgFunctionType &ty)
 returns true iff ty refers to a function type (as opposed to procedure)
 
bool isFunction (const SgFunctionType *ty)
 returns true iff ty refers to a function type (as opposed to procedure)
 
bool isObjectRenaming (const SgAdaRenamingDecl *dcl)
 returns true iff ty refers to an object renaming
 
bool isObjectRenaming (const SgAdaRenamingDecl &dcl)
 returns true iff ty refers to an object renaming
 
bool isExceptionRenaming (const SgAdaRenamingDecl *dcl)
 returns true iff ty refers to an exception renaming
 
bool isExceptionRenaming (const SgAdaRenamingDecl &dcl)
 returns true iff ty refers to an exception renaming
 
std::vector< PrimitiveParameterDescprimitiveParameterPositions (const SgFunctionDeclaration &)
 returns the descriptions for parameters that make an operations primitive
 
std::vector< PrimitiveParameterDescprimitiveParameterPositions (const SgFunctionDeclaration *)
 returns the descriptions for parameters that make an operations primitive
 
SgScopeStatementoverridingScope (const SgExprListExp &args, const std::vector< PrimitiveParameterDesc > &primitiveArgs)
 returns the overriding scope of a primitive function based on the associated arguments as defined by the argument list args and the primitive argument positions defined by primitiveArgs. More...
 
SgScopeStatementoverridingScope (const SgExprListExp *args, const std::vector< PrimitiveParameterDesc > &primitiveArgs)
 returns the overriding scope of a primitive function based on the associated arguments as defined by the argument list args and the primitive argument positions defined by primitiveArgs. More...
 
SgDeclarationStatementbaseDeclaration (SgType &ty)
 finds the type declaration of a type ty More...
 
SgDeclarationStatementbaseDeclaration (SgType *ty)
 finds the type declaration of a type ty More...
 
SgEnumDeclarationbaseEnumDeclaration (SgType *ty)
 finds the underlying enum declaration of a type ty More...
 
SgEnumDeclarationbaseEnumDeclaration (SgType &ty)
 finds the underlying enum declaration of a type ty More...
 
size_t positionalArgumentLimit (const SgExpressionPtrList &arglst)
 finds the one past the last positional argument (aka the first named argument position). More...
 
size_t positionalArgumentLimit (const SgExprListExp &args)
 finds the one past the last positional argument (aka the first named argument position). More...
 
size_t positionalArgumentLimit (const SgExprListExp *args)
 finds the one past the last positional argument (aka the first named argument position). More...
 
long long int convertIntegerLiteral (const char *img)
 converts text to constant values
 
std::string convertStringLiteral (const char *img)
 converts text to constant values
 
long double convertRealLiteral (const char *img)
 converts text to constant values
 
char convertCharLiteral (const char *img)
 converts text to constant values
 

Variables

const std::string roseOperatorPrefix
 
const std::string packageStandardName
 
const std::string durationTypeName
 
const std::string exceptionName
 

Function Documentation

bool SageInterface::ada::withPrivateDefinition ( const SgDeclarationStatement dcl)

tests if the declaration dcl defines a public type that is completed in a private section.

Returns
true, iff dcl is public and completed in a private section.
Precondition
dcl is not null and points to a first-nondefining declaration.
bool SageInterface::ada::withPrivateDefinition ( const SgDeclarationStatement dcl)

tests if the declaration dcl defines a public type that is completed in a private section.

Returns
true, iff dcl is public and completed in a private section.
Precondition
dcl is not null and points to a first-nondefining declaration.
bool SageInterface::ada::unconstrained ( const SgArrayType ty)

tests if ty is an unconstrained array

Returns
true iff ty is unconstrained
bool SageInterface::ada::unconstrained ( const SgArrayType ty)

tests if ty is an unconstrained array

Returns
true iff ty is unconstrained
StatementRange SageInterface::ada::declsInPackage ( SgGlobal globalScope,
const std::string &  mainFile 
)

returns all statements/declarations in the global scope that were defined in the source file.

Parameters
globalScopea reference to the global scope
mainfilea reference to the main source file (name)
Returns
a range [first-in-sequence, limit-of-sequence) of global-scope level statements in mainFile

In other words, the declarations in the with'ed packages are excluded from the returned range.

StatementRange SageInterface::ada::declsInPackage ( SgGlobal globalScope,
const SgSourceFile mainFile 
)

returns all statements/declarations in the global scope that were defined in the source file.

Parameters
globalScopea reference to the global scope
mainfilea reference to the main source file (name)
Returns
a range [first-in-sequence, limit-of-sequence) of global-scope level statements in mainFile

In other words, the declarations in the with'ed packages are excluded from the returned range.

int SageInterface::ada::firstLastDimension ( SgExprListExp args)

returns an integer value for args[0] as used by type attributes first and last

Exceptions
throwsan exception if args[0] cannot be constant folded
Note
currently only constant values are supported
int SageInterface::ada::firstLastDimension ( SgExprListExp args)

returns an integer value for args[0] as used by type attributes first and last

Exceptions
throwsan exception if args[0] cannot be constant folded
Note
currently only constant values are supported
FlatArrayType SageInterface::ada::getArrayTypeInfo ( SgType atype)

returns a flattened representation of Ada array types.

Parameters
atypethe type of the array to be flattened.
Returns
iff is not an arraytype, a pair <nullptr, empty vector> is returned otherwise a pair of a array pointer, and a vector of index ranges. Index ranges can be specified in terms of a range (SgRangeExp), a type attribute (SgAdaAttributeExp), or full type range (SgTypeExpression). (the expressions are part of the AST and MUST NOT BE DELETED).
Precondition
atype is not null.
long long int SageInterface::ada::staticIntegralValue ( SgExpression n)

integer constant folding

Returns
an integral value for an Ada expression if possible
Exceptions
anexception otherwise.
SgRangeExp* SageInterface::ada::range ( const SgAdaAttributeExp rangeAttribute)

returns a range for the range attribute rangeAttribute.

Returns
a range if rangeAttribute is a range attribute and a range expression is in the AST; nullptr otherwise.
Exceptions
astd::runtime_error if the rangeAttribute uses an index specification that is not an integral constant expression.
Precondition
rangeAttribute is not null
SgRangeExp* SageInterface::ada::range ( const SgAdaAttributeExp rangeAttribute)

returns a range for the range attribute rangeAttribute.

Returns
a range if rangeAttribute is a range attribute and a range expression is in the AST; nullptr otherwise.
Exceptions
astd::runtime_error if the rangeAttribute uses an index specification that is not an integral constant expression.
Precondition
rangeAttribute is not null
bool SageInterface::ada::isFunctionTryBlock ( const SgTryStmt n)

returns true iff n is an Ada function try block

Note
an ada try block is a function block, whose non-declarative range includes exactly one try stmt. In this case, the unparser can omit the separate begin and end statement.
bool SageInterface::ada::isFunctionTryBlock ( const SgTryStmt n)

returns true iff n is an Ada function try block

Note
an ada try block is a function block, whose non-declarative range includes exactly one try stmt. In this case, the unparser can omit the separate begin and end statement.
bool SageInterface::ada::isPackageTryBlock ( const SgTryStmt n)

returns true iff n is an Ada package try block

Note
an ada try block is a function block, whose non-declarative range includes exactly one try stmt. In this case, the unparser can omit the separate begin and end statement.
bool SageInterface::ada::isPackageTryBlock ( const SgTryStmt n)

returns true iff n is an Ada package try block

Note
an ada try block is a function block, whose non-declarative range includes exactly one try stmt. In this case, the unparser can omit the separate begin and end statement.
bool SageInterface::ada::isFixedType ( const SgType ty)

returns if the type ty is a fixed point type

also return true for decimal fixed points

bool SageInterface::ada::isFixedType ( const SgType ty)

returns if the type ty is a fixed point type

also return true for decimal fixed points

bool SageInterface::ada::isDecimalFixedType ( const SgType ty)

returns if the type ty is a decimal fixed point type

implementation is incomplete and only detects formal decimal fixed point constraints

bool SageInterface::ada::isDecimalFixedType ( const SgType ty)

returns if the type ty is a decimal fixed point type

implementation is incomplete and only detects formal decimal fixed point constraints

SgAdaGenericDecl* SageInterface::ada::isGenericDecl ( const SgDeclarationStatement n)

Returns the SgAdaGenericDecl node that makes a declaration (either function/procedure or package) generic.

Parameters
na declaration that is possibly part of a generic declaration.
Returns
the generic declaration of n, where n is a either function/procedure or package that is declared directly under an SgAdaGenericDecl; nullptr otherwise.

For a subtree SgAdaGenericDecl->SgAdaGenericDefn->n, the SgAdaGenericDecl node is returned.

SgAdaGenericDecl* SageInterface::ada::isGenericDecl ( const SgDeclarationStatement n)

Returns the SgAdaGenericDecl node that makes a declaration (either function/procedure or package) generic.

Parameters
na declaration that is possibly part of a generic declaration.
Returns
the generic declaration of n, where n is a either function/procedure or package that is declared directly under an SgAdaGenericDecl; nullptr otherwise.

For a subtree SgAdaGenericDecl->SgAdaGenericDefn->n, the SgAdaGenericDecl node is returned.

SgAdaGenericDecl& SageInterface::ada::getGenericDecl ( const SgAdaGenericInstanceDecl n)

Returns SgAdaGenericDecl for a given SgAdaGenericInstanceDecl.

skips over intermediate renaming declarations.

SgAdaGenericDecl* SageInterface::ada::getGenericDecl ( const SgAdaGenericInstanceDecl n)

Returns SgAdaGenericDecl for a given SgAdaGenericInstanceDecl.

skips over intermediate renaming declarations.

SgType* SageInterface::ada::typeOfExpr ( SgExpression )

returns the type of an expression corrects for some peculiarities in the AST

SgType* SageInterface::ada::typeOfExpr ( SgExpression )

returns the type of an expression corrects for some peculiarities in the AST

std::string SageInterface::ada::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 + '"').

if nameInRose does not name an operator, then the name is returned as is.

std::string SageInterface::ada::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).

if nameInRose does not name an operator, an empty string is returned

SgScopeStatement* SageInterface::ada::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 the argument list args and the primitive argument positions defined by primitiveArgs.

Returns
the scope of an overriding argument (incl. the original associated type); nullptr if no such scope can be found.
Note
does not resolve conflicting scopes
See also
also primitiveParameterPositions
SgScopeStatement* SageInterface::ada::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 the argument list args and the primitive argument positions defined by primitiveArgs.

Returns
the scope of an overriding argument (incl. the original associated type); nullptr if no such scope can be found.
Note
does not resolve conflicting scopes
See also
also primitiveParameterPositions
SgDeclarationStatement* SageInterface::ada::baseDeclaration ( SgType ty)

finds the type declaration of a type ty

Returns
returns the first named base declaration of ty nullptr if no declaration can be found

Skips over intermediate derived types, subtypes, etc. until a SgNamedType is found. Returns the declaration of said type.

SgDeclarationStatement* SageInterface::ada::baseDeclaration ( SgType ty)

finds the type declaration of a type ty

Returns
returns the first named base declaration of ty nullptr if no declaration can be found

Skips over intermediate derived types, subtypes, etc. until a SgNamedType is found. Returns the declaration of said type.

SgEnumDeclaration* SageInterface::ada::baseEnumDeclaration ( SgType ty)

finds the underlying enum declaration of a type ty

Returns
an enum declaration associated with ty nullptr if no declaration can be found

in contrast to baseDeclaration, baseEnumDeclaration skips over intermediate SgTypedefDeclarations that introduce a new type or a subtype.

SgEnumDeclaration* SageInterface::ada::baseEnumDeclaration ( SgType ty)

finds the underlying enum declaration of a type ty

Returns
an enum declaration associated with ty nullptr if no declaration can be found

in contrast to baseDeclaration, baseEnumDeclaration skips over intermediate SgTypedefDeclarations that introduce a new type or a subtype.

size_t SageInterface::ada::positionalArgumentLimit ( const SgExpressionPtrList &  arglst)

finds the one past the last positional argument (aka the first named argument position).

Returns
one past the index of the last positional argument.

examples:

  • argument lists without positional arguments => 0
  • argument lists without named arguments => args.size()
  • empty argument lists => 0
  • (1, 2, LEN => 3) => 2
size_t SageInterface::ada::positionalArgumentLimit ( const SgExprListExp args)

finds the one past the last positional argument (aka the first named argument position).

Returns
one past the index of the last positional argument.

examples:

  • argument lists without positional arguments => 0
  • argument lists without named arguments => args.size()
  • empty argument lists => 0
  • (1, 2, LEN => 3) => 2
size_t SageInterface::ada::positionalArgumentLimit ( const SgExprListExp args)

finds the one past the last positional argument (aka the first named argument position).

Returns
one past the index of the last positional argument.

examples:

  • argument lists without positional arguments => 0
  • argument lists without named arguments => args.size()
  • empty argument lists => 0
  • (1, 2, LEN => 3) => 2
void SageInterface::ada::convertToOperatorRepresentation ( SgNode root,
bool  convertCallSyntax = false,
bool  convertNamedArguments = false 
)

converts AST from a function call representation to operator form for fundamental operator declarations.

Parameters
rootthe subtree is traversed to find operator calls (using the traversal mechanism)
convertCallSyntaxfalse, only convert those calls where get_uses_operator_syntax() returns false true, convert all calls (may result in invalid Ada)
convertNamedArgumentsnot relevant, when convertCallSyntax == false true, named arguments are resolved false, named arguments are preserved