|
ROSE 2.23.0
|
This is a stateless, abstract base class for implementing some functionality required by the class hierarchy analysis onto different subsets of the AST.
e.g., C++ analysis, JVM analysis, ...
Definition at line 20 of file AbstractCompatibilityBridge.h.
#include <Rose/Common/Analysis/AbstractCompatibilityBridge.h>

Public Member Functions | |
| AbstractCompatibilityBridge ()=default | |
| Constructs a stateless compatibility bridge. | |
| virtual | ~AbstractCompatibilityBridge ()=default |
| Destroys a compatibility bridge through the base type. | |
| virtual std::string | nameOf (FunctionKeyType key) const =0 |
returns the source name of the function represented by key. | |
| virtual std::string | nameOf (ClassKeyType key) const =0 |
returns the source name of the class represented by key. | |
| virtual bool | isAbstract (ClassKeyType key) const =0 |
returns true if the class represented by key is an abstract class. | |
| virtual bool | isPureVirtual (FunctionKeyType key) const =0 |
returns true if the class represented by key is an abstract function. | |
| virtual int | compareNames (FunctionKeyType lhs, FunctionKeyType rhs) const =0 |
compares the source name of the functions lhs and rhs. | |
| virtual int | compareFunctionsByType (FunctionKeyType lhs, FunctionKeyType rhs, bool exclReturnType=true) const =0 |
compares the canonical types of functions lhs and rhs | |
| virtual FunctionTypeRelation | haveSameOrCovariantReturn (const ClassAnalysis &classes, FunctionKeyType basId, FunctionKeyType drvId) const =0 |
tests if drvId has the same or covariant return type with respect to basId | |
| virtual void | extractFromMemoryPool (ClassAnalysis &classes) const =0 |
| extracts class information from the memory pool if available | |
| virtual void | extractFromProject (ClassAnalysis &classes, ASTRootType root) const =0 |
extracts class by walking the AST rooted at root. | |
| virtual LanguageSpecificFn | languageSpecificProcessing () const =0 |
| returns a function that handles language specific post-processing for the extract classes. | |
| virtual void | inheritanceEdges (ClassKeyType clkey, std::function< void(ClassKeyType, ClassKeyType, bool)> fn) const =0 |
calls the callback function fn(derived, base, isvirtual) for all direct base classes of clkey | |
| virtual DataMemberType | typeOf (VariableKeyType var) const =0 |
returns the type of a non-static data member var. | |
| virtual bool | isAutoGeneratable (const ClassAnalysis &classes, ClassKeyType clkey, FunctionKeyType fnkey) const |
returns whether a function with fnkey's signature can be implicitly generated in clkey. | |
| virtual std::uint32_t | languageStandard () const |
| returns the active language standard as a C++ __cplusplus-style value when available. | |
| virtual bool | inheritedMethodsImplementVirtualBaseMethods () const |
| returns whether a method inherited along the non-virtual inheritance chain implements an otherwise unimplemented function of a virtual base. | |
| virtual bool | isInheritableImplementation (FunctionKeyType fnkey) const |
returns whether the inherited function fnkey qualifies as an implementation of a virtual base function (see inheritedMethodsImplementVirtualBaseMethods). | |
| virtual bool | canOverride (FunctionKeyType drv, FunctionKeyType bas) const |
returns whether drv may override bas under language rules beyond name and signature, such as access control. | |
| virtual bool | isFinal (FunctionKeyType fnkey) const |
returns whether the virtual function fnkey cannot be overridden. | |
| virtual void | explicitOverrides (const ClassAnalysis &classes, ClassKeyType cls, std::function< void(FunctionKeyType, FunctionKeyType)> fn) const |
| reports override relations that are declared explicitly instead of being derived from names and signatures. | |
| virtual bool | canOverrideInContext (const ClassAnalysis &classes, ClassKeyType drvClass, FunctionKeyType drv, ClassKeyType basClass, FunctionKeyType bas) const |
returns whether drv, declared in drvClass, may override bas, declared in basClass, with knowledge of the classes in between. | |
|
pure virtual |
returns the source name of the function represented by key.
| key | abstract function key to name. |
key. Implemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility, and Rose::Source::Analysis::CppCompatibility.
|
pure virtual |
returns the source name of the class represented by key.
| key | abstract class key to name. |
key. Implemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility, and Rose::Source::Analysis::CppCompatibility.
|
pure virtual |
returns true if the class represented by key is an abstract class.
| key | abstract class key to test. |
key denotes an abstract class. Implemented in Rose::Source::Analysis::CppCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, and Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility.
|
pure virtual |
returns true if the class represented by key is an abstract function.
| key | abstract function key to test. |
key denotes an abstract member function. Implemented in Rose::Source::Analysis::CppCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, and Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility.
|
pure virtual |
compares the source name of the functions lhs and rhs.
| lhs | left-hand side function |
| rhs | right-hand side function |
Implemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility, and Rose::Source::Analysis::CppCompatibility.
|
pure virtual |
compares the canonical types of functions lhs and rhs
| lhs | left-hand side function |
| rhs | right-hand side function |
| exclReturnType | if true the return types of lhs and rhs are not considered (though the return types of potential arguments and return types are). This can be useful for obtaining equality of functions that have covariant return types. |
if lhs and rhs are not equal, the ordering is not specified but produces consistent results
Implemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility, and Rose::Source::Analysis::CppCompatibility.
|
pure virtual |
tests if drvId has the same or covariant return type with respect to basId
| classes | the extracted class analysis |
| basId | ID of a function in a base class |
| drvId | ID of a function in a derived class |
basId and drvId.The function only checks the return type, and does not check whether the classes in which the functions drvId and basId are defined are in a inheritance relationship.
Implemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility, and Rose::Source::Analysis::CppCompatibility.
|
pure virtual |
extracts class information from the memory pool if available
| classes | analysis object to populate with discovered classes. |
classes is createdImplemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility, and Rose::Source::Analysis::CppCompatibility.
|
pure virtual |
extracts class by walking the AST rooted at root.
| classes | analysis object to populate with discovered classes. |
| root | abstract key for the AST root to traverse. |
classes is createdImplemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility, and Rose::Source::Analysis::CppCompatibility.
|
pure virtual |
returns a function that handles language specific post-processing for the extract classes.
a use case is applying additional analysis rules after the common inheritance relationships have been computed.
Implemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility, and Rose::Source::Analysis::CppCompatibility.
|
pure virtual |
calls the callback function fn(derived, base, isvirtual) for all direct base classes of clkey
| clkey | class whose direct inheritance edges are requested. |
| fn | callback invoked for each edge as (derived, base, isVirtual). |
|
pure virtual |
returns the type of a non-static data member var.
| var | data member key to inspect. |
Implemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility, Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility, and Rose::Source::Analysis::CppCompatibility.
|
inlinevirtual |
returns whether a function with fnkey's signature can be implicitly generated in clkey.
| classes | class analysis context. |
| clkey | class for which implicit generation is tested. |
| fnkey | function whose signature is tested. |
Reimplemented in Rose::Source::Analysis::CppCompatibility.
Definition at line 191 of file AbstractCompatibilityBridge.h.
|
inlinevirtual |
returns the active language standard as a C++ __cplusplus-style value when available.
Reimplemented in Rose::Source::Analysis::CppCompatibility.
Definition at line 203 of file AbstractCompatibilityBridge.h.
|
inlinevirtual |
returns whether a method inherited along the non-virtual inheritance chain implements an otherwise unimplemented function of a virtual base.
This is the rule of Java (JLS 8.4.8.1, JVMS 5.4.6) and CIL (ECMA-335 II.12.2): for a class C extending B and implementing interface I, a concrete method B.m inherited by C implements I.m. C++ has no such rule; the class stays abstract. When enabled, analyzeVirtualFunctions records such relationships as implied overrides with C as witness (see OverrideDesc::witness).
Reimplemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility.
Definition at line 220 of file AbstractCompatibilityBridge.h.
|
inlinevirtual |
returns whether the inherited function fnkey qualifies as an implementation of a virtual base function (see inheritedMethodsImplementVirtualBaseMethods).
| fnkey | an inherited function that matches a virtual base function by signature. |
fnkey may implement the virtual base function.Only consulted when inheritedMethodsImplementVirtualBaseMethods returns true. A Java bridge returns true for non-abstract public methods (JLS 8.4.8.4: an inherited abstract method does not implement; interface methods are public, so the implementing method must be public).
Reimplemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility.
Definition at line 233 of file AbstractCompatibilityBridge.h.
|
inlinevirtual |
returns whether drv may override bas under language rules beyond name and signature, such as access control.
| drv | function in a derived class (or inherited by it) that matches bas by signature. |
| bas | function in an ancestor class. |
In C++ access does not affect overriding, so the default applies. The JVM (JVMS 5.4.5) excludes private methods on either side and lets a package-private method be overridden only from the same run-time package. If this query rejects a pair, the analysis still records the relation when it holds transitively: drv overrides an intermediate function that in turn overrides bas (JVMS 5.4.5, rule (b)). Bridges therefore only need to decide the direct relation.
Reimplemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility.
Definition at line 254 of file AbstractCompatibilityBridge.h.
Referenced by canOverrideInContext().
|
inlinevirtual |
returns whether the virtual function fnkey cannot be overridden.
| fnkey | virtual function to inspect. |
fnkey is final (e.g., a sealed override in C#); the base implementation returns false.The result is recorded in the VirtualFunctionDesc so that clients know that the function has no possible overriders. Bridges for languages in which a final function is not part of the override relation also reject such pairs in canOverride.
Reimplemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility.
Definition at line 271 of file AbstractCompatibilityBridge.h.
|
inlinevirtual |
reports override relations that are declared explicitly instead of being derived from names and signatures.
| classes | class analysis context; inheritance relations are complete. |
| cls | class whose explicit overrides are requested. |
| fn | callback invoked as fn(overrider, overridden) for each explicit pair where overrider is a virtual function declared in cls. |
CIL expresses explicit interface implementations, overrides under a different name, covariant returns, and default interface method overrides in the MethodImpl table. The analysis records each reported pair as an override, without consulting canOverride, but only if both functions are known virtual functions. Return types are not required to be identical. The base implementation reports nothing.
Definition at line 292 of file AbstractCompatibilityBridge.h.
|
inlinevirtual |
returns whether drv, declared in drvClass, may override bas, declared in basClass, with knowledge of the classes in between.
| classes | class analysis context; inheritance relations are complete. |
| drvClass | class that declares drv; invalid for an implied override, where the declaring class of the inherited function is not known. |
| drv | function in a derived class that matches bas by signature. |
| basClass | class that declares bas. |
| bas | function in an ancestor class. |
Languages whose override rules depend on the classes between drvClass and basClass (e.g., a CIL method that starts a new vtable slot in an intermediate class) implement this query. The analysis calls this function; it is not necessary to also implement canOverride(drv, bas). Rejected pairs are resolved transitively as described for canOverride.
Reimplemented in Rose::BinaryAnalysis::ByteCode::ClassHierarchy::CilCompatibility.
Definition at line 320 of file AbstractCompatibilityBridge.h.
References canOverride().