Exemplo n.º 1
0
        public static List <LocalVariable> ComputeUnusedArguments(
            List <LocalVariable> argList,
            UseDefDescription useDef)
        {
            var allUsages       = useDef.GetAllUsedVariables();
            var stillUnused     = new List <LocalVariable>();
            var unusedArguments = new HashSet <LocalVariable>(argList);

            foreach (var unusedArgument in unusedArguments)
            {
                if (!allUsages.Contains(unusedArgument))
                {
                    stillUnused.Add(unusedArgument);
                }
            }
            return(stillUnused.ToList());
        }
Exemplo n.º 2
0
        public static HashSet <LocalVariable> GetAllUsedVariables(this UseDefDescription useDef,
                                                                  bool includeDefinitions = false)
        {
            var result     = new HashSet <LocalVariable>();
            var operations = useDef.GetLocalOperations();

            for (var index = 0; index < operations.Length; index++)
            {
                var usages = useDef.GetUsages(index);
                foreach (var usage in usages)
                {
                    result.Add(usage);
                }
                if (includeDefinitions)
                {
                    var definition = useDef.GetDefinition(index);
                    if (definition != null)
                    {
                        result.Add(definition);
                    }
                }
            }
            return(result);
        }