コード例 #1
0
ファイル: Runtime.cs プロジェクト: yonglehou/MOSA-Project
        public static MetadataPRDefinitionStruct *GetProtectedRegionEntryByAddress(uint address, MetadataTypeStruct *exceptionType, MetadataMethodStruct *methodDef)
        {
            var protectedRegionTable = methodDef->ProtectedRegionTable;

            if (protectedRegionTable == null)
            {
                return(null);
            }

            uint method = (uint)methodDef->Method;

            if (method == 0)
            {
                return(null);
            }

            uint offset  = address - method;
            int  entries = protectedRegionTable->NumberOfRegions;

            int entry = 0;
            MetadataPRDefinitionStruct *protectedRegionDef = null;
            uint currentStart = uint.MinValue;
            uint currentEnd   = uint.MaxValue;

            while (entry < entries)
            {
                var prDef = MetadataPRTableStruct.GetProtecteRegionDefinitionAddress(protectedRegionTable, (uint)entry);

                uint start = prDef->StartOffset;
                uint end   = prDef->EndOffset;

                if ((offset >= start) && (offset < end) && (start >= currentStart) && (end < currentEnd))
                {
                    var handlerType = prDef->HandlerType;

                    // If the handler is a Finally clause, accept without testing
                    if (handlerType == ExceptionHandlerType.Finally)
                    {
                        protectedRegionDef = prDef;
                        currentStart       = start;
                        currentEnd         = end;
                        entry++;
                        continue;
                    }

                    var exType = prDef->ExceptionType;

                    // If the handler is a Exception clause, accept if the exception Type
                    // is in the is within the inhertiance chain of the exception object
                    if (handlerType == ExceptionHandlerType.Exception && IsTypeInInheritanceChain(exType, exceptionType))
                    {
                        protectedRegionDef = prDef;
                        currentStart       = start;
                        currentEnd         = end;
                        entry++;
                        continue;
                    }
                }

                entry++;
            }

            return(protectedRegionDef);
        }
コード例 #2
0
ファイル: Runtime.cs プロジェクト: yonglehou/MOSA-Project
 public static string GetMethodDefinitionName(MetadataMethodStruct *methodDef)
 {
     return(InitializeMetadataString(methodDef->Name));
 }
コード例 #3
0
 public static uint *GetParameterDefinitionAddress(MetadataMethodStruct *data, uint slot)
 {
     return((uint *)*((uint *)data + MetadataMethodStruct.ParametersOffset + slot));
 }