예제 #1
0
        protected virtual bool TryWith(IInitializerCollector collector, int index, IList <IElement> elements)
        {
            Expression @new;
            VariableAssignmentElement assignment;
            var matched = Matcher
                          .For(elements[index]).As <VariableAssignmentElement>()
                          .AssignTo(out assignment)
                          .For(v => v.Value).Match(collector.MatchNew)
                          .AssignTo(out @new)
                          .Matched;

            if (!matched)
            {
                return(false);
            }

            var initializer = collector.AttemptToCollect(@new, assignment.VariableIndex, index, elements);

            if (initializer != null)
            {
                assignment.Value = initializer;
                this.inliner.Inline(elements, i => i == assignment.VariableIndex);
                return(true);
            }

            return(false);
        }
        protected virtual bool TryWith(IInitializerCollector collector, int index, IList<IElement> elements)
        {
            Expression @new;
            VariableAssignmentElement assignment;
            var matched = Matcher
                .For(elements[index]).As<VariableAssignmentElement>()
                .AssignTo(out assignment)
                .For(v => v.Value).Match(collector.MatchNew)
                    .AssignTo(out @new)
                .Matched;

            if (!matched)
                return false;

            var initializer = collector.AttemptToCollect(@new, assignment.VariableIndex, index, elements);
            if (initializer != null) {
                assignment.Value = initializer;
                this.inliner.Inline(elements, i => i == assignment.VariableIndex);
                return true;
            }

            return false;
        }