//
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Reflection.Emit;
namespace Mono.CSharp
//
// A scope type context, it can be inflated for generic types
//
- Type CurrentType { get; }
+ TypeSpec 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
+ // A member definition of the context. For partial types definition use
// CurrentTypeDefinition.PartialContainer otherwise the context is local
//
- // TODO: CurrentType.Definition
- //
- TypeContainer CurrentTypeDefinition { get; }
+ MemberCore CurrentMemberDefinition { get; }
bool IsObsolete { get; }
bool IsUnsafe { get; }
bool IsStatic { get; }
+ bool HasUnresolvedConstraints { get; }
string GetSignatureForError ();
- ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc);
- FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104);
+ ExtensionMethodGroupExpr LookupExtensionMethod (TypeSpec extensionType, string name, int arity, Location loc);
+ FullNamedExpression LookupNamespaceOrType (string name, int arity, Location loc, bool ignore_cs0104);
FullNamedExpression LookupNamespaceAlias (string name);
CompilerContext Compiler { get; }
public TypeInferenceContext ReturnTypeInference;
- Type return_type;
+ TypeSpec return_type;
/// <summary>
/// The location where return has to jump to return the
/// </summary>
public bool HasReturnLabel;
- public BlockContext (IMemberContext mc, ExplicitBlock block, Type returnType)
+ public BlockContext (IMemberContext mc, ExplicitBlock block, TypeSpec returnType)
: base (mc)
{
if (returnType == null)
HasReturnLabel = true;
}
- public Type ReturnType {
+ public TypeSpec ReturnType {
get { return return_type; }
}
}
get { return CurrentAnonymousMethod as Iterator; }
}
- public Type CurrentType {
+ public TypeSpec CurrentType {
get { return MemberContext.CurrentType; }
}
get { return MemberContext.CurrentTypeParameters; }
}
- public TypeContainer CurrentTypeDefinition {
- get { return MemberContext.CurrentTypeDefinition; }
+ public MemberCore CurrentMemberDefinition {
+ get { return MemberContext.CurrentMemberDefinition; }
}
public bool ConstantCheckState {
get { return (flags & Options.DoFlowAnalysis) != 0; }
}
+ public bool HasUnresolvedConstraints {
+ get { return false; }
+ }
+
public bool IsInProbingMode {
get { return (flags & Options.ProbingMode) != 0; }
}
get { return HasSet (Options.UnsafeScope) || MemberContext.IsUnsafe; }
}
- public ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Location loc)
+ public ExtensionMethodGroupExpr LookupExtensionMethod (TypeSpec extensionType, string name, int arity, Location loc)
{
- return MemberContext.LookupExtensionMethod (extensionType, name, loc);
+ return MemberContext.LookupExtensionMethod (extensionType, name, arity, loc);
}
- public FullNamedExpression LookupNamespaceOrType (string name, Location loc, bool ignore_cs0104)
+ public FullNamedExpression LookupNamespaceOrType (string name, int arity, Location loc, bool ignore_cs0104)
{
- return MemberContext.LookupNamespaceOrType (name, loc, ignore_cs0104);
+ return MemberContext.LookupNamespaceOrType (name, arity, loc, ignore_cs0104);
}
public FullNamedExpression LookupNamespaceAlias (string name)
//
public class CloneContext
{
- Hashtable block_map = new Hashtable ();
- Hashtable variable_map;
+ Dictionary<Block, Block> block_map = new Dictionary<Block, Block> ();
+ Dictionary<LocalInfo, LocalInfo> variable_map;
public void AddBlockMap (Block from, Block to)
{
- if (block_map.Contains (from))
+ if (block_map.ContainsKey (from))
return;
block_map[from] = to;
}
public Block LookupBlock (Block from)
{
- Block result = (Block) block_map[from];
-
- if (result == null) {
+ Block result;
+ if (!block_map.TryGetValue (from, out result)) {
result = (Block) from.Clone (this);
- block_map[from] = result;
+ block_map [from] = result;
}
return result;
///
public Block RemapBlockCopy (Block from)
{
- Block mapped_to = (Block) block_map[from];
- if (mapped_to == null)
+ Block mapped_to;
+ if (!block_map.TryGetValue (from, out mapped_to))
return from;
return mapped_to;
public void AddVariableMap (LocalInfo from, LocalInfo to)
{
if (variable_map == null)
- variable_map = new Hashtable ();
-
- if (variable_map.Contains (from))
+ variable_map = new Dictionary<LocalInfo, LocalInfo> ();
+ else if (variable_map.ContainsKey (from))
return;
+
variable_map[from] = to;
}
public LocalInfo LookupVariable (LocalInfo from)
{
- LocalInfo result = (LocalInfo) variable_map[from];
-
- if (result == null)
+ try {
+ return variable_map[from];
+ } catch (KeyNotFoundException) {
throw new Exception ("LookupVariable: looking up a variable that has not been registered yet");
-
- return result;
+ }
}
}