Mono.CSharp.LocalVariable.PrepareForFlowAnalysis C# (CSharp) Method

PrepareForFlowAnalysis() public method

public PrepareForFlowAnalysis ( BlockContext bc ) : void
bc BlockContext
return void
		public void PrepareForFlowAnalysis (BlockContext bc)
		{
			//
			// No need for definitely assigned check for these guys
			//
			if ((flags & (Flags.Constant | Flags.ReadonlyMask | Flags.CompilerGenerated)) != 0)
				return;

			VariableInfo = new VariableInfo (this, bc.FlowOffset);
			bc.FlowOffset += VariableInfo.Length;
		}

Usage Example

Example #1
0
		// <summary>
		//   This is used by non-static `struct' constructors which do not have an
		//   initializer - in this case, the constructor must initialize all of the
		//   struct's fields.  To do this, we add a "this" variable and use the flow
		//   analysis code to ensure that it's been fully initialized before control
		//   leaves the constructor.
		// </summary>
		public LocalVariable AddThisVariable (BlockContext bc, TypeContainer ds, Location l)
		{
			if (this_variable == null) {
				this_variable = new LocalVariable (this, "this", LocalVariable.Flags.IsThis | LocalVariable.Flags.Used, l);
				this_variable.Type = ds.CurrentType;
				this_variable.PrepareForFlowAnalysis (bc);
			}

			return this_variable;
		}