Moved LocalVariableInfo to shared (#19184)
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>
Fri, 3 Aug 2018 20:03:35 +0000 (13:03 -0700)
committerGitHub <noreply@github.com>
Fri, 3 Aug 2018 20:03:35 +0000 (13:03 -0700)
* File Modified

* Moved to shared

* Introducing RuntimeLocalVariableInfo

* Build Corefx change

* sealed added

src/System.Private.CoreLib/System.Private.CoreLib.csproj
src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
src/System.Private.CoreLib/shared/System/Reflection/LocalVariableInfo.cs [moved from src/System.Private.CoreLib/src/System/Reflection/LocalVariableInfo.cs with 50% similarity]
src/System.Private.CoreLib/src/System/Reflection/RuntimeLocalVariableInfo.cs [new file with mode: 0644]
src/vm/mscorlib.h
src/vm/runtimehandles.cpp
src/vm/runtimehandles.h

index f8adb1c..d231b4d 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\Reflection\FieldInfo.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\INVOCATION_FLAGS.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\LoaderAllocator.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Reflection\LocalVariableInfo.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\MdConstant.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\MdFieldInfo.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\MdImport.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\RuntimeConstructorInfo.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\RuntimeEventInfo.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\RuntimeFieldInfo.cs" />
+    <Compile Include="$(BclSourcesRoot)\System\Reflection\RuntimeLocalVariableInfo.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\RuntimeMethodInfo.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\RuntimeModule.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\RuntimeParameterInfo.cs" />
index dd56943..afb7c6b 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\InvalidFilterCriteriaException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\IReflect.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\IReflectableType.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\LocalVariableInfo.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\ManifestResourceInfo.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\MemberFilter.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\MemberInfo.cs" />
@@ -8,17 +8,10 @@ namespace System.Reflection
 {
     public class LocalVariableInfo
     {
-        #region Private Data Members
-        private RuntimeType m_type;
-        private int m_isPinned;
-        private int m_localIndex;
-        #endregion
-
-        #region Constructor
+        public virtual Type LocalType { get { Debug.Fail("type must be set!"); return null; } }
+        public virtual int LocalIndex => 0;
+        public virtual bool IsPinned => false;
         protected LocalVariableInfo() { }
-        #endregion
-
-        #region Object Overrides
         public override string ToString()
         {
             string toString = LocalType.ToString() + " (" + LocalIndex + ")";
@@ -28,13 +21,6 @@ namespace System.Reflection
 
             return toString;
         }
-        #endregion
-
-        #region Public Members
-        public virtual Type LocalType { get { Debug.Assert(m_type != null, "type must be set!"); return m_type; } }
-        public virtual bool IsPinned { get { return m_isPinned != 0; } }
-        public virtual int LocalIndex { get { return m_localIndex; } }
-        #endregion
     }
 }
 
diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeLocalVariableInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeLocalVariableInfo.cs
new file mode 100644 (file)
index 0000000..77b4591
--- /dev/null
@@ -0,0 +1,21 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+
+namespace System.Reflection
+{
+    internal sealed class RuntimeLocalVariableInfo : LocalVariableInfo
+    {
+        private RuntimeType _type;
+        private int _localIndex;
+        private bool _isPinned;
+
+        protected RuntimeLocalVariableInfo() { }
+
+        public override Type LocalType { get { Debug.Assert(_type != null, "type must be set!"); return _type; } }
+        public override int LocalIndex => _localIndex;
+        public override bool IsPinned => _isPinned;
+    }
+}
index d6caea2..dcd434e 100644 (file)
@@ -552,11 +552,11 @@ DEFINE_FIELD_U(m_catchMetadataToken,       ExceptionHandlingClause,        m_cat
 DEFINE_FIELD_U(m_filterOffset,             ExceptionHandlingClause,        m_filterOffset)
 DEFINE_CLASS(EH_CLAUSE,             Reflection,             ExceptionHandlingClause)
 
-DEFINE_CLASS_U(Reflection,             LocalVariableInfo,          LocalVariableInfo)
-DEFINE_FIELD_U(m_type,                     LocalVariableInfo,        m_type)
-DEFINE_FIELD_U(m_isPinned,                 LocalVariableInfo,        m_bIsPinned)
-DEFINE_FIELD_U(m_localIndex,               LocalVariableInfo,        m_localIndex)
-DEFINE_CLASS(LOCAL_VARIABLE_INFO,   Reflection,             LocalVariableInfo)
+DEFINE_CLASS_U(Reflection,             RuntimeLocalVariableInfo,        RuntimeLocalVariableInfo)
+DEFINE_FIELD_U(_type,                  RuntimeLocalVariableInfo,        _type)
+DEFINE_FIELD_U(_localIndex,            RuntimeLocalVariableInfo,        _localIndex)
+DEFINE_FIELD_U(_isPinned,              RuntimeLocalVariableInfo,        _isPinned)
+DEFINE_CLASS(RUNTIME_LOCAL_VARIABLE_INFO,   Reflection,             RuntimeLocalVariableInfo)
 
 DEFINE_CLASS_U(Reflection,             MethodBody,                 MethodBody)
 DEFINE_FIELD_U(m_IL,                       MethodBody,         m_IL)
index 1d0fb95..f587b4c 100644 (file)
@@ -2430,7 +2430,7 @@ FCIMPL2(MethodBody *, RuntimeMethodHandle::GetMethodBody, ReflectMethodObject *p
     {
         METHODBODYREF MethodBodyObj;
         EXCEPTIONHANDLINGCLAUSEREF EHClauseObj;
-        LOCALVARIABLEINFOREF LocalVariableInfoObj;
+        RUNTIMELOCALVARIABLEINFOREF RuntimeLocalVariableInfoObj;
         U1ARRAYREF                  U1Array;
         BASEARRAYREF                TempArray;
         REFLECTCLASSBASEREF         declaringType;
@@ -2439,7 +2439,7 @@ FCIMPL2(MethodBody *, RuntimeMethodHandle::GetMethodBody, ReflectMethodObject *p
 
     gc.MethodBodyObj = NULL;
     gc.EHClauseObj = NULL;
-    gc.LocalVariableInfoObj = NULL;
+    gc.RuntimeLocalVariableInfoObj = NULL;
     gc.U1Array              = NULL;
     gc.TempArray            = NULL;
     gc.declaringType        = (REFLECTCLASSBASEREF)ObjectToOBJECTREF(pDeclaringTypeUNSAFE);
@@ -2469,7 +2469,7 @@ FCIMPL2(MethodBody *, RuntimeMethodHandle::GetMethodBody, ReflectMethodObject *p
             MethodTable * pExceptionHandlingClauseMT = MscorlibBinder::GetClass(CLASS__EH_CLAUSE);
             TypeHandle thEHClauseArray = ClassLoader::LoadArrayTypeThrowing(TypeHandle(pExceptionHandlingClauseMT), ELEMENT_TYPE_SZARRAY);
 
-            MethodTable * pLocalVariableMT = MscorlibBinder::GetClass(CLASS__LOCAL_VARIABLE_INFO);
+            MethodTable * pLocalVariableMT = MscorlibBinder::GetClass(CLASS__RUNTIME_LOCAL_VARIABLE_INFO);
             TypeHandle thLocalVariableArray = ClassLoader::LoadArrayTypeThrowing(TypeHandle(pLocalVariableMT), ELEMENT_TYPE_SZARRAY);
 
             Module* pModule = pMethod->GetModule();
@@ -2551,21 +2551,21 @@ FCIMPL2(MethodBody *, RuntimeMethodHandle::GetMethodBody, ReflectMethodObject *p
 
                 for (INT32 i = 0; i < cLocals; i ++)
                 {
-                    gc.LocalVariableInfoObj = (LOCALVARIABLEINFOREF)AllocateObject(pLocalVariableMT);
+                    gc.RuntimeLocalVariableInfoObj = (RUNTIMELOCALVARIABLEINFOREF)AllocateObject(pLocalVariableMT);
 
-                    gc.LocalVariableInfoObj->m_localIndex = i;
+                    gc.RuntimeLocalVariableInfoObj->_localIndex = i;
                     
                     metaSig.NextArg();
 
                     CorElementType eType;
                     IfFailThrow(metaSig.GetArgProps().PeekElemType(&eType));
                     if (ELEMENT_TYPE_PINNED == eType)
-                        gc.LocalVariableInfoObj->m_bIsPinned = TRUE;
+                        gc.RuntimeLocalVariableInfoObj->_isPinned = TRUE;
 
                     TypeHandle  tempType= metaSig.GetArgProps().GetTypeHandleThrowing(pModule, &sigTypeContext);       
                     OBJECTREF refLocalType = tempType.GetManagedClassObject();
-                    gc.LocalVariableInfoObj->SetType(refLocalType);
-                    gc.MethodBodyObj->m_localVariables->SetAt(i, (OBJECTREF) gc.LocalVariableInfoObj);
+                    gc.RuntimeLocalVariableInfoObj->SetType(refLocalType);
+                    gc.MethodBodyObj->m_localVariables->SetAt(i, (OBJECTREF) gc.RuntimeLocalVariableInfoObj);
                 }        
             }
             else
index c757f9d..f35ef44 100644 (file)
@@ -32,16 +32,16 @@ typedef enum ReflectionCallConv {
 
 class ExceptionHandlingClause;
 class MethodBody;
-class LocalVariableInfo;
+class RuntimeLocalVariableInfo;
 
 #ifdef USE_CHECKED_OBJECTREFS
 typedef REF<ExceptionHandlingClause> EXCEPTIONHANDLINGCLAUSEREF;
 typedef REF<MethodBody> METHODBODYREF;
-typedef REF<LocalVariableInfo> LOCALVARIABLEINFOREF;
+typedef REF<RuntimeLocalVariableInfo> RUNTIMELOCALVARIABLEINFOREF;
 #else
 typedef DPTR(ExceptionHandlingClause) EXCEPTIONHANDLINGCLAUSEREF;
 typedef DPTR(MethodBody) METHODBODYREF;
-typedef DPTR(LocalVariableInfo) LOCALVARIABLEINFOREF;
+typedef DPTR(RuntimeLocalVariableInfo) RUNTIMELOCALVARIABLEINFOREF;
 #endif
 
 class ExceptionHandlingClause : Object 
@@ -80,28 +80,28 @@ public:
     CLR_BOOL m_initLocals;    
 };
 
-class LocalVariableInfo : Object
+class RuntimeLocalVariableInfo : Object
 {
 private:
     // Disallow creation and copy construction of these.
-    LocalVariableInfo() { }
-    LocalVariableInfo(LocalVariableInfo &r) { }    
+    RuntimeLocalVariableInfo() { }
+    RuntimeLocalVariableInfo(RuntimeLocalVariableInfo &r) { }    
 
 public:
 
     REFLECTCLASSBASEREF GetType()
     {
-        return (REFLECTCLASSBASEREF)m_type;
+        return (REFLECTCLASSBASEREF)_type;
     }
 
     void SetType(OBJECTREF type)
     {
-        SetObjectReference(&m_type, type, GetAppDomain());
+        SetObjectReference(&_type, type, GetAppDomain());
     }
 
-    OBJECTREF m_type;
-    INT32 m_bIsPinned;
-    INT32 m_localIndex;
+    OBJECTREF _type;
+    INT32 _localIndex;
+    CLR_BOOL _isPinned;
 };
 
 class MdUtf8String {