Example #1
0
        public void FlowAnalysis(FlowAnalysisContext fc)
        {
            bool has_out = false;

            foreach (var arg in args)
            {
                if (arg.ArgType == Argument.AType.Out)
                {
                    has_out = true;
                    continue;
                }

                arg.FlowAnalysis(fc);
            }

            if (!has_out)
            {
                return;
            }

            foreach (var arg in args)
            {
                if (arg.ArgType != Argument.AType.Out)
                {
                    continue;
                }

                arg.FlowAnalysis(fc);
            }
        }
Example #2
0
        public void FlowAnalysis(FlowAnalysisContext fc)
        {
            if (ArgType == AType.Out)
            {
                var vr = Expr as VariableReference;
                if (vr != null)
                {
                    if (vr.VariableInfo != null)
                    {
                        fc.SetVariableAssigned(vr.VariableInfo);
                    }

                    return;
                }

                var fe = Expr as FieldExpr;
                if (fe != null)
                {
                    fe.SetFieldAssigned(fc);
                    return;
                }

                return;
            }

            Expr.FlowAnalysis(fc);
        }
Example #3
0
 public override void FlowAnalysis(FlowAnalysisContext fc)
 {
     foreach (var expr in targetExprs)
     {
         expr.FlowAnalysis(fc);
     }
 }
Example #4
0
        // <summary>
        //   A struct's constructor must always assign all fields.
        //   This method checks whether it actually does so.
        // </summary>
        public bool IsFullyInitialized(FlowAnalysisContext fc, VariableInfo vi, Location loc)
        {
            if (struct_info == null)
            {
                return(true);
            }

            bool ok = true;

            for (int i = 0; i < struct_info.Count; i++)
            {
                var field = struct_info.Fields[i];

                if (!fc.IsStructFieldDefinitelyAssigned(vi, field.Name))
                {
                    if (field.MemberDefinition is Property.BackingField)
                    {
                        fc.Report.Error(843, loc,
                                        "An automatically implemented property `{0}' must be fully assigned before control leaves the constructor. Consider calling the default struct contructor from a constructor initializer",
                                        field.GetSignatureForError());
                    }
                    else
                    {
                        fc.Report.Error(171, loc,
                                        "Field `{0}' must be fully assigned before control leaves the constructor",
                                        field.GetSignatureForError());
                    }
                    ok = false;
                }
            }

            return(ok);
        }
Example #5
0
        public override void FlowAnalysis(FlowAnalysisContext fc)
        {
            base.FlowAnalysis(fc);

            var vr = target as VariableReference;

            if (vr != null)
            {
                if (vr.VariableInfo != null)
                {
                    fc.SetVariableAssigned(vr.VariableInfo);
                }

                return;
            }

            var fe = target as FieldExpr;

            if (fe != null)
            {
                fe.SetFieldAssigned(fc);
                return;
            }

            var pe = target as PropertyExpr;

            if (pe != null)
            {
                pe.SetBackingFieldAssigned(fc);
                return;
            }
        }
Example #6
0
 public override void FlowAnalysis(FlowAnalysisContext fc)
 {
     InstanceExpr.FlowAnalysis(fc);
     if (arguments != null)
     {
         arguments.FlowAnalysis(fc);
     }
 }
Example #7
0
        protected override bool DoFlowAnalysis(FlowAnalysisContext fc)
        {
            expr.FlowAnalysis(fc);

            RegisterResumePoint();

            return(false);
        }
Example #8
0
        public override void FlowAnalysis(FlowAnalysisContext fc)
        {
            source.FlowAnalysis(fc);

            if (target is ArrayAccess || target is IndexerExpr || target is PropertyExpr)
            {
                target.FlowAnalysis(fc);
            }
        }
Example #9
0
        public override void FlowAnalysis(FlowAnalysisContext fc)
        {
            base.FlowAnalysis(fc);
            method_group.FlowAnalysis(fc);

            if (conditional_access_receiver)
            {
                fc.ConditionalAccessEnd();
            }
        }
Example #10
0
        public override void FlowAnalysis(FlowAnalysisContext fc)
        {
            var da = conditional_access_receiver ? fc.BranchDefiniteAssignment() : null;

            base.FlowAnalysis(fc);
            method_group.FlowAnalysis(fc);

            if (conditional_access_receiver)
            {
                fc.DefiniteAssignment = da;
            }
        }
Example #11
0
        public void SetGeneratedFieldAssigned(FlowAnalysisContext fc)
        {
            if (variablesToInfer == null)
            {
                return;
            }

            foreach (var lv in variablesToInfer)
            {
                fc.SetVariableAssigned(lv.VariableInfo);
            }
        }
Example #12
0
            public override void FlowAnalysis(FlowAnalysisContext fc, List <MovableArgument> movable = null)
            {
                foreach (var arg in ordered)
                {
                    if (arg.ArgType != Argument.AType.Out)
                    {
                        arg.FlowAnalysis(fc);
                    }
                }

                base.FlowAnalysis(fc, ordered);
            }
Example #13
0
        protected override bool DoFlowAnalysis(FlowAnalysisContext fc)
        {
            base.DoFlowAnalysis(fc);

            var init   = (AsyncInitializer)Expr;
            var res    = !init.Block.HasReachableClosingBrace;
            var storey = (AsyncTaskStorey)init.Storey;

            if (storey.ReturnType.IsGenericTask)
            {
                return(res);
            }

            return(true);
        }
Example #14
0
        public override void FlowAnalysis(FlowAnalysisContext fc)
        {
            source.FlowAnalysis(fc);

            if (target is ArrayAccess || target is IndexerExpr)
            {
                target.FlowAnalysis(fc);
                return;
            }

            var pe = target as PropertyExpr;

            if (pe != null && !pe.IsAutoPropertyAccess)
            {
                target.FlowAnalysis(fc);
            }
        }
Example #15
0
        public virtual void FlowAnalysis(FlowAnalysisContext fc, List <MovableArgument> movable = null)
        {
            bool has_out = false;

            foreach (var arg in args)
            {
                if (arg.ArgType == Argument.AType.Out)
                {
                    has_out = true;
                    continue;
                }

                if (movable == null)
                {
                    arg.FlowAnalysis(fc);
                    continue;
                }

                var ma = arg as MovableArgument;
                if (ma != null && !movable.Contains(ma))
                {
                    arg.FlowAnalysis(fc);
                }
            }

            if (!has_out)
            {
                return;
            }

            foreach (var arg in args)
            {
                if (arg.ArgType != Argument.AType.Out)
                {
                    continue;
                }

                arg.FlowAnalysis(fc);
            }
        }
Example #16
0
 public override void FlowAnalysis(FlowAnalysisContext fc)
 {
     invoke.FlowAnalysis(fc);
 }
Example #17
0
 public bool IsFullyInitialized(FlowAnalysisContext fc, Location loc)
 {
     return(TypeInfo.IsFullyInitialized(fc, this, loc));
 }
Example #18
0
 public override void FlowAnalysis(FlowAnalysisContext fc)
 {
     arguments.FlowAnalysis(fc);
 }
Example #19
0
 public override void FlowAnalysis(FlowAnalysisContext fc)
 {
     source.FlowAnalysis(fc);
     ((FieldExpr)target).SetFieldAssigned(fc);
 }
Example #20
0
			public override void FlowAnalysis (FlowAnalysisContext fc, List<MovableArgument> movable = null)
			{
				foreach (var arg in ordered) {
					if (arg.ArgType != Argument.AType.Out)
						arg.FlowAnalysis (fc);
				}

				base.FlowAnalysis (fc, ordered);
			}
Example #21
0
		public void FlowAnalysis (FlowAnalysisContext fc)
		{
			if (ArgType == AType.Out) {
				var vr = Expr as VariableReference;
				if (vr != null) {
					if (vr.VariableInfo != null)
						fc.SetVariableAssigned (vr.VariableInfo);

					return;
				}

				var fe = Expr as FieldExpr;
				if (fe != null) {
					fe.SetFieldAssigned (fc);
					return;
				}

				return;
			}

			Expr.FlowAnalysis (fc);
		}
Example #22
0
File: assign.cs Project: dyxu/vimrc
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			base.FlowAnalysis (fc);

			var vr = target as VariableReference;
			if (vr != null) {
				if (vr.VariableInfo != null)
					fc.SetVariableAssigned (vr.VariableInfo);

				return;
			}

			var fe = target as FieldExpr;
			if (fe != null) {
				fe.SetFieldAssigned (fc);
				return;
			}
		}
Example #23
0
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			source.FlowAnalysis (fc);
			((FieldExpr) target).SetFieldAssigned (fc);
		}
Example #24
0
 public override void FlowAnalysis(FlowAnalysisContext fc)
 {
     base.FlowAnalysis(fc);
     method_group.FlowAnalysis(fc);
 }
Example #25
0
 protected override bool DoFlowAnalysis(FlowAnalysisContext fc)
 {
     return(true);
 }
Example #26
0
 protected override bool DoFlowAnalysis(FlowAnalysisContext fc)
 {
     throw new NotImplementedException();
 }
Example #27
0
		public bool IsFullyInitialized (FlowAnalysisContext fc, Location loc)
		{
			return TypeInfo.IsFullyInitialized (fc, this, loc);
		}
Example #28
0
		// <summary>
		//   A struct's constructor must always assign all fields.
		//   This method checks whether it actually does so.
		// </summary>
		public bool IsFullyInitialized (FlowAnalysisContext fc, VariableInfo vi, Location loc)
		{
			if (struct_info == null)
				return true;

			bool ok = true;
			for (int i = 0; i < struct_info.Count; i++) {
				var field = struct_info.Fields[i];

				if (!fc.IsStructFieldDefinitelyAssigned (vi, field.Name)) {
					var bf = field.MemberDefinition as Property.BackingFieldDeclaration;
					if (bf != null) {
						if (bf.Initializer != null)
							continue;

						fc.Report.Error (843, loc,
							"An automatically implemented property `{0}' must be fully assigned before control leaves the constructor. Consider calling the default struct contructor from a constructor initializer",
							field.GetSignatureForError ());

						ok = false;
						continue;
					}

					fc.Report.Error (171, loc,
						"Field `{0}' must be fully assigned before control leaves the constructor",
						field.GetSignatureForError ());
					ok = false;
				}
			}

			return ok;
		}
Example #29
0
		public void FlowAnalysis (FlowAnalysisContext fc)
		{
			bool has_out = false;
			foreach (var arg in args) {
				if (arg.ArgType == Argument.AType.Out) {
					has_out = true;
					continue;
				}

				arg.FlowAnalysis (fc);
			}

			if (!has_out)
				return;

			foreach (var arg in args) {
				if (arg.ArgType != Argument.AType.Out)
					continue;

				arg.FlowAnalysis (fc);
			}
		}
Example #30
0
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			base.FlowAnalysis (fc);
			method_group.FlowAnalysis (fc);

			if (conditional_access_receiver)
				fc.ConditionalAccessEnd ();
		}
Example #31
0
			protected override bool DoFlowAnalysis (FlowAnalysisContext fc)
			{
				return false;
			}
Example #32
0
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			InstanceExpr.FlowAnalysis (fc);
			if (arguments != null)
				arguments.FlowAnalysis (fc);
		}
Example #33
0
 public override void FlowAnalysis(FlowAnalysisContext fc)
 {
     target.FlowAnalysis(fc);
     source.FlowAnalysis(fc);
 }
Example #34
0
		public virtual void FlowAnalysis (FlowAnalysisContext fc, List<MovableArgument> movable = null)
		{
			bool has_out = false;
			foreach (var arg in args) {
				if (arg.ArgType == Argument.AType.Out) {
					has_out = true;
					continue;
				}

				if (movable == null) {
					arg.FlowAnalysis (fc);
					continue;
				}

				var ma = arg as MovableArgument;
				if (ma != null && !movable.Contains (ma))
					arg.FlowAnalysis (fc);
			}

			if (!has_out)
				return;

			foreach (var arg in args) {
				if (arg.ArgType != Argument.AType.Out)
					continue;

				arg.FlowAnalysis (fc);
			}
		}
Example #35
0
		public void FlowAnalysis (FlowAnalysisContext fc)
		{
			foreach (var arg in args)
				arg.FlowAnalysis (fc);
		}
Example #36
0
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			// We are reachable, mark block body reachable too
			MarkReachable (new Reachability ());

			CheckReachableExit (fc.Report);

			var das = fc.BranchDefiniteAssignment ();
			var prev_pb = fc.ParametersBlock;
			fc.ParametersBlock = Block;
			var da_ontrue = fc.DefiniteAssignmentOnTrue;
			var da_onfalse = fc.DefiniteAssignmentOnFalse;

			block.FlowAnalysis (fc);

			fc.ParametersBlock = prev_pb;
			fc.DefiniteAssignment = das;
			fc.DefiniteAssignmentOnTrue = da_ontrue;
			fc.DefiniteAssignmentOnFalse = da_onfalse;
		}
Example #37
0
		public override void FlowAnalysis (FlowAnalysisContext fc) {
			base.FlowAnalysis (fc);
			method_group.FlowAnalysis (fc);
		}
Example #38
0
File: assign.cs Project: dyxu/vimrc
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			source.FlowAnalysis (fc);

			if (target is ArrayAccess || target is IndexerExpr || target is PropertyExpr)
				target.FlowAnalysis (fc);
		}
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			source.FlowAnalysis (fc);

			if (target is ArrayAccess || target is IndexerExpr) {
				target.FlowAnalysis (fc);
				return;
			}

			var pe = target as PropertyExpr;
			if (pe != null && !pe.IsAutoPropertyAccess)
				target.FlowAnalysis (fc);
		}
Example #40
0
File: assign.cs Project: dyxu/vimrc
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			target.FlowAnalysis (fc);
			source.FlowAnalysis (fc);
		}
Example #41
0
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			side_effect.FlowAnalysis (fc);
		}
Example #42
0
        public override void FlowAnalysis(FlowAnalysisContext fc)
        {
            stmt.Expr.FlowAnalysis(fc);

            stmt.RegisterResumePoint();
        }
Example #43
0
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			arguments.FlowAnalysis (fc);
		}
Example #44
0
 protected override bool DoFlowAnalysis(FlowAnalysisContext fc)
 {
     return(state_machine.ReturnType.Kind != MemberKind.Void);
 }
Example #45
0
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			invoke.FlowAnalysis (fc);
		}
Example #46
0
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			if (argument_list != null)
				argument_list.FlowAnalysis (fc);
		}
Example #47
0
		public override void FlowAnalysis (FlowAnalysisContext fc)
		{
			var da = conditional_access_receiver ? fc.BranchDefiniteAssignment () : null;

			base.FlowAnalysis (fc);
			method_group.FlowAnalysis (fc);

			if (conditional_access_receiver)
				fc.DefiniteAssignment = da;
		}