Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/coreclr/vm/jitinterface.cpp')
-rw-r--r--src/coreclr/vm/jitinterface.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp
index 3d0012cbd41..9c8d9cbe59c 100644
--- a/src/coreclr/vm/jitinterface.cpp
+++ b/src/coreclr/vm/jitinterface.cpp
@@ -4529,6 +4529,57 @@ bool CEEInfo::isMoreSpecificType(
}
/*********************************************************************/
+// Returns TypeCompareState::Must if cls is known to be an enum.
+// For enums with known exact type returns the underlying
+// type in underlyingType when the provided pointer is
+// non-NULL.
+// Returns TypeCompareState::May when a runtime check is required.
+TypeCompareState CEEInfo::isEnum(
+ CORINFO_CLASS_HANDLE cls,
+ CORINFO_CLASS_HANDLE* underlyingType)
+{
+ CONTRACTL {
+ THROWS;
+ GC_TRIGGERS;
+ MODE_PREEMPTIVE;
+ } CONTRACTL_END;
+
+ TypeCompareState result = TypeCompareState::May;
+
+ if (underlyingType != nullptr)
+ {
+ *underlyingType = nullptr;
+ }
+
+ JIT_TO_EE_TRANSITION_LEAF();
+
+ TypeHandle th(cls);
+
+ _ASSERTE(!th.IsNull());
+
+ if (!th.IsGenericVariable())
+ {
+ if (!th.IsTypeDesc() && th.AsMethodTable()->IsEnum())
+ {
+ result = TypeCompareState::Must;
+ if (underlyingType != nullptr)
+ {
+ CorElementType elemType = th.AsMethodTable()->GetInternalCorElementType();
+ TypeHandle underlyingHandle(CoreLibBinder::GetElementType(elemType));
+ *underlyingType = CORINFO_CLASS_HANDLE(underlyingHandle.AsPtr());
+ }
+ }
+ else
+ {
+ result = TypeCompareState::MustNot;
+ }
+ }
+
+ EE_TO_JIT_TRANSITION_LEAF();
+ return result;
+}
+
+/*********************************************************************/
// Given a class handle, returns the Parent type.
// For COMObjectType, it returns Class Handle of System.Object.
// Returns 0 if System.Object is passed in.