Ejemplo n.º 1
0
 private bool IsInitialized(JVariable/*!*/ variable)
 {
     return _bits.Get(_variableIndices[variable] * 2 + 1);
 }
Ejemplo n.º 2
0
 public ClosureInfo(JVariable variable, bool accessedInScope)
 {
     Variable = variable;
     AccessedInScope = accessedInScope;
 }
Ejemplo n.º 3
0
 private bool IsAssigned(JVariable/*!*/ variable)
 {
     return _bits.Get(_variableIndices[variable] * 2);
 }
Ejemplo n.º 4
0
 private bool ReadFromExtractedCode(JVariable variable)
 {
     return _readBeforeInitialized.Contains(variable) &&
         _inputCollector._allReadVariables.Contains(variable);
 }
Ejemplo n.º 5
0
 private bool TryGetAnyVariable(string name, out JVariable variable)
 {
     if (_variables != null && name != null) {
         return _variables.TryGetValue(name, out variable);
     } else {
         variable = null;
         return false;
     }
 }
Ejemplo n.º 6
0
 private void SetInitialized(JVariable/*!*/ variable, bool value)
 {
     _bits.Set(_variableIndices[variable] * 2 + 1, value);
 }
Ejemplo n.º 7
0
 internal override bool ExposesLocalVariable(JVariable variable)
 {
     return NeedsLocalsDictionary;
 }
Ejemplo n.º 8
0
 /*!*/
 internal JVariable CreateVariable(string name, VariableKind kind)
 {
     EnsureVariables();
     JVariable variable;
     _variables[name] = variable = new JVariable(name, kind, this);
     return variable;
 }
Ejemplo n.º 9
0
 internal abstract bool ExposesLocalVariable(JVariable variable);
Ejemplo n.º 10
0
        internal void AddFreeVariable(JVariable variable, bool accessedInScope)
        {
            if (_freeVars == null) {
                _freeVars = new List<JVariable>();
            }

            if (!_freeVars.Contains(variable)) {
                _freeVars.Add(variable);
            }
        }
Ejemplo n.º 11
0
 internal void AddVariable(JVariable variable)
 {
     EnsureVariables();
     _variables[variable.Name] = variable;
 }
Ejemplo n.º 12
0
        internal void AddCellVariable(JVariable variable)
        {
            if (_cellVars == null) {
                _cellVars = new List<string>();
            }

            if (!_cellVars.Contains(variable.Name)) {
                _cellVars.Add(variable.Name);
            }
        }
Ejemplo n.º 13
0
 public static void AddVariable(this Parameter node, JAst ast, bool bindNames, JVariable variable)
 {
     if (bindNames) {
         ast.SetAttribute(node, Variable, variable);
     }
 }
Ejemplo n.º 14
0
 private static int CompareVariables(JVariable left, JVariable right)
 {
     return String.Compare(left.Name, right.Name);
 }
Ejemplo n.º 15
0
 private bool ReadBeforeInitialized(JVariable variable)
 {
     return _readBeforeInitialized.Contains(variable);
 }
Ejemplo n.º 16
0
 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;
 }
Ejemplo n.º 17
0
 private void SetAssigned(JVariable/*!*/ variable, bool value)
 {
     _bits.Set(_variableIndices[variable] * 2, value);
 }
Ejemplo n.º 18
0
 internal bool TryGetVariable(string name, out JVariable variable)
 {
     if (TryGetAnyVariable(name, out variable)) {
         return true;
     } else {
         variable = null;
         return false;
     }
 }
Ejemplo n.º 19
0
 internal override bool ExposesLocalVariable(JVariable variable)
 {
     return true;
 }
Ejemplo n.º 20
0
        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;
        }
Ejemplo n.º 21
0
        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;
        }
Ejemplo n.º 22
0
Archivo: JAst.cs Proyecto: borota/JTVS
        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;
        }