Esempio n. 1
0
            private ExprParamPair GenChain(PhraseChain stmt, ParamList overlapCandidate)
            {
                Contract.Requires <ArgumentNullException>(stmt != null);
                Contract.Ensures(Contract.Result <ExprParamPair>() != null);
                Contract.Ensures(Contract.Result <ExprParamPair>().Expression != null);
                Contract.Ensures(Contract.Result <ExprParamPair>().Expression.Type != typeof(void));

                ParamList  assigned = null;
                Expression lastExpr = null;
                var        exprs    = new List <Expression>();
                var        local    = new List <ParameterExpression>();

                foreach (var ph in stmt.Phrases)
                {
                    ParameterExpression tmpVar = null;
                    if (lastExpr != null)
                    {
                        tmpVar = Expression.Parameter(lastExpr.Type);
                        exprs.Add(Expression.Assign(tmpVar, lastExpr));
                        local.Add(tmpVar);
                    }
                    exprs.Add(DebugInfo(ph.Range));
                    var pair = GenPhrase(ph, tmpVar, assigned, overlapCandidate);
                    assigned = ParamList.Merge(pair.Parameters, assigned);
                    lastExpr = pair.Expression;
                }
                exprs.Add(lastExpr);
                return(new ExprParamPair(Expression.Block(local, exprs), assigned));
            }
Esempio n. 2
0
            private ExprParamPair GenChain(PhraseChain stmt, ParamList overlapCandidate)
            {
                Contract.Requires<ArgumentNullException>(stmt != null);
                Contract.Ensures(Contract.Result<ExprParamPair>() != null);
                Contract.Ensures(Contract.Result<ExprParamPair>().Expression != null);
                Contract.Ensures(Contract.Result<ExprParamPair>().Expression.Type != typeof(void));

                ParamList assigned = null;
                Expression lastExpr = null;
                var exprs = new List<Expression>();
                var local = new List<ParameterExpression>();
                foreach (var ph in stmt.Phrases) {
                    ParameterExpression tmpVar = null;
                    if (lastExpr != null) {
                        tmpVar = Expression.Parameter(lastExpr.Type);
                        exprs.Add(Expression.Assign(tmpVar, lastExpr));
                        local.Add(tmpVar);
                    }
                    exprs.Add(DebugInfo(ph.Range));
                    var pair = GenPhrase(ph, tmpVar, assigned, overlapCandidate);
                    assigned = ParamList.Merge(pair.Parameters, assigned);
                    lastExpr = pair.Expression;
                }
                exprs.Add(lastExpr);
                return new ExprParamPair(Expression.Block(local, exprs), assigned);
            }