protected ActivationObject(Statement node, ActivationObject parent, ErrorSink errorSink) {
            _node = node;
            m_useStrict = false;

            Parent = parent;
            NameTable = new Dictionary<string, JSVariableField>();
            ChildScopes = new List<ActivationObject>();

            // if our parent is a scope....
            if (parent != null) {
                // add us to the parent's list of child scopes
                parent.ChildScopes.Add(this);

                // if the parent is strict, so are we
                UseStrict = parent.UseStrict;
            }

            // create the two lists of declared items for this scope
            ScopeLookups = new HashSet<Lookup>();
            VarDeclaredNames = new HashSet<INameDeclaration>();
            LexicallyDeclaredNames = new HashSet<INameDeclaration>();

            GhostedCatchParameters = new HashSet<ParameterDeclaration>();
            GhostedFunctions = new HashSet<FunctionObject>();

            _errorSink = errorSink;
        }
示例#2
0
        internal FunctionScope(Statement node, ActivationObject parent, bool isExpression, FunctionObject funcObj, ErrorSink errorSink)
            : base(node, parent, errorSink)
        {
            m_refScopes = new HashSet<ActivationObject>();
            if (isExpression)
            {
                // parent scopes automatically reference enclosed function expressions
                AddReference(Parent);
            }

            FunctionObject = funcObj;
        }
示例#3
0
 public static Expression GetExpression(Statement statement)
 {
     if (statement is Block)
     {
         if (((Block)statement).Count == 1)
         {
             return GetExpression(((Block)statement)[0]);
         }
     }
     else if (statement is ExpressionStatement)
     {
         var exprStmt = (ExpressionStatement)statement;
         return exprStmt.Expression;
     }
     else if (statement is ReturnNode)
     {
         return ((ReturnNode)statement).Operand;
     }
     return null;
 }
示例#4
0
 internal EvalAnalysisUnit(Statement ast, JsAst tree, EnvironmentRecord scope)
     : base(ast, tree, scope) {
 }
示例#5
0
 public BlockScope(Statement node, ActivationObject parent, ErrorSink errorSink)
     : base(node, parent, errorSink)
 {
 }
示例#6
0
 internal static Expression GetExpression(Statement statement) {
     if (statement is ExpressionStatement) {
         return ((ExpressionStatement)statement).Expression;
     } else if (statement is ReturnNode) {
         return ((ReturnNode)statement).Operand;
     } else {
         return null;
     }
 }
示例#7
0
 internal CatchScope(Statement node, ActivationObject parent, ParameterDeclaration catchParameter, ErrorSink errorSink)
     : base(node, parent, errorSink)
 {
     CatchParameter = catchParameter;
 }
 private Statement GetTargetStatement(Statement node) {
     Statement targetNode = node;
     while (targetNode.Parent != null &&
         targetNode.Parent.GetEndIndex(_tree.LocationResolver) == node.GetEndIndex(_tree.LocationResolver)) {
         if (targetNode.Parent != null && targetNode.Parent.Parent is JsAst) {
             // https://nodejstools.codeplex.com/workitem/1102
             // We don't want to reformat the entire document just because someone
             // is doing something at the end of the document.
             break;
         }
         targetNode = targetNode.Parent;
     }
     return targetNode;
 }
 private void CheckStatement(Statement node) {
     if (_typedChar == ';' && node.GetEndIndex(_tree.LocationResolver) == _position) {
         // if(1)if(1)if(1)if(1)x+=2;
         // We want to reformat all of the if statements that are nested
         // so walk up the parent nodes as long as they are all terminated
         // at the same semicolon.                   
         Span = GetTargetStatement(node).GetSpan(_tree.LocationResolver);
     }
 }
 public WithScope(Statement node, ActivationObject parent, ErrorSink errorSink)
     : base(node, parent, errorSink)
 {
     IsInWithScope = true;
 }
示例#11
0
 /// <summary>
 /// Replaces the whitespace for a control flow node.  Updates the current indentation
 /// level and then updates the whitespace after the keyword based upon the format
 /// options.
 /// </summary>
 private void ReplaceControlFlowWhiteSpace(Statement node, int keywordLength) {
     ReplaceFollowingWhiteSpace(node.GetStartIndex(_tree.LocationResolver) + keywordLength, _options.SpaceAfterKeywordsInControlFlowStatements ? " " : "");
 }