+ protected TypeParameterMutator mutator;
+
+ public HoistedStoreyClass (TypeContainer parent, MemberName name, TypeParameter[] tparams, Modifiers mod)
+ : base (parent, name, mod | Modifiers.PRIVATE)
+ {
+ if (tparams != null) {
+ type_params = new TypeParameter[tparams.Length];
+ var src = new TypeParameterSpec[tparams.Length];
+ var dst = new TypeParameterSpec[tparams.Length];
+
+ for (int i = 0; i < type_params.Length; ++i) {
+ type_params[i] = tparams[i].CreateHoistedCopy (this, spec);
+
+ src[i] = tparams[i].Type;
+ dst[i] = type_params[i].Type;
+ }
+
+ // A copy is not enough, inflate any type parameter constraints
+ // using a new type parameters
+ var inflator = new TypeParameterInflator (this, null, src, dst);
+ for (int i = 0; i < type_params.Length; ++i) {
+ src[i].InflateConstraints (inflator, dst[i]);
+ }
+
+ mutator = new TypeParameterMutator (tparams, type_params);
+ }
+ }
+
+ #region Properties
+
+ public TypeParameterMutator Mutator {
+ get {
+ return mutator;
+ }
+ set {
+ mutator = value;
+ }
+ }
+
+ #endregion
+
+ public HoistedStoreyClass GetGenericStorey ()
+ {
+ DeclSpace storey = this;
+ while (storey != null && storey.CurrentTypeParameters == null)
+ storey = storey.Parent;
+
+ return storey as HoistedStoreyClass;
+ }
+ }
+
+
+ //
+ // Anonymous method storey is created when an anonymous method uses
+ // variable or parameter from outer scope. They are then hoisted to
+ // anonymous method storey (captured)
+ //
+ public class AnonymousMethodStorey : HoistedStoreyClass
+ {
+ struct StoreyFieldPair
+ {
+ public readonly AnonymousMethodStorey Storey;
+ public readonly Field Field;
+
+ public StoreyFieldPair (AnonymousMethodStorey storey, Field field)
+ {
+ this.Storey = storey;
+ this.Field = field;
+ }
+ }
+