public FlowBranchingToplevel StartFlowBranching (ParametersBlock stmt, FlowBranching parent) { FlowBranchingToplevel branching = new FlowBranchingToplevel (parent, stmt); current_flow_branching = branching; return branching; }
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; }
public bool ResolveMeta (EmitContext ec, Parameters ip) { int errors = Report.Errors; int orig_count = parameters.Count; if (top_level_branching != null) return true; if (ip != null) parameters = ip; // Assert: orig_count != parameter.Count => orig_count == 0 if (orig_count != 0 && orig_count != parameters.Count) throw new InternalErrorException ("parameter information mismatch"); int offset = Parent == null ? 0 : Parent.AssignableSlots; for (int i = 0; i < orig_count; ++i) { Parameter.Modifier mod = parameters.FixedParameters [i].ModFlags; if ((mod & Parameter.Modifier.OUT) != Parameter.Modifier.OUT) continue; VariableInfo vi = new VariableInfo (ip, i, offset); parameter_info [i].VariableInfo = vi; offset += vi.Length; } ResolveMeta (ec, offset); top_level_branching = ec.StartFlowBranching (this); return Report.Errors == errors; }
public FlowBranchingToplevel StartFlowBranching (ToplevelBlock stmt) { FlowBranchingToplevel branching = new FlowBranchingToplevel (CurrentBranching, stmt); current_flow_branching = branching; return branching; }