public bool ResolveTopBlock (EmitContext anonymous_method_host, ToplevelBlock block, Parameters ip, IMethodData md, out bool unreachable) { if (resolved) { unreachable = this.unreachable; return true; } current_phase = Phase.Resolving; unreachable = false; if (!loc.IsNull) CurrentFile = loc.File; #if PRODUCTION try { #endif if (!block.ResolveMeta (this, ip)) return false; using (this.With (EmitContext.Flags.DoFlowAnalysis, true)) { FlowBranchingToplevel top_level; if (anonymous_method_host != null) top_level = new FlowBranchingToplevel (anonymous_method_host.CurrentBranching, block); else top_level = block.TopLevelBranching; current_flow_branching = top_level; bool ok = block.Resolve (this); current_flow_branching = null; if (!ok) return false; bool flow_unreachable = top_level.End (); if (flow_unreachable) this.unreachable = unreachable = true; } #if PRODUCTION } catch (Exception e) { Console.WriteLine ("Exception caught by the compiler while compiling:"); Console.WriteLine (" Block that caused the problem begin at: " + loc); if (CurrentBlock != null){ Console.WriteLine (" Block being compiled: [{0},{1}]", CurrentBlock.StartLocation, CurrentBlock.EndLocation); } Console.WriteLine (e.GetType ().FullName + ": " + e.Message); throw; } #endif if (return_type != TypeManager.void_type && !unreachable) { if (CurrentAnonymousMethod == null) { Report.Error (161, md.Location, "`{0}': not all code paths return a value", md.GetSignatureForError ()); return false; } else if (!CurrentAnonymousMethod.IsIterator) { Report.Error (1643, CurrentAnonymousMethod.Location, "Not all code paths return a value in anonymous method of type `{0}'", CurrentAnonymousMethod.GetSignatureForError ()); return false; } } resolved = true; return true; }