+
+ 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;
+ }
+
+ public bool ResolveMeta (EmitContext ec, InternalParameters ip)
+ {
+ int errors = Report.Errors;
+
+ if (top_level_branching != null)
+ return true;
+
+ ResolveMeta (this, ec, ip);
+
+ top_level_branching = ec.StartFlowBranching (this);
+
+ return Report.Errors == errors;
+ }