本文整理汇总了C#中SortedSet.AddIfNew方法的典型用法代码示例。如果您正苦于以下问题:C# SortedSet.AddIfNew方法的具体用法?C# SortedSet.AddIfNew怎么用?C# SortedSet.AddIfNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedSet
的用法示例。
在下文中一共展示了SortedSet.AddIfNew方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindBasicBlockTargets
/// <summary>
/// Finds basic block targets.
/// </summary>
/// <returns></returns>
/// <exception cref="InvalidCompilerException"></exception>
private SortedSet<int> FindBasicBlockTargets()
{
var targets = new SortedSet<int>();
targets.Add(0);
// Find out all targets labels
for (var ctx = new Context(InstructionSet, 0); ctx.Index >= 0; ctx.GotoNext())
{
switch (ctx.Instruction.FlowControl)
{
case FlowControl.Next: continue;
case FlowControl.Call: continue;
case FlowControl.Break: goto case FlowControl.UnconditionalBranch;
case FlowControl.Return: continue;
case FlowControl.Throw: continue;
case FlowControl.UnconditionalBranch:
{
//Debug.Assert(ctx.BranchTargets.Length == 1);
targets.AddIfNew(ctx.BranchTargets[0]);
continue;
}
case FlowControl.Switch: goto case FlowControl.ConditionalBranch;
case FlowControl.ConditionalBranch:
{
foreach (int target in ctx.BranchTargets)
targets.AddIfNew(target);
targets.AddIfNew(ctx.Next.Label);
continue;
}
case FlowControl.EndFinally: continue;
case FlowControl.Leave:
{
//Debug.Assert(ctx.BranchTargets.Length == 1);
targets.AddIfNew(ctx.BranchTargets[0]);
continue;
}
default:
throw new InvalidCompilerException();
}
}
// Add exception targets
foreach (var handler in MethodCompiler.Method.ExceptionHandlers)
{
targets.AddIfNew(handler.HandlerStart);
targets.AddIfNew(handler.TryStart);
if (handler.FilterOffset != null)
targets.AddIfNew(handler.FilterOffset.Value);
}
//foreach (var target in targets)
//{
// //trace.Log("Target: " + target.ToString("X4"));
//}
return targets;
}