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

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

            RuntimeTypeHandle arrElmTypeHandle =
                TypeSystemHelper.GetConstructedRuntimeTypeHandle(reader, debuggerPreparedExternalReferences);

            uint rank = reader.GetUnsigned();

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

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

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

            Array             returnValue;
            RuntimeTypeHandle arrayTypeHandle = default(RuntimeTypeHandle);
            // Get an array RuntimeTypeHandle given an element's RuntimeTypeHandle and rank.
            // Pass false for isMdArray, and rank == -1 for SzArrays
            IntPtr returnValueHandlePointer = IntPtr.Zero;
            uint   returnHandleIdentifier   = 0;

            try
            {
                if (rank == 1 && lowerBounds[0] == 0)
                {
                    // TODO : throw exception with loc message
                    bool success = TypeLoaderEnvironment.Instance.TryGetArrayTypeForElementType(arrElmTypeHandle, false, -1, out arrayTypeHandle);
                    Debug.Assert(success);
                    returnValue = Internal.Runtime.Augments.RuntimeAugments.NewArray(arrayTypeHandle, dims[0]);
                }
                else
                {
                    // TODO : throw exception with loc message
                    bool success = TypeLoaderEnvironment.Instance.TryGetArrayTypeForElementType(arrElmTypeHandle, true, (int)rank, out arrayTypeHandle);
                    Debug.Assert(success);
                    returnValue = Internal.Runtime.Augments.RuntimeAugments.NewMultiDimArray(
                        arrayTypeHandle,
                        dims,
                        lowerBounds);
                }
                GCHandle returnValueHandle = GCHandle.Alloc(returnValue);
                returnValueHandlePointer = GCHandle.ToIntPtr(returnValueHandle);
                returnHandleIdentifier   = RuntimeAugments.RhpRecordDebuggeeInitiatedHandle(returnValueHandlePointer);
            }
            finally
            {
                ReturnToDebuggerWithReturn(returnHandleIdentifier, returnValueHandlePointer, false);
            }
        }
Beispiel #2
0
        private unsafe static FuncEvalResult CallParameterizedFunctionOrNewParameterizedObject(ref long myFuncEvalId, byte *parameterBuffer, uint parameterBufferSize, bool isConstructor)
        {
            InvokeFunctionData invokeFunctionData = new InvokeFunctionData();

            LowLevelNativeFormatReader reader = new LowLevelNativeFormatReader(parameterBuffer, parameterBufferSize);

            myFuncEvalId = s_funcEvalId = (long)reader.GetUnsignedLong();
            uint parameterCount = reader.GetUnsigned();

            invokeFunctionData.parameterValues = new byte[parameterCount][];
            for (int i = 0; i < parameterCount; i++)
            {
                uint   parameterValueSize = reader.GetUnsigned();
                byte[] parameterValue     = new byte[parameterValueSize];
                for (int j = 0; j < parameterValueSize; j++)
                {
                    uint parameterByte = reader.GetUnsigned();
                    parameterValue[j] = (byte)parameterByte;
                }
                invokeFunctionData.parameterValues[i] = parameterValue;
            }
            ulong[] debuggerPreparedExternalReferences;
            BuildDebuggerPreparedExternalReferences(reader, out debuggerPreparedExternalReferences);

            bool hasThis;

            TypeDesc[] parameters;
            bool[]     parametersWithGenericDependentLayout;
            bool       result = TypeSystemHelper.CallingConverterDataFromMethodSignature(
                reader,
                debuggerPreparedExternalReferences,
                out hasThis,
                out parameters,
                out parametersWithGenericDependentLayout
                );

            invokeFunctionData.types = new RuntimeTypeHandle[parameters.Length];

            for (int i = 0; i < invokeFunctionData.types.Length; i++)
            {
                invokeFunctionData.types[i] = parameters[i].GetRuntimeTypeHandle();
            }

            LocalVariableType[] argumentTypes = new LocalVariableType[parameters.Length];
            for (int i = 0; i < parameters.Length; i++)
            {
                // TODO, FuncEval, what these false really means? Need to make sure our format contains those information
                argumentTypes[i] = new LocalVariableType(invokeFunctionData.types[i], false, false);
            }

            if (isConstructor)
            {
                // TODO, FuncEval, deal with Nullable objects
                invokeFunctionData.thisObj = RuntimeAugments.RawNewObject(invokeFunctionData.types[1]);
            }

            LocalVariableSet.SetupArbitraryLocalVariableSet <InvokeFunctionData>(InvokeFunction, ref invokeFunctionData, argumentTypes);

            return(invokeFunctionData.result);
        }
Beispiel #3
0
        private unsafe static void BuildDebuggerPreparedExternalReferences(LowLevelNativeFormatReader reader, out ulong[] debuggerPreparedExternalReferences)
        {
            uint eeTypeCount = reader.GetUnsigned();

            debuggerPreparedExternalReferences = new ulong[eeTypeCount];
            for (int i = 0; i < eeTypeCount; i++)
            {
                ulong eeType = reader.GetUnsignedLong();
                debuggerPreparedExternalReferences[i] = eeType;
            }
        }
Beispiel #4
0
        private unsafe static FuncEvalResult NewParameterizedArray(ref long myFuncEvalId, byte *parameterBuffer, uint parameterBufferSize)
        {
            LowLevelNativeFormatReader reader = new LowLevelNativeFormatReader(parameterBuffer, parameterBufferSize);

            myFuncEvalId = s_funcEvalId = (long)reader.GetUnsignedLong();
            ulong[] debuggerPreparedExternalReferences;
            BuildDebuggerPreparedExternalReferences(reader, out debuggerPreparedExternalReferences);

            RuntimeTypeHandle arrElmTypeHandle =
                TypeSystemHelper.GetConstructedRuntimeTypeHandle(reader, debuggerPreparedExternalReferences);

            uint rank = reader.GetUnsigned();

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

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

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

            Array             newArray        = null;
            RuntimeTypeHandle arrayTypeHandle = default(RuntimeTypeHandle);

            Exception ex = null;

            try
            {
                // Get an array RuntimeTypeHandle given an element's RuntimeTypeHandle and rank.
                // Pass false for isMdArray, and rank == -1 for SzArrays
                if (rank == 1 && lowerBounds[0] == 0)
                {
                    // TODO : throw exception with loc message
                    bool success = TypeLoaderEnvironment.Instance.TryGetArrayTypeForElementType(arrElmTypeHandle, false, -1, out arrayTypeHandle);
                    Debug.Assert(success);
                    newArray = Internal.Runtime.Augments.RuntimeAugments.NewArray(arrayTypeHandle, dims[0]);
                }
                else
                {
                    // TODO : throw exception with loc message
                    bool success = TypeLoaderEnvironment.Instance.TryGetArrayTypeForElementType(arrElmTypeHandle, true, (int)rank, out arrayTypeHandle);
                    Debug.Assert(success);
                    newArray = Internal.Runtime.Augments.RuntimeAugments.NewMultiDimArray(
                        arrayTypeHandle,
                        dims,
                        lowerBounds);
                }
            }
            catch (Exception e)
            {
                ex = e;
            }

            object returnValue;

            if (ex != null)
            {
                returnValue = ex;
            }
            else
            {
                returnValue = newArray;
            }

            return(new FuncEvalResult(returnValue, ex != null));
        }