Beispiel #1
0
        private unsafe static void NewParameterizedObjectNoConstructor(byte *parameterBuffer, uint parameterBufferSize)
        {
            uint         offset = 0;
            NativeReader reader = new NativeReader(parameterBuffer, parameterBufferSize);

            ulong[] debuggerPreparedExternalReferences;
            offset = BuildDebuggerPreparedExternalReferences(reader, offset, out debuggerPreparedExternalReferences);

            NativeLayoutInfoLoadContext nativeLayoutContext = new NativeLayoutInfoLoadContext();
            TypeSystemContext           typeSystemContext   = TypeSystemContextFactory.Create();

            nativeLayoutContext._module                = null;
            nativeLayoutContext._typeSystemContext     = typeSystemContext;
            nativeLayoutContext._typeArgumentHandles   = Instantiation.Empty;
            nativeLayoutContext._methodArgumentHandles = Instantiation.Empty;
            nativeLayoutContext._debuggerPreparedExternalReferences = debuggerPreparedExternalReferences;

            NativeParser parser         = new NativeParser(reader, offset);
            TypeDesc     objectTypeDesc = TypeLoaderEnvironment.Instance.GetConstructedTypeFromParserAndNativeLayoutContext(ref parser, nativeLayoutContext);

            TypeSystemContextFactory.Recycle(typeSystemContext);

            RuntimeTypeHandle objectTypeHandle = objectTypeDesc.GetRuntimeTypeHandle();
            object            returnValue      = RuntimeAugments.NewObject(objectTypeHandle);

            GCHandle returnValueHandle        = GCHandle.Alloc(returnValue);
            IntPtr   returnValueHandlePointer = GCHandle.ToIntPtr(returnValueHandle);
            uint     returnHandleIdentifier   = RuntimeAugments.RhpRecordDebuggeeInitiatedHandle(returnValueHandlePointer);

            ReturnToDebuggerWithReturn(returnHandleIdentifier, returnValueHandlePointer, false);
        }
Beispiel #2
0
 internal override void ParseBaseType(NativeLayoutInfoLoadContext nativeLayoutInfoLoadContext, NativeParser baseTypeParser)
 {
     if (!baseTypeParser.IsNull)
     {
         // If the base type is available from the native layout info use it if the type we have is a NoMetadataType
         SetBaseType((DefType)nativeLayoutInfoLoadContext.GetType(ref baseTypeParser));
     }
     else
     {
         // Set the base type for no metadata types, if we reach this point, and there isn't a parser, then we simply use the value from the template
         SetBaseType(ComputeTemplate().BaseType);
     }
 }
Beispiel #3
0
        private static TypeDesc GetConstructedType(LowLevelNativeFormatReader reader, ulong[] externalReferences)
        {
            NativeLayoutInfoLoadContext nativeLayoutContext = new NativeLayoutInfoLoadContext();
            TypeSystemContext           typeSystemContext   = TypeSystemContextFactory.Create();

            nativeLayoutContext._module                = null;
            nativeLayoutContext._typeSystemContext     = typeSystemContext;
            nativeLayoutContext._typeArgumentHandles   = Instantiation.Empty;
            nativeLayoutContext._methodArgumentHandles = Instantiation.Empty;
            nativeLayoutContext._debuggerPreparedExternalReferences = externalReferences;

            TypeDesc     objectTypeDesc = null;
            NativeParser parser         = new NativeParser(reader.InternalReader, reader.Offset);

            objectTypeDesc = TypeLoaderEnvironment.Instance.GetConstructedTypeFromParserAndNativeLayoutContext(
                ref parser,
                nativeLayoutContext);
            TypeSystemContextFactory.Recycle(typeSystemContext);
            return(objectTypeDesc);
        }
Beispiel #4
0
        private unsafe static void NewParameterizedArray(byte *parameterBuffer, uint parameterBufferSize)
        {
            uint         offset = 0;
            NativeReader reader = new NativeReader(parameterBuffer, parameterBufferSize);

            ulong[] debuggerPreparedExternalReferences;
            offset = BuildDebuggerPreparedExternalReferences(reader, offset, out debuggerPreparedExternalReferences);

            NativeLayoutInfoLoadContext nativeLayoutContext = new NativeLayoutInfoLoadContext();
            TypeSystemContext           typeSystemContext   = TypeSystemContextFactory.Create();

            nativeLayoutContext._module                = null;
            nativeLayoutContext._typeSystemContext     = typeSystemContext;
            nativeLayoutContext._typeArgumentHandles   = Instantiation.Empty;
            nativeLayoutContext._methodArgumentHandles = Instantiation.Empty;
            nativeLayoutContext._debuggerPreparedExternalReferences = debuggerPreparedExternalReferences;

            NativeParser parser         = new NativeParser(reader, offset);
            TypeDesc     arrElementType = TypeLoaderEnvironment.Instance.GetConstructedTypeFromParserAndNativeLayoutContext(ref parser, nativeLayoutContext);

            TypeSystemContextFactory.Recycle(typeSystemContext);

            uint rank = parser.GetUnsigned();

            int[] dims        = new int[rank];
            int[] lowerBounds = new int[rank];

            for (uint i = 0; i < rank; ++i)
            {
                dims[i] = (int)parser.GetUnsigned();
            }

            for (uint i = 0; i < rank; ++i)
            {
                lowerBounds[i] = (int)parser.GetUnsigned();
            }

            RuntimeTypeHandle typeHandle      = arrElementType.GetRuntimeTypeHandle();
            RuntimeTypeHandle arrayTypeHandle = default(RuntimeTypeHandle);
            Array             returnValue;
            // Get an array RuntimeTypeHandle given an element's RuntimeTypeHandle and rank.
            // Pass false for isMdArray, and rank == -1 for SzArrays
            bool succeed = false;

            if (rank == 1 && lowerBounds[0] == 0)
            {
                succeed = TypeLoaderEnvironment.Instance.TryGetArrayTypeForElementType(
                    typeHandle,
                    false,
                    -1,
                    out arrayTypeHandle);
                Debug.Assert(succeed);

                returnValue = Internal.Runtime.Augments.RuntimeAugments.NewArray(
                    arrayTypeHandle,
                    dims[0]);
            }
            else
            {
                succeed = TypeLoaderEnvironment.Instance.TryGetArrayTypeForElementType(
                    typeHandle,
                    true,
                    (int)rank,
                    out arrayTypeHandle
                    );
                Debug.Assert(succeed);
                returnValue = Internal.Runtime.Augments.RuntimeAugments.NewMultiDimArray(
                    arrayTypeHandle,
                    dims,
                    lowerBounds
                    );
            }
            GCHandle returnValueHandle        = GCHandle.Alloc(returnValue);
            IntPtr   returnValueHandlePointer = GCHandle.ToIntPtr(returnValueHandle);
            uint     returnHandleIdentifier   = RuntimeAugments.RhpRecordDebuggeeInitiatedHandle(returnValueHandlePointer);

            ReturnToDebuggerWithReturn(returnHandleIdentifier, returnValueHandlePointer, false);
        }
Beispiel #5
0
 /// Parse the native layout to ensure that the type has proper base type setup.
 /// This is used to generalize out some behavior of NoMetadataTypes which actually use this information
 internal virtual void ParseBaseType(NativeLayoutInfoLoadContext nativeLayoutInfoLoadContext, NativeParser baseTypeParser)
 {
     return;
 }