3 #ifndef _SAGEINTERFACE_ADA_H
4 #define _SAGEINTERFACE_ADA_H 1
6 #include "sage3basic.hhh"
7 #include "sageInterface.h"
24 ASSERT_not_null(n.get_symbol());
26 return *n.get_symbol();
33 ASSERT_not_null(n.get_symbol());
35 return *n.get_symbol();
42 ASSERT_not_null(n.get_declaration());
44 return *n.get_declaration();
51 return declOf(symOf(n));
60 ASSERT_not_null(sy.get_declaration());
61 return *sy.get_declaration();
68 ASSERT_not_null(n.get_decl());
95 ASSERT_not_null(n.get_decl());
112 return nameOf(symOf(n));
119 return nameOf(symOf(n));
140 return nameOf(declOf(n));
165 extern const std::string roseOperatorPrefix;
166 extern const std::string packageStandardName;
167 extern const std::string durationTypeName;
168 extern const std::string exceptionName;
186 using StatementRange = std::pair<SgDeclarationStatementPtrList::iterator, SgDeclarationStatementPtrList::iterator>;
214 struct FlatArrayType : std::tuple<SgArrayType*, std::vector<SgExpression*> >
216 using base = std::tuple<SgArrayType*, std::vector<SgExpression*> >;
219 SgArrayType* type()
const {
return std::get<0>(*this); }
220 std::vector<SgExpression*>
const& dims()
const {
return std::get<1>(*this); }
221 std::vector<SgExpression*>& dims() {
return std::get<1>(*this); }
237 template <
class SageLocatedNode>
238 struct IfInfo : std::tuple<SgExpression*, SageLocatedNode*>
240 using base = std::tuple<SgExpression*, SageLocatedNode*>;
243 SgExpression* condition()
const {
return std::get<0>(*this); }
244 SageLocatedNode* trueBranch()
const {
return std::get<1>(*this); }
245 bool isElse()
const {
return condition() ==
nullptr; }
254 std::vector<IfExpressionInfo>
258 std::vector<IfStatementInfo>
325 SgStatementPtrList::const_iterator
declarationLimit(
const SgStatementPtrList& list);
449 using base = std::tuple<SgType*, bool>;
452 SgType* typerep()
const {
return std::get<0>(*this); }
453 SgType& typerep_ref()
const;
454 bool polymorphic()
const {
return std::get<1>(*this); }
481 struct ImportedUnitResult : std::tuple<std::string, const SgDeclarationStatement*, const SgAdaRenamingDecl*>
483 using base = std::tuple<std::string, const SgDeclarationStatement*, const SgAdaRenamingDecl*>;
486 const std::string& name()
const {
return std::get<0>(*this); }
490 ASSERT_not_null(std::get<1>(*
this));
491 return *(std::get<1>(*this));
521 SgExpressionPtrList::const_iterator,
522 SgExpressionPtrList::const_iterator
526 SgExpressionPtrList::const_iterator,
527 SgExpressionPtrList::const_iterator
532 SgAdaAncestorInitializer*
ancestor()
const {
return std::get<0>(*this); }
535 SgExpressionPtrList::const_iterator
begin()
const {
return std::get<1>(*this); }
538 SgExpressionPtrList::const_iterator
end()
const {
return std::get<2>(*this); }
582 using base = std::tuple<size_t, const SgInitializedName*>;
587 pos()
const {
return std::get<0>(*this); }
591 name()
const {
return std::get<1>(*this); }
596 std::vector<PrimitiveParameterDesc>
599 std::vector<PrimitiveParameterDesc>
637 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.).
bool unitRefDenotesGenericInstance(const SgAdaUnitRefExp &n)
returns true iff n refers to a generic declaration from inside said declaration false otherwise (e...
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.
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.
const SgScopeStatement * logicalParentScope(const SgScopeStatement &s)
returns the logical parent scope of a scope s.
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
SgScopeStatement * operatorScope(std::string opname, SgTypePtrList argtypes)
returns the scope where an operator with name opname and argument types in argtypes should be defined...
const SgInitializedName * name() const
the parameters 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...
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
This class represents the concept of a variable name within the compiler (a shared container for the ...
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 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.
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)
bool isFunctionTryBlock(const SgTryStmt &n)
returns true iff n is an Ada function try block
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...
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
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 operations primitive
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
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).
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