// A member definition of the context. For partial types definition use
// CurrentTypeDefinition.PartialContainer otherwise the context is local
//
+ // TODO: Obsolete it in this context, dynamic context cannot guarantee sensible value
+ //
MemberCore CurrentMemberDefinition { get; }
bool IsObsolete { get; }
string GetSignatureForError ();
- ExtensionMethodGroupExpr LookupExtensionMethod (TypeSpec extensionType, string name, int arity, Location loc);
+ IList<MethodSpec> LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceEntry scope);
FullNamedExpression LookupNamespaceOrType (string name, int arity, Location loc, bool ignore_cs0104);
FullNamedExpression LookupNamespaceAlias (string name);
{
FlowBranching current_flow_branching;
- public TypeInferenceContext ReturnTypeInference;
-
TypeSpec return_type;
/// <summary>
/// </summary>
public bool HasReturnLabel;
+ public int FlowOffset;
+
public BlockContext (IMemberContext mc, ExplicitBlock block, TypeSpec returnType)
: base (mc)
{
CurrentBlock = block;
}
+ public BlockContext (ResolveContext rc, ExplicitBlock block, TypeSpec returnType)
+ : this (rc.MemberContext, block, returnType)
+ {
+ if (rc.IsUnsafe)
+ flags |= ResolveContext.Options.UnsafeScope;
+
+ if (rc.HasSet (ResolveContext.Options.CheckedScope))
+ flags |= ResolveContext.Options.CheckedScope;
+ }
+
public override FlowBranching CurrentBranching {
get { return current_flow_branching; }
}
return branching;
}
- public FlowBranchingIterator StartFlowBranching (Iterator iterator)
+ public FlowBranchingIterator StartFlowBranching (Iterator iterator, FlowBranching parent)
{
- FlowBranchingIterator branching = new FlowBranchingIterator (CurrentBranching, iterator);
+ FlowBranchingIterator branching = new FlowBranchingIterator (parent, iterator);
current_flow_branching = branching;
return branching;
}
- public FlowBranchingToplevel StartFlowBranching (ToplevelBlock stmt, FlowBranching parent)
+ public FlowBranchingToplevel StartFlowBranching (ParametersBlock stmt, FlowBranching parent)
{
FlowBranchingToplevel branching = new FlowBranchingToplevel (parent, stmt);
current_flow_branching = branching;
ConstructorScope = 1 << 11,
+ UsingInitializerScope = 1 << 12,
+
/// <summary>
/// Whether control flow analysis is enabled
/// </summary>
}
}
- Options flags;
+ protected Options flags;
//
// Whether we are inside an anonymous method.
get { return MemberContext.Compiler; }
}
+ public virtual ExplicitBlock ConstructorBlock {
+ get {
+ return CurrentBlock.Explicit;
+ }
+ }
+
public virtual FlowBranching CurrentBranching {
get { return null; }
}
get { return (flags & Options.OmitStructFlowAnalysis) != 0; }
}
- // TODO: Merge with CompilerGeneratedThis
- public Expression GetThis (Location loc)
- {
- This my_this;
- if (CurrentBlock != null)
- my_this = new This (CurrentBlock, loc);
- else
- my_this = new This (loc);
-
- if (!my_this.ResolveBase (this))
- my_this = null;
-
- return my_this;
- }
-
- public bool MustCaptureVariable (LocalInfo local)
+ public bool MustCaptureVariable (INamedBlockVariable local)
{
if (CurrentAnonymousMethod == null)
return false;
if (CurrentAnonymousMethod.IsIterator)
return true;
- return local.Block.Toplevel != CurrentBlock.Toplevel;
+ return local.Block.ParametersBlock != CurrentBlock.ParametersBlock.Original;
}
public bool HasSet (Options options)
public bool IsObsolete {
get {
// Disables obsolete checks when probing is on
- return IsInProbingMode || MemberContext.IsObsolete;
+ return MemberContext.IsObsolete;
}
}
get { return HasSet (Options.UnsafeScope) || MemberContext.IsUnsafe; }
}
- public ExtensionMethodGroupExpr LookupExtensionMethod (TypeSpec extensionType, string name, int arity, Location loc)
+ public IList<MethodSpec> LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceEntry scope)
{
- return MemberContext.LookupExtensionMethod (extensionType, name, arity, loc);
+ return MemberContext.LookupExtensionMethod (extensionType, name, arity, ref scope);
}
public FullNamedExpression LookupNamespaceOrType (string name, int arity, Location loc, bool ignore_cs0104)
public class CloneContext
{
Dictionary<Block, Block> block_map = new Dictionary<Block, Block> ();
- Dictionary<LocalInfo, LocalInfo> variable_map;
public void AddBlockMap (Block from, Block to)
{
- if (block_map.ContainsKey (from))
- return;
- block_map[from] = to;
+ block_map.Add (from, to);
}
public Block LookupBlock (Block from)
Block result;
if (!block_map.TryGetValue (from, out result)) {
result = (Block) from.Clone (this);
- block_map [from] = result;
}
return result;
return mapped_to;
}
-
- public void AddVariableMap (LocalInfo from, LocalInfo to)
- {
- if (variable_map == null)
- variable_map = new Dictionary<LocalInfo, LocalInfo> ();
- else if (variable_map.ContainsKey (from))
- return;
-
- variable_map[from] = to;
- }
-
- public LocalInfo LookupVariable (LocalInfo from)
- {
- try {
- return variable_map[from];
- } catch (KeyNotFoundException) {
- throw new Exception ("LookupVariable: looking up a variable that has not been registered yet");
- }
- }
}
//
public class CompilerContext
{
readonly Report report;
+ readonly PredefinedAttributes attributes;
public CompilerContext (Report report)
{
this.report = report;
+
+ this.attributes = new PredefinedAttributes ();
}
+ #region Properties
+
+ // TODO: Obsolete, it has to go
+ public RootNamespace GlobalRootNamespace { get; set; }
+
public bool IsRuntimeBinder { get; set; }
+ public PredefinedAttributes PredefinedAttributes {
+ get {
+ return attributes;
+ }
+ }
+
public Report Report {
- get { return report; }
+ get {
+ return report;
+ }
}
- //public PredefinedAttributes PredefinedAttributes {
- // get { throw new NotImplementedException (); }
- //}
+ #endregion
}
//