"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "projects/CodeThorn/src/RoseCompatibility.h" between
rose-0.11.53.0.tar.gz and rose-0.11.54.0.tar.gz

About: ROSE is a compiler infrastructure to build source-to-source program transformation and analysis tools for large-scale C, C++, UPC, Fortran, OpenMP, Java, Python and PHP applications.

RoseCompatibility.h  (rose-0.11.53.0):RoseCompatibility.h  (rose-0.11.54.0)
#ifndef ROSE_MAPPING #ifndef ROSE_MAPPING
#define ROSE_MAPPING 1 #define ROSE_MAPPING 1
// minimal header for mapping rose onto the class hierarchy analysis // minimal header for mapping rose onto the class hierarchy analysis
#include <sage3basic.h> #include <sage3basic.h>
#include <VariableIdMapping.h> //~ #include <VariableIdMapping.h>
#include <FunctionId.h>
#include <string> #include <string>
#include <functional> #include <functional>
namespace CodeThorn namespace CodeThorn
{ {
using ClassKeyType = const SgClassDefinition*; using ClassKeyType = const SgClassDefinition*;
using TypeKeyType = const SgType*; using TypeKeyType = const SgType*;
using CastKeyType = const SgCastExp*; using CastKeyType = const SgCastExp*;
using ASTRootType = SgProject*; using VariableKeyType = const SgInitializedName*;
using FunctionKeyType = const SgMemberFunctionDeclaration*;
using ASTRootType = SgProject*;
/// type of a class naming function /// type of a class naming function
using ClassNameFn = std::function<std::string(ClassKeyType)>; using ClassNameFn = std::function<std::string(ClassKeyType)>;
/// type of a function naming function /// type of a function naming function
using FuncNameFn = std::function<std::string(FunctionId)>; using FuncNameFn = std::function<std::string(FunctionKeyType)>;
/// type of a variable naming function /// type of a variable naming function
using VarNameFn = std::function<std::string(VariableId)>; using VarNameFn = std::function<std::string(VariableKeyType)>;
class ClassAnalysis; class ClassAnalysis;
class CastAnalysis; class CastAnalysis;
/// a compatibility layer that abstracts functions and queries of /// a compatibility layer that abstracts functions and queries of
/// the AST and implements those capabilities for ROSE. /// the AST and implements those capabilities for ROSE.
class RoseCompatibilityBridge class RoseCompatibilityBridge
{ {
public: public:
enum ReturnTypeRelation : int enum ReturnTypeRelation : int
{ {
unrelated = 0, unrelated = 0,
sametype = 1, sametype = 1,
covariant = 2 covariant = 2
}; };
explicit RoseCompatibilityBridge() = default;
RoseCompatibilityBridge(VariableIdMapping& varIdMap, const FunctionIdMapping
& funIdMap)
: varMap(varIdMap), funMap(funIdMap)
{}
~RoseCompatibilityBridge() = default; ~RoseCompatibilityBridge() = default;
/// returns the variable-id for a variable or parameter \ref var /// returns the variable-id for a variable or parameter \ref var
/// \{ /// \{
VariableId variableId(SgInitializedName* var) const; VariableKeyType variableId(SgInitializedName* var) const;
VariableId variableId(SgVariableDeclaration* var) const; VariableKeyType variableId(SgVariableDeclaration* var) const;
/// \} /// \}
/// returns the function-id for a (member) function \ref fun /// returns the function-id for a (member) function \ref fun
FunctionId functionId(const SgFunctionDeclaration* fun) const; FunctionKeyType functionId(const SgMemberFunctionDeclaration* fun) const;
/// returns a string representation for \ref vid /// returns a string representation for \ref vid
std::string nameOf(VariableId vid) const; std::string nameOf(VariableKeyType vid) const;
/// returns a string representation for \ref vid /// returns a string representation for \ref vid
std::string nameOf(FunctionId fid) const; std::string nameOf(FunctionKeyType fid) const;
/// compares the name of \ref lhs and \ref rhs /// compares the name of functions \ref lhs and \ref rhs
/// \param lhs some function /// \param lhs some function
/// \param rhs some function /// \param rhs some function
/// \returns 0 iff lhs and rhs have the same name (wrt virtual function over riding) /// \returns 0 iff lhs and rhs have the same name (wrt virtual function over riding)
/// 1 iff lhs > rhs /// 1 iff lhs > rhs
/// -1 iff lhs < rhs /// -1 iff lhs < rhs
int compareNames(FunctionId lhs, FunctionId rhs) const; int compareNames(FunctionKeyType lhs, FunctionKeyType rhs) const;
/// compares the types of \ref lhs and \ref rhs /// compares the types of \ref lhs and \ref rhs
/// \param lhs some function /// \param lhs some function
/// \param rhs some function /// \param rhs some function
/// \param exclReturnType if true the return types of \ref lhs and \ref rhs /// \param exclReturnType if true the return types of \ref lhs and \ref rhs
/// are not considered (though the return types of potential argument s /// are not considered (though the return types of potential argument s
/// and return types are). This can be useful for obtaining equality of /// and return types are). This can be useful for obtaining equality of
/// functions that have covariant return types. /// functions that have covariant return types.
/// \returns 0 iff lhs and rhs have the same type /// \returns 0 iff lhs and rhs have the same type
/// 1 iff lhs > rhs /// 1 iff lhs > rhs
/// -1 iff lhs < rhs /// -1 iff lhs < rhs
/// \details /// \details
/// The comparison skips over typedef aliases and handles array to pointe r decay. /// The comparison skips over typedef aliases and handles array to pointe r decay.
int compareTypes(FunctionId lhs, FunctionId rhs, bool exclReturnType = true) const; int compareTypes(FunctionKeyType lhs, FunctionKeyType rhs, bool exclReturnTy pe = true) const;
/// tests if \ref drvId has the same or covariant return type with respect t o \ref basId /// tests if \ref drvId has the same or covariant return type with respect t o \ref basId
/// \param classes the extracted class analysis /// \param classes the extracted class analysis
/// \param basId ID of a function in a base class /// \param basId ID of a function in a base class
/// \param drvId ID of a function in a derived class /// \param drvId ID of a function in a derived class
/// \details /// \details
/// The function only checks the return type, and does not check whether the classes in which /// The function only checks the return type, and does not check whether the classes in which
/// the functions \ref drvId and \ref basId are defined are in a inherita nce relationship. /// the functions \ref drvId and \ref basId are defined are in a inherita nce relationship.
ReturnTypeRelation ReturnTypeRelation
haveSameOrCovariantReturn(const ClassAnalysis&, FunctionId basId, FunctionId drvId) const; haveSameOrCovariantReturn(const ClassAnalysis&, FunctionKeyType basId, Funct ionKeyType drvId) const;
/// extracts class and cast information under the root /// extracts class and cast information under the root
void extractFromProject(ClassAnalysis&, CastAnalysis&, ASTRootType) const; void extractFromProject(ClassAnalysis&, CastAnalysis&, ASTRootType) const;
/// returns iff \ref id is a pure virtual member function /// returns iff \ref id is a pure virtual member function
bool isPureVirtual(FunctionId id) const; bool isPureVirtual(FunctionKeyType id) const;
/// returns a function that maps a FunctionId to std::string /// returns a function that maps a FunctionKeyType to std::string
FuncNameFn functionNomenclator() const; FuncNameFn functionNomenclator() const;
/// returns a function that maps a ClassKeyType to std::string /// returns a function that maps a ClassKeyType to std::string
ClassNameFn classNomenclator() const; ClassNameFn classNomenclator() const;
/// returns a function that maps a VariableId to std::string /// returns a function that maps a VariableId to std::string
VarNameFn variableNomenclator() const; VarNameFn variableNomenclator() const;
private: private:
RoseCompatibilityBridge() = delete; //~ RoseCompatibilityBridge() = del ete;
RoseCompatibilityBridge(RoseCompatibilityBridge&&) = delete; RoseCompatibilityBridge(RoseCompatibilityBridge&&) = delete;
RoseCompatibilityBridge& operator=(RoseCompatibilityBridge&&) = delete; RoseCompatibilityBridge& operator=(RoseCompatibilityBridge&&) = delete;
RoseCompatibilityBridge(const RoseCompatibilityBridge&) = delete; RoseCompatibilityBridge(const RoseCompatibilityBridge&) = delete;
RoseCompatibilityBridge& operator=(const RoseCompatibilityBridge&) = delete; RoseCompatibilityBridge& operator=(const RoseCompatibilityBridge&) = delete;
VariableIdMapping& varMap;
const FunctionIdMapping& funMap;
}; };
/// wrapper class to produce informative debug output about casts /// wrapper class to produce informative debug output about casts
struct CastWriterDbg struct CastWriterDbg
{ {
CastWriterDbg(CastKeyType n) CastWriterDbg(CastKeyType n)
: node(n) : node(n)
{} {}
CastKeyType node; CastKeyType node;
 End of changes. 17 change blocks. 
29 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)