public ExtractedMethodCreator(JAst ast, ScopeStatement[] scopes, HashSet<JVariable> inputVariables, HashSet<JVariable> outputVariables, SelectionTarget target, int indentSize, bool insertTabs) { _ast = ast; _scopes = scopes; _inputVars = new List<JVariable>(inputVariables); _outputVars = new List<JVariable>(outputVariables); _inputVars.Sort(CompareVariables); _outputVars.Sort(CompareVariables); _target = target; _indentSize = indentSize; _insertTabs = insertTabs; }
public ExtractMethodRequest(ScopeStatement targetScope, string name, string[] parameters) { _name = name; _parameters = parameters; _targetScope = targetScope; }
public NodeTarget(Dictionary<ScopeStatement, int> insertLocations, ScopeStatement[] parents, Node node) : base(insertLocations, parents) { _node = node; }
public SuiteTarget(Dictionary<ScopeStatement, int> insertLocations, ScopeStatement[] parents, SuiteStatement suite, SuiteStatement[] followingSuites, Span selectedSpan, int startIndex, int endIndex) : base(insertLocations, parents) { _suite = suite; _start = startIndex; _end = endIndex; _followingSuites = followingSuites; _selectedSpan = selectedSpan; }
public SelectionTarget(Dictionary<ScopeStatement, int> insertLocations, ScopeStatement[] parents) { _parents = parents; _insertLocations = insertLocations; }
internal override bool TryBindOuter(ScopeStatement from, string name, bool allowGlobals, out JVariable variable) { // Functions expose their locals to direct access ContainsNestedFreeVariables = true; if (TryGetVariable(name, out variable)) { variable.AccessedInNestedScope = true; if (variable.Kind == VariableKind.Local || variable.Kind == VariableKind.Parameter) { from.AddFreeVariable(variable, true); for (ScopeStatement scope = from.Parent; scope != this; scope = scope.Parent) { scope.AddFreeVariable(variable, false); } AddCellVariable(variable); } else if(allowGlobals) { from.AddReferencedGlobal(name); } return true; } return false; }
public static void Check(ScopeStatement scope) { if (scope.ScopeVariables != null) { FlowChecker fc = new FlowChecker(scope); scope.Walk(fc); } }
public FlowChecker(ScopeStatement scope) { var scopeVars = scope.ScopeVariables; _variables = new Dictionary<string, JVariable>(scopeVars.Count); foreach (var scopeVar in scopeVars) { _variables[scopeVar.Name] = scopeVar; } _bits = new BitArray(_variables.Count * 2); int index = 0; _variableIndices = new Dictionary<JVariable, int>(_variables.Count); foreach (var binding in _variables) { _variableIndices[binding.Value] = index++; } _scope = scope; _fdef = new FlowDefiner(this); _fdel = new FlowDeleter(this); }
internal virtual bool TryBindOuter(ScopeStatement from, string name, bool allowGlobals, out JVariable variable) { // Hide scope contents by default (only functions expose their locals) variable = null; return false; }
public ImportWalker(ScopeStatement targetStmt) { _targetStmt = targetStmt; }
internal override bool TryBindOuter(ScopeStatement from, string name, bool allowGlobals, out JVariable variable) { if (allowGlobals) { // Unbound variable from.AddReferencedGlobal(name); if (from.HasLateBoundVariableSets) { // If the context contains unqualified exec, new locals can be introduced // Therefore we need to turn this into a fully late-bound lookup which // happens when we don't have a JVariable. variable = null; return false; } else { // Create a global variable to bind to. variable = EnsureGlobalVariable(name); return true; } } variable = null; return false; }