ROSE  0.11.145.0
Classes | Typedefs | Functions | Variables
SageInterface::Ada Namespace Reference

Description

Contains Ada-specific functionality.

Classes

struct  AggregateInfo
 Details of expression aggregates. More...
 
struct  DominantArgInfo
 
struct  FlatArrayType
 defines the result type for getArrayTypeInfo More...
 
struct  IfInfo
 represents a branch in an if elsif else context (either statement or expression). More...
 
struct  ImportedUnitResult
 describes properties of imported units More...
 
struct  OperatorScopeInfo
 
struct  PrimitiveParameterDesc
 
struct  RecordField
 
struct  TypeDescription
 

Typedefs

using StatementRange = std::pair< SgDeclarationStatementPtrList::iterator, SgDeclarationStatementPtrList::iterator >
 
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
 
const SgScopeStatementcorrespondingBody (const SgScopeStatement *scope)
 returns the body scope (aka definition) of a task, package, or protected object. More...
 
DominantArgInfo operatorArgumentWithNamedRootIfAvail (const SgTypePtrList &argtypes)
 
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. More...
 
ImportedUnitResult importedUnit (const SgImportStatement &impdcl)
 queries properties of an imported unit
 
const SgExpressionimportedElement (const SgImportStatement &n)
 returns the imported element (i.e., the first entry in n's import_list
 
SgScopeStatementpkgStandardScope ()
 do not use, this is temporary
 
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...
 
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. More...
 
const SgScopeStatementcanonicalScope (const SgScopeStatement *scope)
 returns the canonical scope of some Ada scope scope. More...
 
const SgScopeStatementcanonicalScope (const SgScopeStatement &scope)
 
bool sameCanonicalScope (const SgScopeStatement *lhs, const SgScopeStatement *rhs)
 tests if lhs and have the same canonical scope.
 
SgDeclarationStatementassociatedDeclaration (const SgSymbol &n)
 returns the associated declaration for symbol n or nullptr if there is none. 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...
 
FlatArrayType getArrayTypeInfo (SgType &atype)
 returns a flattened representation of Ada array types. More...
 
std::vector< RecordFieldgetAllRecordFields (const SgClassDefinition &rec)
 returns all fields (defined and inherited) of a record. More...
 
std::vector< RecordFieldgetAllRecordFields (const SgClassDefinition *rec)
 returns all fields (defined and inherited) of a record. 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
 
SgAdaPackageBodyDeclgetPackageBodyDeclaration (const SgAdaPackageSpecDecl &specDecl)
 returns the declaration node for the package body, if available
 
SgAdaPackageBodyDeclgetPackageBodyDeclaration (const SgAdaPackageSpecDecl *specDecl)
 returns the declaration node for the package body, if available
 
SgDeclarationStatementgetSpecificationDeclaration (const SgAdaTaskBodyDecl &bodyDecl)
 returns the declaration node (either SgAdaTaskSpecDecl or SgAdaTaskTypeDecl) for the task specification
 
SgDeclarationStatementgetSpecificationDeclaration (const SgAdaTaskBodyDecl *bodyDecl)
 returns the declaration node (either SgAdaTaskSpecDecl or SgAdaTaskTypeDecl) for the task specification
 
SgDeclarationStatementgetSpecificationDeclaration (const SgAdaProtectedBodyDecl &bodyDecl)
 returns the declaration node (either SgAdaProtectedSpecDecl or SgAdaProtectedTypeDecl) for the protected object specification
 
SgDeclarationStatementgetSpecificationDeclaration (const SgAdaProtectedBodyDecl *bodyDecl)
 returns the declaration node (either SgAdaProtectedSpecDecl or SgAdaProtectedTypeDecl) for the protected object specification
 
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 tryFollowsDeclarativeBlock (const SgTryStmt &n)
 returns true iff n is a try block following a declarative region More...
 
bool tryFollowsDeclarativeBlock (const SgTryStmt *n)
 returns true iff n is a try block following a declarative region 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 isBooleanType (const SgType *ty)
 return if the type ty is the corresponding universal type representation in ROSE
 
bool isBooleanType (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 isScalarType (const SgType *ty)
 returns true if ty refers to a scalar type
 
bool isScalarType (const SgType &ty)
 returns true if ty refers to a scalar type
 
bool isDiscreteArrayType (const SgType &ty)
 returns true if ty refers to a discrete array type
 
bool isDiscreteArrayType (const SgType *ty)
 returns true if ty refers to a discrete array type
 
bool resolvesToFixedType (const SgType *ty)
 returns if the type ty resolves to a fixed point type More...
 
bool resolvesToFixedType (const SgType &ty)
 returns if the type ty resolves to 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...
 
bool unitRefDenotesGenericInstance (const SgAdaUnitRefExp &n)
 returns true iff n refers to a generic declaration from inside said declaration false otherwise (e.g., if n does not refer to a generic unit)
 
bool unitRefDenotesGenericInstance (const SgAdaUnitRefExp *n)
 returns true iff n refers to a generic declaration from inside said declaration false otherwise (e.g., if n does not refer to a generic unit)
 
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
 
bool isSeparatedDefinition (const SgFunctionDeclaration &n)
 returns true iff n is a separated function definition is separated
 
bool isSeparatedDefinition (const SgFunctionDeclaration *n)
 returns true iff n is a separated function definition is separated
 
TypeDescription typeRoot (SgType &)
 returns the most fundamental type after skipping subtypes, typedefs, etc.
 
TypeDescription typeRoot (SgType *)
 returns the most fundamental type after skipping subtypes, typedefs, etc.
 
TypeDescription typeOfExpr (SgExpression &)
 returns the type of an expression corrects for some peculiarities in the AST More...
 
TypeDescription typeOfExpr (SgExpression *)
 returns the type of an expression corrects for some peculiarities in the AST More...
 
SgScopeStatementoperatorScope (const std::string &opname, const SgType &ty)
 returns the scope where an operator associated with type ty shall be declared. More...
 
SgScopeStatementoperatorScope (const std::string &opname, const SgType *ty)
 returns the scope where an operator associated with type ty shall be declared. More...
 
SgScopeStatementdeclarationScope (const SgType *ty)
 returns the scope where type ty has been declared More...
 
SgScopeStatementdeclarationScope (const SgType &ty)
 returns the scope where type ty has been declared More...
 
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 isFunction (const SgAdaSubroutineType &ty)
 returns true iff ty refers to a function type (as opposed to procedure)
 
bool isFunction (const SgAdaSubroutineType *ty)
 returns true iff ty refers to a function type (as opposed to procedure)
 
const SgFunctionTypefunctionType (const SgFunctionSymbol *fnsy)
 returns the static type of the function symbol fnsy More...
 
const SgFunctionTypefunctionType (const SgFunctionSymbol &fnsy)
 returns the static type of the function symbol fnsy More...
 
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 operation primitive
 
std::vector< PrimitiveParameterDescprimitiveParameterPositions (const SgFunctionDeclaration *)
 returns the descriptions for parameters that make an operation primitive
 
SgExpressionPtrList normalizedCallArguments (const SgFunctionCallExp &n)
 returns a list of arguments with named arguments placed at the correct position More...
 
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, limit). 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...
 
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...
 
SgScopeStatementlogicalParentScope (const SgScopeStatement &s)
 returns the logical parent scope of a scope s. More...
 
SgScopeStatementlogicalParentScope (const SgScopeStatement *s)
 returns the logical parent scope of a scope s. More...
 
SgDeclarationStatementassociatedDeclaration (const SgType &ty)
 returns the decl where ty was defined nullptr if no such declaration can be found. More...
 
SgDeclarationStatementassociatedDeclaration (const SgType *ty)
 returns the decl where ty was defined nullptr if no such declaration can be found. More...
 
SgTypebaseType (const SgType &ty)
 returns the base type of a type ty More...
 
SgTypebaseType (const SgType *ty)
 returns the base type 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 atype 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.
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 atype 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.
std::vector<RecordField> SageInterface::Ada::getAllRecordFields ( const SgClassDefinition rec)

returns all fields (defined and inherited) of a record.

Parameters
recthe class definition for which the fields are sought
Note
currently the entries in the returned vector are unordered.
std::vector<RecordField> SageInterface::Ada::getAllRecordFields ( const SgClassDefinition rec)

returns all fields (defined and inherited) of a record.

Parameters
recthe class definition for which the fields are sought
Note
currently the entries in the returned vector are unordered.
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
const SgScopeStatement* SageInterface::Ada::correspondingBody ( const SgScopeStatement scope)

returns the body scope (aka definition) of a task, package, or protected object.

Parameters
scopea task, package, protected object spec or body
Returns
the corresponding body scope (i.e., SgAdaProtectedBody, SgAdaPackageBody, SgAdaTaskBody) returns null when a body cannot be found

given a spec or body, the function returns the body, null otherwise e.g., getBodyScope(SgAdaPackageSpec) -> SgAdaPackageBody getBodyScope(SgAdaPackageBody) -> SgAdaPackageBody getBodyScope(SgFunctionDefinition) -> nullptr

bool SageInterface::Ada::tryFollowsDeclarativeBlock ( const SgTryStmt n)

returns true iff n is a try block following a declarative region

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::tryFollowsDeclarativeBlock ( const SgTryStmt n)

returns true iff n is a try block following a declarative region

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::resolvesToFixedType ( const SgType ty)

returns if the type ty resolves to a fixed point type

also return true for decimal fixed points

bool SageInterface::Ada::resolvesToFixedType ( const SgType ty)

returns if the type ty resolves to 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.

TypeDescription SageInterface::Ada::typeOfExpr ( SgExpression )

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

TypeDescription SageInterface::Ada::typeOfExpr ( SgExpression )

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

OperatorScopeInfo SageInterface::Ada::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.

Parameters
opnamethe operator name
argtypesa list of argument types
Returns
a scope where the described operator shall be declared, and the argument position associated with the scope.
SgScopeStatement& SageInterface::Ada::operatorScope ( const std::string &  opname,
const SgType ty 
)

returns the scope where an operator associated with type ty shall be declared.

Parameters
opnamethe operator name
tythe type name
Returns
a scope where the described operator shall be declared.
Note
the main difference to declarationScope is that fixed types require certain operators to exist in package standard.
SgScopeStatement* SageInterface::Ada::operatorScope ( const std::string &  opname,
const SgType ty 
)

returns the scope where an operator associated with type ty shall be declared.

Parameters
opnamethe operator name
tythe type name
Returns
a scope where the described operator shall be declared.
Note
the main difference to declarationScope is that fixed types require certain operators to exist in package standard.
SgScopeStatement* SageInterface::Ada::declarationScope ( const SgType ty)

returns the scope where type ty has been declared

Parameters
tysome type
Returns
the scope where ty was declared
SgScopeStatement* SageInterface::Ada::declarationScope ( const SgType ty)

returns the scope where type ty has been declared

Parameters
tysome type
Returns
the scope where ty was declared
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

const SgFunctionType* SageInterface::Ada::functionType ( const SgFunctionSymbol fnsy)

returns the static type of the function symbol fnsy

Note
The pointer based version returns nullptr if fnsy is nullptr.
const SgFunctionType& SageInterface::Ada::functionType ( const SgFunctionSymbol fnsy)

returns the static type of the function symbol fnsy

Note
The pointer based version returns nullptr if fnsy is nullptr.
SgExpressionPtrList SageInterface::Ada::normalizedCallArguments ( const SgFunctionCallExp n)

returns a list of arguments with named arguments placed at the correct position

Note
defaulted arguments are not represented and the list may contain holes (nullptr)
Exceptions
std::logic_errorwhen there is no function associated with the call, or when named arguments cannot be identified. For an example for the latter, see test case ancestors.adb
std::size_t SageInterface::Ada::normalizedArgumentPosition ( const SgFunctionCallExp call,
const SgExpression arg 
)

returns the parameter position of arg in the callee, after the parameters have been normalized.

Exceptions
astd::logic_error when a position cannot be found.

assume declaration: procedure X(left, right : integer := 1); and call: X(right => 3) then normalizedArgumentPosition(call, "3") -> 1

std::tuple<const SgScopeStatement*, const SgSymbol*> SageInterface::Ada::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, limit).

Parameters
namean identifier of the sought symbol
scopecurrent scope
limitthe scope in the chain that terminates the search (this scope will not be considered)
Returns
a tuple of scope and first symbol inthat scope with the name Naming tips. or <nullptr, nullptr> if no such symbol exists in the context.
    a scope can contain multiple symbols with the same name, so the caller
    may iterate over the remaining names using the scope's accessor functions
    (next_XXX_symbol).
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
const SgScopeStatement* SageInterface::Ada::canonicalScope ( const SgScopeStatement scope)

returns the canonical scope of some Ada scope scope.

The canonical scope of an entity is its declarative scope e.g., The canonical scope of an SgAdaPackageBody is its spec, a SgAdaPackageSpec

SgScopeStatement* SageInterface::Ada::logicalParentScope ( const SgScopeStatement s)

returns the logical parent scope of a scope s.

Compared to si::getEnclosingScope, this function returns the spec as the logical parent for Ada bodies (e.g., packages, tasks, protected objects). Otherwise, the parent scope is the same as returned by si::getEnclosingScope.

SgScopeStatement* SageInterface::Ada::logicalParentScope ( const SgScopeStatement s)

returns the logical parent scope of a scope s.

Compared to si::getEnclosingScope, this function returns the spec as the logical parent for Ada bodies (e.g., packages, tasks, protected objects). Otherwise, the parent scope is the same as returned by si::getEnclosingScope.

SgDeclarationStatement* SageInterface::Ada::associatedDeclaration ( const SgSymbol n)

returns the associated declaration for symbol n or nullptr if there is none.

SgDeclarationStatement* SageInterface::Ada::associatedDeclaration ( const SgType ty)

returns the decl where ty was defined nullptr if no such 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::associatedDeclaration ( const SgType ty)

returns the decl where ty was defined nullptr if no such declaration can be found.

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

SgType* SageInterface::Ada::baseType ( const SgType ty)

returns the base type of a type ty

In the following type hierarchy baseTypes(Y) would return { X, S1, S2 } but not Integer.

type X is new Integer;
subtype S1 is X range 0..X'Last;
subtype S2 is S1 range 10..20;
type Y is new S1;
SgType* SageInterface::Ada::baseType ( const SgType ty)

returns the base type of a type ty

In the following type hierarchy baseTypes(Y) would return { X, S1, S2 } but not Integer.

type X is new Integer;
subtype S1 is X range 0..X'Last;
subtype S2 is S1 range 10..20;
type Y is new S1;
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

baseEnumDeclaration skips over intermediate SgTypedefDeclarations that introduce a new 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

baseEnumDeclaration skips over intermediate SgTypedefDeclarations that introduce a new type (

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