protected override void Assign(BoundNode node, BoundExpression value, bool assigned = true)
        {
            switch (node.Kind)
            {
            case BoundKind.LocalDeclaration:
                var decl = node.Syntax as VariableDeclaratorSyntax;
                if (this.regionPlace == RegionPlace.inside && decl != null && decl.Identifier.Span.End < region.Start)
                {
                    this.regionPlace = RegionPlace.after;
                    LeaveRegion();
                }

                break;

            case BoundKind.Local:
            case BoundKind.Parameter:
            case BoundKind.ThisReference:
                if (this.regionPlace == RegionPlace.inside && node.Syntax.Span.End < region.Start)
                {
                    this.regionPlace = RegionPlace.after;
                    LeaveRegion();
                }

                break;
            }

            base.Assign(node, value, assigned);
        }
        /// <summary>
        /// Used to keep track of whether we are currently within the region or not.
        /// </summary>
        /// <param name="currentLocation"></param>
        private void NoteLocation(TextSpan currentLocation)
        {
            switch (regionPlace)
            {
            case RegionPlace.before:
                if (currentLocation.Start >= region.Start)
                {
                    regionPlace = RegionPlace.inside;
                    EnterRegion();
                    goto case RegionPlace.inside;
                }

                break;

            case RegionPlace.inside:
                if (currentLocation.Start > region.End)
                {
                    regionPlace = RegionPlace.after;
                    LeaveRegion();
                    goto case RegionPlace.after;
                }
                else
                {
                    // we have a location that spans inside and outside.
                    // probably the region is a subexpression and we are looking
                    // at an enclosing expression.  We depend on the positions coming from the
                    // subexpressions to properly compute the before/inside/after.
                }

                break;

            case RegionPlace.after:
                // Should move monotonically forward through the text of the program.
                // Note that this requires that all the basic flow analysis visitors handle their constructs in program text order.
                if (currentLocation.Start <= region.End)
                {
                    throw new ArgumentException();
                }
                break;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Used to keep track of whether we are currently within the region or not.
        /// </summary>
        /// <param name="currentLocation"></param>
        private void NoteLocation(TextSpan currentLocation)
        {
            switch (regionPlace)
            {
                case RegionPlace.before:
                    if (currentLocation.Start >= region.Start)
                    {
                        regionPlace = RegionPlace.inside;
                        EnterRegion();
                        goto case RegionPlace.inside;
                    }

                    break;

                case RegionPlace.inside:
                    if (currentLocation.Start > region.End)
                    {
                        regionPlace = RegionPlace.after;
                        LeaveRegion();
                        goto case RegionPlace.after;
                    }
                    else
                    {
                        // we have a location that spans inside and outside.
                        // probably the region is a subexpression and we are looking
                        // at an enclosing expression.  We depend on the positions coming from the
                        // subexpressions to properly compute the before/inside/after.
                    }

                    break;

                case RegionPlace.after:
                    // Should move monotonically forward through the text of the program.
                    // Note that this requires that all the basic flow analysis visitors handle their constructs in program text order.
                    if (currentLocation.Start <= region.End)
                        throw new ArgumentException();
                    break;
            }
        }
 /// <summary>
 /// To scan the whole body, we start outside (before) the region.
 /// </summary>
 protected override void Scan()
 {
     regionPlace = RegionPlace.before;
     base.Scan();
 }
Beispiel #5
0
        protected override void Assign(BoundNode node, BoundExpression value, bool assigned = true)
        {
            switch (node.Kind)
            {
                case BoundKind.LocalDeclaration:
                    var decl = node.Syntax as VariableDeclaratorSyntax;
                    if (this.regionPlace == RegionPlace.inside && decl != null && decl.Identifier.Span.End < region.Start)
                    {
                        this.regionPlace = RegionPlace.after;
                        LeaveRegion();
                    }

                    break;

                case BoundKind.Local:
                case BoundKind.Parameter:
                case BoundKind.ThisReference:
                    if (this.regionPlace == RegionPlace.inside && node.Syntax.Span.End < region.Start)
                    {
                        this.regionPlace = RegionPlace.after;
                        LeaveRegion();
                    }

                    break;
            }

            base.Assign(node, value, assigned);
        }
Beispiel #6
0
 /// <summary>
 /// To scan the whole body, we start outside (before) the region.
 /// </summary>
 protected override void Scan()
 {
     regionPlace = RegionPlace.before;
     base.Scan();
 }