コード例 #1
0
        public void VisitNode(JSFunctionExpression fn)
        {
            // Create a new visitor for nested function expressions
            if (Stack.OfType<JSFunctionExpression>().Skip(1).FirstOrDefault() != null) {
                var nested = new OptimizeArrayEnumerators(TypeSystem, FunctionSource);
                nested.Visit(fn);

                return;
            }

            Function = fn;
            VisitChildren(fn);
        }
コード例 #2
0
        public void VisitNode(JSFunctionExpression fn)
        {
            // Create a new visitor for nested function expressions
            if (Stack.OfType <JSFunctionExpression>().Skip(1).FirstOrDefault() != null)
            {
                var nested = new OptimizeArrayEnumerators(TypeSystem, FunctionSource);
                nested.Visit(fn);

                return;
            }

            Function  = fn;
            FirstPass = FunctionSource.GetFirstPass(Function.Method.QualifiedIdentifier);

            VisitChildren(fn);

            if (EnumeratorsToKill.Count > 0)
            {
                // Rerun the static analyzer since we made major changes
                FunctionSource.InvalidateFirstPass(Function.Method.QualifiedIdentifier);
                FirstPass = FunctionSource.GetFirstPass(Function.Method.QualifiedIdentifier);

                // Scan to see if any of the enumerators we eliminated uses of are now
                //  unreferenced. If they are, eliminate them entirely.
                foreach (var variable in EnumeratorsToKill)
                {
                    var variableName = variable.Name;
                    var accesses     = (
                        from a in FirstPass.Accesses
                        where a.Source.Name == variableName
                        select a
                        );

                    if (!accesses.Any())
                    {
                        var eliminator = new VariableEliminator(
                            variable, new JSNullExpression()
                            );
                        eliminator.Visit(fn);
                    }
                }
            }
        }
コード例 #3
0
        public void VisitNode(JSFunctionExpression fn)
        {
            // Create a new visitor for nested function expressions
            if (Stack.OfType<JSFunctionExpression>().Skip(1).FirstOrDefault() != null) {
                var nested = new OptimizeArrayEnumerators(TypeSystem, FunctionSource);
                nested.Visit(fn);

                return;
            }

            Function = fn;
            FirstPass = FunctionSource.GetFirstPass(Function.Method.QualifiedIdentifier);

            VisitChildren(fn);

            if (EnumeratorsToKill.Count > 0) {
                // Rerun the static analyzer since we made major changes
                FunctionSource.InvalidateFirstPass(Function.Method.QualifiedIdentifier);
                FirstPass = FunctionSource.GetFirstPass(Function.Method.QualifiedIdentifier);

                // Scan to see if any of the enumerators we eliminated uses of are now
                //  unreferenced. If they are, eliminate them entirely.
                foreach (var variable in EnumeratorsToKill) {
                    var variableName = variable.Name;
                    var accesses = (
                        from a in FirstPass.Accesses
                        where a.Source.Name == variableName
                        select a
                    );

                    if (!accesses.Any()) {
                        var eliminator = new VariableEliminator(
                            variable, new JSNullExpression()
                        );
                        eliminator.Visit(fn);
                    }
                }
            }
        }