コード例 #1
0
ファイル: ExprVisitorBase.cs プロジェクト: zwy2014/corefx
        /////////////////////////////////////////////////////////////////////////////////

        protected EXPRSTMT DispatchStatementList(EXPRSTMT expr)
        {
            Debug.Assert(expr != null);

            EXPRSTMT first = expr;
            EXPRSTMT pexpr = first;

            while (pexpr != null)
            {
                // If the processor replaces the statement -- potentially with
                // null, another statement, or a list of statements -- then we
                // make sure that the statement list is hooked together correctly.

                EXPRSTMT next = pexpr.GetOptionalNextStatement();
                EXPRSTMT old  = pexpr;

                // Unhook the next one.
                pexpr.SetOptionalNextStatement(null);

                EXPR result = Dispatch(pexpr);
                Debug.Assert(result == null || result.isSTMT());

                if (pexpr == first)
                {
                    first = (result == null) ? null : result.asSTMT();
                }
                else
                {
                    pexpr.SetOptionalNextStatement((result == null) ? null : result.asSTMT());
                }

                // A transformation may return back a list of statements (or
                // if the statements have been determined to be unnecessary,
                // perhaps it has simply returned null.)
                //
                // Skip visiting the new list, then hook the tail of the old list
                // up to the end of the new list.

                while (pexpr.GetOptionalNextStatement() != null)
                {
                    pexpr = pexpr.GetOptionalNextStatement();
                }

                // Re-hook the next pointer.
                pexpr.SetOptionalNextStatement(next);
            }
            return(first);
        }
コード例 #2
0
ファイル: ExprVisitorBase.cs プロジェクト: noahfalk/corefx
        public EXPR Visit(EXPR pExpr)
        {
            if (pExpr == null)
            {
                return null;
            }

            EXPR pResult;
            if (IsCachedExpr(pExpr, out pResult))
            {
                return pResult;
            }

            if (pExpr.isSTMT())
            {
                return CacheExprMapping(pExpr, DispatchStatementList(pExpr.asSTMT()));
            }

            return CacheExprMapping(pExpr, Dispatch(pExpr));
        }
コード例 #3
0
ファイル: ExprVisitorBase.cs プロジェクト: zwy2014/corefx
        public EXPR Visit(EXPR pExpr)
        {
            if (pExpr == null)
            {
                return(null);
            }

            EXPR pResult;

            if (IsCachedExpr(pExpr, out pResult))
            {
                return(pResult);
            }

            if (pExpr.isSTMT())
            {
                return(CacheExprMapping(pExpr, DispatchStatementList(pExpr.asSTMT())));
            }

            return(CacheExprMapping(pExpr, Dispatch(pExpr)));
        }