private bool IsInitialized(JVariable/*!*/ variable) { return _bits.Get(_variableIndices[variable] * 2 + 1); }
public ClosureInfo(JVariable variable, bool accessedInScope) { Variable = variable; AccessedInScope = accessedInScope; }
private bool IsAssigned(JVariable/*!*/ variable) { return _bits.Get(_variableIndices[variable] * 2); }
private bool ReadFromExtractedCode(JVariable variable) { return _readBeforeInitialized.Contains(variable) && _inputCollector._allReadVariables.Contains(variable); }
private bool TryGetAnyVariable(string name, out JVariable variable) { if (_variables != null && name != null) { return _variables.TryGetValue(name, out variable); } else { variable = null; return false; } }
private void SetInitialized(JVariable/*!*/ variable, bool value) { _bits.Set(_variableIndices[variable] * 2 + 1, value); }
internal override bool ExposesLocalVariable(JVariable variable) { return NeedsLocalsDictionary; }
/*!*/ internal JVariable CreateVariable(string name, VariableKind kind) { EnsureVariables(); JVariable variable; _variables[name] = variable = new JVariable(name, kind, this); return variable; }
internal abstract bool ExposesLocalVariable(JVariable variable);
internal void AddFreeVariable(JVariable variable, bool accessedInScope) { if (_freeVars == null) { _freeVars = new List<JVariable>(); } if (!_freeVars.Contains(variable)) { _freeVars.Add(variable); } }
internal void AddVariable(JVariable variable) { EnsureVariables(); _variables[variable.Name] = variable; }
internal void AddCellVariable(JVariable variable) { if (_cellVars == null) { _cellVars = new List<string>(); } if (!_cellVars.Contains(variable.Name)) { _cellVars.Add(variable.Name); } }
public static void AddVariable(this Parameter node, JAst ast, bool bindNames, JVariable variable) { if (bindNames) { ast.SetAttribute(node, Variable, variable); } }
private static int CompareVariables(JVariable left, JVariable right) { return String.Compare(left.Name, right.Name); }
private bool ReadBeforeInitialized(JVariable variable) { return _readBeforeInitialized.Contains(variable); }
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; }
private void SetAssigned(JVariable/*!*/ variable, bool value) { _bits.Set(_variableIndices[variable] * 2, value); }
internal bool TryGetVariable(string name, out JVariable variable) { if (TryGetAnyVariable(name, out variable)) { return true; } else { variable = null; return false; } }
internal override bool ExposesLocalVariable(JVariable variable) { return true; }
private static bool HasClosureVariable(List<ClosureInfo> closureVariables, JVariable variable) { if (closureVariables == null) { return false; } for (int i = 0; i < closureVariables.Count; i++) { if (closureVariables[i].Variable == variable) { return true; } } return false; }
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; }
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; }