예제 #1
0
        private IEnumerable<IAnalysisVariable> GetVariablesInScope(Lookup name, EnvironmentRecord scope) {
            var result = new List<IAnalysisVariable>();

            VariableDef var;
            if (scope.TryGetVariable(name.Name, out var)) {
                result.AddRange(VariableTransformer.ScopeToVariables.ToVariables(_unit, var));
            }

            // if a variable is imported from another module then also yield the defs/refs for the 
            // value in the defining module.
            var linked = scope.GetLinkedVariablesNoCreate(name.Name);
            if (linked != null) {
                result.AddRange(linked.SelectMany(x => VariableTransformer.ScopeToVariables.ToVariables(_unit, x)));
            }
            return result;
        }