+ get { return capture_context; }
+ }
+
+ public FlowBranching TopLevelBranching {
+ get { return top_level_branching; }
+ }
+
+ //
+ // This is used if anonymous methods are used inside an iterator
+ // (see 2test-22.cs for an example).
+ //
+ // The AnonymousMethod is created while parsing - at a time when we don't
+ // know yet that we're inside an iterator, so it's `Container' is initially
+ // null. Later on, when resolving the iterator, we need to move the
+ // anonymous method into that iterator.
+ //
+ public void ReParent (ToplevelBlock new_parent, AnonymousContainer new_host)
+ {
+ foreach (ToplevelBlock block in children) {
+ if (block.CaptureContext == null)
+ continue;
+
+ block.container = new_parent;
+ block.CaptureContext.ReParent (new_parent, new_host);
+ }
+ }
+
+ //
+ // Returns a `ParameterReference' for the given name, or null if there
+ // is no such parameter
+ //
+ public ParameterReference GetParameterReference (string name, Location loc)
+ {
+ Parameter par;
+ int idx;
+
+ for (ToplevelBlock t = this; t != null; t = t.Container) {
+ Parameters pars = t.Parameters;
+ par = pars.GetParameterByName (name, out idx);
+ if (par != null)
+ return new ParameterReference (pars, this, idx, name, loc);
+ }
+ return null;
+ }
+
+ //
+ // Whether the parameter named `name' is local to this block,
+ // or false, if the parameter belongs to an encompassing block.
+ //
+ public bool IsLocalParameter (string name)
+ {
+ return Parameters.GetParameterByName (name) != null;
+ }
+
+ //
+ // Whether the `name' is a parameter reference
+ //
+ public bool IsParameterReference (string name)
+ {
+ for (ToplevelBlock t = this; t != null; t = t.Container) {
+ if (t.IsLocalParameter (name))
+ return true;
+ }
+ return false;
+ }
+
+ LocalInfo this_variable = null;
+
+ // <summary>
+ // Returns the "this" instance variable of this block.
+ // See AddThisVariable() for more information.
+ // </summary>
+ public LocalInfo ThisVariable {
+ get { return this_variable; }
+ }
+
+
+ // <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 LocalInfo AddThisVariable (TypeContainer tc, Location l)
+ {
+ if (this_variable == null) {
+ this_variable = new LocalInfo (tc, this, l);
+ this_variable.Used = true;
+ this_variable.IsThis = true;
+
+ Variables.Add ("this", this_variable);