예제 #1
0
		OpCodeHandlerInfo FindHandler(SigState execSigState) {
			foreach (var handler in handlerInfos) {
				if (Matches(handler.ExecSig, execSigState))
					return handler;
			}
			return null;
		}
예제 #2
0
 OpCodeHandlerInfo FindHandler(SigState execSigState)
 {
     foreach (var handler in handlerInfos)
     {
         if (Matches(handler.ExecSig, execSigState))
         {
             return(handler);
         }
     }
     return(null);
 }
예제 #3
0
        bool Matches(MethodSigInfo handlerSig, SigState sigState)
        {
            stack.Clear();
            sigIndexToHandlerIndex.Clear();
            handlerIndexToSigIndex.Clear();
            var handlerInfos = handlerSig.BlockInfos;
            var sigInfos     = sigState.SigInfo.BlockInfos;

            stack.Push(new MatchInfo(0, 0));
            while (stack.Count > 0)
            {
                var info = stack.Pop();

                int  handlerIndex, sigIndex;
                bool hasVisitedHandler = handlerIndexToSigIndex.TryGetValue(info.HandlerIndex, out sigIndex);
                bool hasVisitedSig     = sigIndexToHandlerIndex.TryGetValue(info.SigIndex, out handlerIndex);
                if (hasVisitedHandler != hasVisitedSig)
                {
                    return(false);
                }
                if (hasVisitedHandler)
                {
                    if (handlerIndex != info.HandlerIndex || sigIndex != info.SigIndex)
                    {
                        return(false);
                    }
                    continue;
                }
                handlerIndexToSigIndex[info.HandlerIndex] = info.SigIndex;
                sigIndexToHandlerIndex[info.SigIndex]     = info.HandlerIndex;

                var handlerBlock = handlerInfos[info.HandlerIndex];
                var sigBlock     = sigInfos[info.SigIndex];

                if (!handlerBlock.Equals(sigBlock))
                {
                    return(false);
                }

                for (int i = 0; i < handlerBlock.Targets.Count; i++)
                {
                    int handlerTargetIndex = handlerBlock.Targets[i];
                    int sigTargetIndex     = sigBlock.Targets[i];
                    stack.Push(new MatchInfo(handlerTargetIndex, sigTargetIndex));
                }
            }

            return(true);
        }
예제 #4
0
		bool Matches(MethodSigInfo handlerSig, SigState sigState) {
			stack.Clear();
			sigIndexToHandlerIndex.Clear();
			handlerIndexToSigIndex.Clear();
			var handlerInfos = handlerSig.BlockInfos;
			var sigInfos = sigState.SigInfo.BlockInfos;

			stack.Push(new MatchInfo(0, 0));
			while (stack.Count > 0) {
				var info = stack.Pop();

				int handlerIndex, sigIndex;
				bool hasVisitedHandler = handlerIndexToSigIndex.TryGetValue(info.HandlerIndex, out sigIndex);
				bool hasVisitedSig = sigIndexToHandlerIndex.TryGetValue(info.SigIndex, out handlerIndex);
				if (hasVisitedHandler != hasVisitedSig)
					return false;
				if (hasVisitedHandler) {
					if (handlerIndex != info.HandlerIndex || sigIndex != info.SigIndex)
						return false;
					continue;
				}
				handlerIndexToSigIndex[info.HandlerIndex] = info.SigIndex;
				sigIndexToHandlerIndex[info.SigIndex] = info.HandlerIndex;

				var handlerBlock = handlerInfos[info.HandlerIndex];
				var sigBlock = sigInfos[info.SigIndex];

				if (!handlerBlock.Equals(sigBlock))
					return false;

				for (int i = 0; i < handlerBlock.Targets.Count; i++) {
					int handlerTargetIndex = handlerBlock.Targets[i];
					int sigTargetIndex = sigBlock.Targets[i];
					stack.Push(new MatchInfo(handlerTargetIndex, sigTargetIndex));
				}
			}

			return true;
		}