- }
- catch (COMException) {
- if ((RootContext.StrongNameKeyFile == null) || (!RootContext.StrongNameDelaySign))
- throw;
-
- // FIXME: it seems Microsoft AssemblyBuilder doesn't like to delay sign assemblies
- Report.Error (1548, "Couldn't delay-sign the assembly with the '" +
- RootContext.StrongNameKeyFile +
- "', Use MCS with the Mono runtime or CSC to compile this assembly.");
- }
- catch (System.IO.IOException io) {
- Report.Error (16, "Could not write to file `"+name+"', cause: " + io.Message);
- return;
- }
- catch (System.UnauthorizedAccessException ua) {
- Report.Error (16, "Could not write to file `"+name+"', cause: " + ua.Message);
- return;
- }
- catch (System.NotImplementedException nie) {
- Report.RuntimeMissingSupport (Location.Null, nie.Message);
- return;
- }
-
- //
- // Write debuger symbol file
- //
- if (saveDebugInfo)
- SymbolWriter.WriteSymbolFile ();
- }
- }
-
-
- /// <summary>
- /// An interface to hold all the information needed in the resolving phase.
- /// </summary>
- public interface IMemberContext
- {
- //
- // A scope type context, it can be inflated for generic types
- //
- Type CurrentType { get; }
-
- //
- // A scope type parameters either VAR or MVAR
- //
- TypeParameter[] CurrentTypeParameters { get; }
-
- //
- // A type definition of the type context. For partial types definition use
- // CurrentTypeDefinition.PartialContainer otherwise the context is local
- //
- // TODO: CurrentType.Definition
- //
- TypeContainer CurrentTypeDefinition { get; }
-
- bool IsInObsoleteScope { get; }
- bool IsInUnsafeScope { get; }
- bool IsStatic { get; }
-
- ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc);
- FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104);
- FullNamedExpression LookupNamespaceAlias (string name);
- }
-
- //
- // Block or statement resolving context
- //
- public class BlockContext : ResolveContext
- {
- FlowBranching current_flow_branching;
-
- public TypeInferenceContext ReturnTypeInference;
-
- public BlockContext (IMemberContext mc, ExplicitBlock block, Type returnType)
- : base (mc)
- {
- if (returnType == null)
- throw new ArgumentNullException ("returnType");
-
- this.return_type = returnType;
-
- // TODO: check for null value
- CurrentBlock = block;
- }
-
- public override FlowBranching CurrentBranching {
- get { return current_flow_branching; }
- }
-
- // <summary>
- // Starts a new code branching. This inherits the state of all local
- // variables and parameters from the current branching.
- // </summary>
- public FlowBranching StartFlowBranching (FlowBranching.BranchingType type, Location loc)
- {
- current_flow_branching = FlowBranching.CreateBranching (CurrentBranching, type, null, loc);
- return current_flow_branching;
- }
-
- // <summary>
- // Starts a new code branching for block `block'.
- // </summary>
- public FlowBranching StartFlowBranching (Block block)
- {
- Set (Options.DoFlowAnalysis);
-
- current_flow_branching = FlowBranching.CreateBranching (
- CurrentBranching, FlowBranching.BranchingType.Block, block, block.StartLocation);
- return current_flow_branching;
- }
-
- public FlowBranchingTryCatch StartFlowBranching (TryCatch stmt)
- {
- FlowBranchingTryCatch branching = new FlowBranchingTryCatch (CurrentBranching, stmt);
- current_flow_branching = branching;
- return branching;
- }
-
- public FlowBranchingException StartFlowBranching (ExceptionStatement stmt)
- {
- FlowBranchingException branching = new FlowBranchingException (CurrentBranching, stmt);
- current_flow_branching = branching;
- return branching;
- }
-
- public FlowBranchingLabeled StartFlowBranching (LabeledStatement stmt)
- {
- FlowBranchingLabeled branching = new FlowBranchingLabeled (CurrentBranching, stmt);
- current_flow_branching = branching;
- return branching;
- }
-
- public FlowBranchingIterator StartFlowBranching (Iterator iterator)
- {
- FlowBranchingIterator branching = new FlowBranchingIterator (CurrentBranching, iterator);
- current_flow_branching = branching;
- return branching;
- }
-
- public FlowBranchingToplevel StartFlowBranching (ToplevelBlock stmt, FlowBranching parent)
- {
- FlowBranchingToplevel branching = new FlowBranchingToplevel (parent, stmt);
- current_flow_branching = branching;
- return branching;
- }
-
- // <summary>
- // Ends a code branching. Merges the state of locals and parameters
- // from all the children of the ending branching.
- // </summary>
- public bool EndFlowBranching ()
- {
- FlowBranching old = current_flow_branching;
- current_flow_branching = current_flow_branching.Parent;
-
- FlowBranching.UsageVector vector = current_flow_branching.MergeChild (old);
- return vector.IsUnreachable;
- }
-
- // <summary>
- // Kills the current code branching. This throws away any changed state
- // information and should only be used in case of an error.
- // </summary>
- // FIXME: this is evil
- public void KillFlowBranching ()
- {
- current_flow_branching = current_flow_branching.Parent;
- }
-
- //
- // This method is used during the Resolution phase to flag the
- // need to define the ReturnLabel
- //
- public void NeedReturnLabel ()
- {
- if (!HasReturnLabel)
- HasReturnLabel = true;
- }
- }