+ public bool CheckError136_InParents (string name, Location loc)
+ {
+ for (Block b = Parent; b != null; b = b.Parent) {
+ if (!b.DoCheckError136 (name, "parent or current", loc))
+ return false;
+ }
+
+ for (Block b = Toplevel.ContainerBlock; b != null; b = b.Toplevel.ContainerBlock) {
+ if (!b.CheckError136_InParents (name, loc))
+ return false;
+ }
+
+ return true;
+ }
+
+ public bool CheckError136_InChildren (string name, Location loc)
+ {
+ if (!DoCheckError136_InChildren (name, loc))
+ return false;
+
+ Block b = this;
+ while (b.Implicit) {
+ if (!b.Parent.DoCheckError136_InChildren (name, loc))
+ return false;
+ b = b.Parent;
+ }
+
+ return true;
+ }
+
+ protected bool DoCheckError136_InChildren (string name, Location loc)
+ {
+ if (!DoCheckError136 (name, "child", loc))
+ return false;
+
+ if (AnonymousChildren != null) {
+ foreach (ToplevelBlock child in AnonymousChildren) {
+ if (!child.DoCheckError136_InChildren (name, loc))
+ return false;
+ }
+ }
+
+ if (children != null) {
+ foreach (Block child in children) {
+ if (!child.DoCheckError136_InChildren (name, loc))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public bool CheckError136 (string name, string scope, bool check_parents,
+ bool check_children, Location loc)
+ {
+ if (!DoCheckError136 (name, scope, loc))
+ return false;
+
+ if (check_parents) {
+ if (!CheckError136_InParents (name, loc))
+ return false;
+ }
+
+ if (check_children) {
+ if (!CheckError136_InChildren (name, loc))
+ return false;
+ }
+
+ for (Block c = Toplevel.ContainerBlock; c != null; c = c.Toplevel.ContainerBlock) {
+ if (!c.DoCheckError136 (name, "parent or current", loc))
+ return false;
+ }
+
+ return true;
+ }
+
+ protected bool DoCheckError136 (string name, string scope, Location loc)
+ {
+ LocalInfo vi = GetKnownVariableInfo (name, false);
+ if (vi != null) {
+ Report.SymbolRelatedToPreviousError (vi.Location, name);
+ Error_AlreadyDeclared (loc, name, scope != null ? scope : "child");
+ return false;
+ }
+
+ int idx;
+ Parameter p = Toplevel.Parameters.GetParameterByName (name, out idx);
+ if (p != null) {
+ Report.SymbolRelatedToPreviousError (p.Location, name);
+ Error_AlreadyDeclared (
+ loc, name, scope != null ? scope : "method argument");
+ return false;
+ }
+
+ return true;
+ }
+