Exemple #1
0
    protected override ILBlock VisitBlock(ILBlock block)
    {
        currentScope++;

        var result = base.VisitBlock(block);

        currentScope--;

        if (block.Body.Count == 0)
            return result;

        var toOffset = block.LastILOffset();

        if (toOffset < 0)
            return result;

        foreach (var start in starts.Where(kvp => kvp.Key.Item2 == currentScope + 1).ToList())
        {
            starts.Remove(start.Key);

            List<ILExpression> args;
            if (block.Body.Last().Match(ILCode.Ret, out args) && args.Count == 1 && args[0].MatchLdloc(start.Key.Item1))
                continue; // Returning the variable

            UsingRanges.Add(new ILRange { From = start.Value, To = toOffset });
        }

        return result;
    }
Exemple #2
0
    protected override ILBlock VisitBlock(ILBlock block)
    {
        currentScope++;

        var result = base.VisitBlock(block);

        currentScope--;

        if (block.Body.Count == 0)
        {
            return(result);
        }

        var toOffset = block.LastILOffset();

        if (toOffset < 0)
        {
            return(result);
        }

        foreach (var start in starts.Where(kvp => kvp.Key.Item2 == currentScope + 1).ToList())
        {
            starts.Remove(start.Key);

            List <ILExpression> args;
            if (block.Body.Last().Match(ILCode.Ret, out args) && args.Count == 1 && args[0].MatchLdloc(start.Key.Item1))
            {
                continue; // Returning the variable
            }
            UsingRanges.Add(new ILRange {
                From = start.Value, To = toOffset
            });
        }

        return(result);
    }