Ejemplo n.º 1
0
Archivo: decl.cs Proyecto: Tenere/mono
		public MemberName (MemberName left, MemberName right)
		{
			this.Name = right.Name;
			this.Location = right.Location;
			this.TypeArguments = right.TypeArguments;
			this.Left = left;
		}
Ejemplo n.º 2
0
		public MemberName (MemberName left, MemberName right)
		{
			this.Name = right.Name;
			this.Location = right.Location;
			this.TypeParameters = right.TypeParameters;
			this.Left = left;
		}
Ejemplo n.º 3
0
		public MethodCore (DeclSpace parent, GenericMethod generic,
			FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
			MemberName name, Attributes attrs, ParametersCompiled parameters)
			: base (parent, generic, type, mod, allowed_mod, name, attrs)
		{
			this.parameters = parameters;
		}
Ejemplo n.º 4
0
 public Class(TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs)
     : base(parent, name, attrs, MemberKind.Class)
 {
     var accmods = IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE;
     this.ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod, accmods, Location, Report);
     spec = new TypeSpec (Kind, null, this, null, ModFlags);
 }
Ejemplo n.º 5
0
		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);
			}
		}
Ejemplo n.º 6
0
		private MemberName (MemberName left, string name, bool is_double_colon,
				    TypeArguments args, Location loc)
			: this (left, name, is_double_colon, loc)
		{
			if (args != null && args.Count > 0)
				this.TypeArguments = args;
		}
Ejemplo n.º 7
0
        protected Event(DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
            : base(parent, null, type, mod_flags,
				parent.PartialContainer.Kind == MemberKind.Interface ? AllowedModifiersInterface :
				parent.PartialContainer.Kind == MemberKind.Struct ? AllowedModifiersStruct :
				AllowedModifiersClass,
				name, attrs)
        {
        }
Ejemplo n.º 8
0
 public Enum(TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
     : base(parent, name, attrs, MemberKind.Enum)
 {
     underlying_type_expr = type;
     var accmods = IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE;
     ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod_flags, accmods, Location, Report);
     spec = new EnumSpec (null, this, null, null, ModFlags);
 }
Ejemplo n.º 9
0
		protected FieldBase (DeclSpace parent, FullNamedExpression type, Modifiers mod,
				     Modifiers allowed_mod, MemberName name, Attributes attrs)
			: base (parent, null, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE,
				name, attrs)
		{
			if ((mod & Modifiers.ABSTRACT) != 0)
				Report.Error (681, Location, "The modifier 'abstract' is not valid on fields. Try using a property instead");
		}
Ejemplo n.º 10
0
		private MemberName (MemberName left, string name, bool is_double_colon,
				    Location loc)
		{
			this.Name = name;
			this.Location = loc;
			this.is_double_colon = is_double_colon;
			this.Left = left;
		}
Ejemplo n.º 11
0
        public Class(NamespaceEntry ns, DeclSpace parent, MemberName name, Modifiers mod,
			      Attributes attrs)
            : base(ns, parent, name, attrs, MemberKind.Class)
        {
            var accmods = (Parent == null || Parent.Parent == null) ? Modifiers.INTERNAL : Modifiers.PRIVATE;
            this.ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod, accmods, Location, Report);
            spec = new TypeSpec (Kind, null, this, null, ModFlags);
        }
Ejemplo n.º 12
0
		protected CompilerGeneratedContainer (TypeContainer parent, MemberName name, Modifiers mod, MemberKind kind)
			: base (parent, name, null, kind)
		{
			Debug.Assert ((mod & Modifiers.AccessibilityMask) != 0);

			ModFlags = mod | Modifiers.COMPILER_GENERATED | Modifiers.SEALED;
			spec = new TypeSpec (Kind, null, this, null, ModFlags);
		}
Ejemplo n.º 13
0
Archivo: enum.cs Proyecto: speier/shake
 public Enum(NamespaceEntry ns, DeclSpace parent, TypeExpr type,
     Modifiers mod_flags, MemberName name, Attributes attrs)
     : base(ns, parent, name, attrs, MemberKind.Enum)
 {
     this.base_type = type;
     var accmods = IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE;
     ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod_flags, accmods, Location, Report);
     spec = new EnumSpec (null, this, null, null, ModFlags);
 }
Ejemplo n.º 14
0
		public TypeContainer (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
			: base (parent, name, attrs)
		{
			this.Kind = kind;
			if (name != null)
				this.Basename = name.Basename;

			defined_names = new Dictionary<string, MemberCore> ();
		}
Ejemplo n.º 15
0
		public HoistedStoreyClass (DeclSpace parent, MemberName name, TypeParameter[] tparams, Modifiers mod)
			: base (parent, name, mod | Modifiers.PRIVATE)
		{
			if (tparams != null) {
				type_params = new TypeParameter[tparams.Length];
				for (int i = 0; i < type_params.Length; ++i) {
					type_params[i] = tparams[i].CreateHoistedCopy (this, spec);
				}
			}
		}
Ejemplo n.º 16
0
        public Delegate(TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, ParametersCompiled param_list,
				 Attributes attrs)
            : base(parent, name, attrs, MemberKind.Delegate)
        {
            this.ReturnType = type;
            ModFlags        = ModifiersExtensions.Check (AllowedModifiers, mod_flags,
                               IsTopLevel ? Modifiers.INTERNAL :
                               Modifiers.PRIVATE, name.Location, Report);
            parameters      = param_list;
            spec = new TypeSpec (Kind, null, this, null, ModFlags | Modifiers.SEALED);
        }
Ejemplo n.º 17
0
 		public Delegate (NamespaceEntry ns, DeclSpace parent, FullNamedExpression type,
				 int mod_flags, MemberName name, ParametersCompiled param_list,
				 Attributes attrs)
			: base (ns, parent, name, attrs, Kind.Delegate)

		{
			this.ReturnType = type;
			ModFlags        = Modifiers.Check (AllowedModifiers, mod_flags,
							   IsTopLevel ? Modifiers.INTERNAL :
							   Modifiers.PRIVATE, name.Location, Report);
			Parameters      = param_list;
		}
Ejemplo n.º 18
0
        public Class(NamespaceEntry ns, DeclSpace parent, MemberName name, Modifiers mod,
            Attributes attrs)
            : base(ns, parent, name, attrs, MemberKind.Class)
        {
            var accmods = (Parent == null || Parent.Parent == null) ? Modifiers.INTERNAL : Modifiers.PRIVATE;
            this.ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod, accmods, Location, Report);
            spec = new TypeSpec (Kind, null, this, null, ModFlags);

            if (IsStatic && RootContext.Version == LanguageVersion.ISO_1) {
                Report.FeatureIsNotAvailable (Location, "static classes");
            }
        }
Ejemplo n.º 19
0
		protected CompilerGeneratedClass (DeclSpace parent, GenericMethod generic, MemberName name, int mod)
			: this (parent, name, mod)
		{
			if (generic != null) {
				ArrayList list = new ArrayList ();
				foreach (TypeParameter tparam in generic.TypeParameters) {
					if (tparam.Constraints != null)
						list.Add (tparam.Constraints.Clone ());
				}
				SetParameterInfo (list);
			}
		}
Ejemplo n.º 20
0
			AstType ConvertToType (MemberName memberName)
			{
				AstType result;
				if (memberName.Left != null) {
					result = new MemberType () { MemberName = memberName.Name };
					result.AddChild (ConvertToType (memberName.Left), MemberType.TargetRole);
				} else {
					result = new SimpleType () { Identifier = memberName.Name };
				}
				if (memberName.TypeArguments != null && !memberName.TypeArguments.IsEmpty) {
					foreach (var arg in memberName.TypeArguments.Args) {
						result.AddChild (ConvertToType (arg), AstType.Roles.TypeArgument);
					}
				}
				return result;
			}
Ejemplo n.º 21
0
        /// <remarks>
        ///   If a method in Type `t' (or null to look in all interfaces
        ///   and the base abstract class) with name `Name', return type `ret_type' and
        ///   arguments `args' implements an interface, this method will
        ///   return the MethodInfo that this method implements.
        ///
        ///   If `name' is null, we operate solely on the method's signature.  This is for
        ///   instance used when implementing indexers.
        ///
        ///   The `Operation op' controls whether to lookup, clear the pending bit, or clear
        ///   all the methods with the given signature.
        ///
        ///   The `MethodInfo need_proxy' is used when we're implementing an interface's
        ///   indexer in a class.  If the new indexer's IndexerName does not match the one
        ///   that was used in the interface, then we always need to create a proxy for it.
        ///
        /// </remarks>
        public MethodSpec InterfaceMethod(MemberName name, TypeSpec iType, MethodData method, Operation op, out MethodSpec ambiguousCandidate, ref bool optional)
        {
            ambiguousCandidate = null;

            if (pending_implementations == null)
            {
                return(null);
            }

            TypeSpec           ret_type = method.method.ReturnType;
            ParametersCompiled args     = method.method.ParameterInfo;
            bool       is_indexer       = method.method is Indexer.SetIndexerMethod || method.method is Indexer.GetIndexerMethod;
            MethodSpec m;

            foreach (TypeAndMethods tm in pending_implementations)
            {
                if (!(iType == null || tm.type == iType))
                {
                    continue;
                }

                int method_count = tm.methods.Count;
                for (int i = 0; i < method_count; i++)
                {
                    m = tm.methods [i];

                    if (m == null)
                    {
                        continue;
                    }

                    if (is_indexer)
                    {
                        if (!m.IsAccessor || m.Parameters.IsEmpty)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (name.Name != m.Name)
                        {
                            continue;
                        }

                        if (m.Arity != name.Arity)
                        {
                            continue;
                        }
                    }

                    if (!TypeSpecComparer.Override.IsEqual(m.Parameters, args))
                    {
                        continue;
                    }

                    if (!TypeSpecComparer.Override.IsEqual(m.ReturnType, ret_type))
                    {
                        tm.found[i] = method;
                        continue;
                    }

                    //
                    // `need_proxy' is not null when we're implementing an
                    // interface indexer and this is Clear(One/All) operation.
                    //
                    // If `name' is null, then we do a match solely based on the
                    // signature and not on the name (this is done in the Lookup
                    // for an interface indexer).
                    //
                    if (op != Operation.Lookup)
                    {
                        if (m.IsAccessor != method.method.IsAccessor)
                        {
                            continue;
                        }

                        // If `t != null', then this is an explicitly interface
                        // implementation and we can always clear the method.
                        // `need_proxy' is not null if we're implementing an
                        // interface indexer.  In this case, we need to create
                        // a proxy if the implementation's IndexerName doesn't
                        // match the IndexerName in the interface.
                        if (m.DeclaringType.IsInterface && iType == null && name.Name != m.Name)                                // TODO: This is very expensive comparison
                        {
                            tm.need_proxy[i] = method.method.Spec;
                        }
                        else
                        {
                            tm.methods[i] = null;
                        }
                    }
                    else
                    {
                        tm.found [i] = method;
                        optional     = tm.optional;
                    }

                    if (op == Operation.Lookup && name.ExplicitInterface != null && ambiguousCandidate == null)
                    {
                        ambiguousCandidate = m;
                        continue;
                    }

                    //
                    // Lookups and ClearOne return
                    //
                    if (op != Operation.ClearAll)
                    {
                        return(m);
                    }
                }

                // If a specific type was requested, we can stop now.
                if (tm.type == iType)
                {
                    break;
                }
            }

            m = ambiguousCandidate;
            ambiguousCandidate = null;
            return(m);
        }
Ejemplo n.º 22
0
		public HoistedStoreyClass (TypeDefinition parent, MemberName name, TypeParameters tparams, Modifiers mods, MemberKind kind)
			: base (parent, name, mods | Modifiers.PRIVATE, kind)
		{

			if (tparams != null) {
				var type_params = name.TypeParameters;
				var src = new TypeParameterSpec[tparams.Count];
				var dst = new TypeParameterSpec[tparams.Count];

				for (int i = 0; i < tparams.Count; ++i) {
					type_params[i] = tparams[i].CreateHoistedCopy (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 < tparams.Count; ++i) {
					src[i].InflateConstraints (inflator, dst[i]);
				}

				mutator = new TypeParameterMutator (tparams, type_params);
			}
		}
Ejemplo n.º 23
0
 public GetEnumeratorMethod(IteratorStorey host, FullNamedExpression returnType, MemberName name)
     : base(host, null, returnType, Modifiers.DEBUGGER_HIDDEN, name)
 {
     Block.AddStatement(new GetEnumeratorStatement(host, this));
 }
Ejemplo n.º 24
0
 public Using(Location usingLocation, MemberName nSpace, Location semicolonLocation)
 {
     this.UsingLocation     = usingLocation;
     this.NSpace            = nSpace;
     this.SemicolonLocation = semicolonLocation;
 }
Ejemplo n.º 25
0
        public void DefineIteratorMembers()
        {
            pc_field      = AddCompilerGeneratedField("$PC", TypeManager.system_int32_expr);
            current_field = AddCompilerGeneratedField("$current", iterator_type_expr);

            if (hoisted_params != null)
            {
                //
                // Iterators are independent, each GetEnumerator call has to
                // create same enumerator therefore we have to keep original values
                // around for re-initialization
                //
                // TODO: Do it for assigned/modified parameters only
                //
                hoisted_params_copy = new ArrayList(hoisted_params.Count);
                foreach (HoistedParameter hp in hoisted_params)
                {
                    hoisted_params_copy.Add(new HoistedParameter(hp, "<$>" + hp.Field.Name));
                }
            }

            if (generic_enumerator_type != null)
            {
                Define_Current(true);
            }

            Define_Current(false);
            new DisposeMethod(this);
            Define_Reset();

            if (Iterator.IsEnumerable)
            {
                MemberName name = new MemberName(QualifiedAliasMember.GlobalAlias, "System", null, Location);
                name = new MemberName(name, "Collections", Location);
                name = new MemberName(name, "IEnumerable", Location);
                name = new MemberName(name, "GetEnumerator", Location);

                if (generic_enumerator_type != null)
                {
                    Method get_enumerator = new IteratorMethod(this, enumerator_type, 0, name);

                    name = new MemberName(name.Left.Left, "Generic", Location);
                    name = new MemberName(name, "IEnumerable", generic_args, Location);
                    name = new MemberName(name, "GetEnumerator", Location);
                    Method gget_enumerator = new GetEnumeratorMethod(this, generic_enumerator_type, name);

                    //
                    // Just call generic GetEnumerator implementation
                    //
                    get_enumerator.Block.AddStatement(
                        new Return(new Invocation(new DynamicMethodGroupExpr(gget_enumerator, Location), null), Location));

                    AddMethod(get_enumerator);
                    AddMethod(gget_enumerator);
                }
                else
                {
                    AddMethod(new GetEnumeratorMethod(this, enumerator_type, name));
                }
            }
        }
Ejemplo n.º 26
0
            public IteratorMethod(IteratorStorey host, FullNamedExpression returnType, int mod, MemberName name)
                : base(host, null, returnType, mod | Modifiers.DEBUGGER_HIDDEN | Modifiers.COMPILER_GENERATED,
                       name, ParametersCompiled.EmptyReadOnlyParameters, null)
            {
                this.host = host;

                Block = new ToplevelBlock(Compiler, host.Iterator.Container.Toplevel, ParametersCompiled.EmptyReadOnlyParameters, Location);
            }
Ejemplo n.º 27
0
 protected virtual void SetMemberName(MemberName new_name)
 {
     member_name = new_name;
 }
Ejemplo n.º 28
0
 public MemberName(MemberName left, string name, FullNamedExpression explicitInterface, Location loc)
     : this(left, name, loc)
 {
     this.ExplicitInterface = explicitInterface;
 }
Ejemplo n.º 29
0
 public static GetEnumeratorMethod Create(IteratorStorey host, FullNamedExpression returnType, MemberName name)
 {
     return(Create(host, returnType, name, null));
 }
Ejemplo n.º 30
0
            public static GetEnumeratorMethod Create(IteratorStorey host, FullNamedExpression returnType, MemberName name, Statement statement)
            {
                var m    = new GetEnumeratorMethod(host, returnType, name);
                var stmt = statement ?? new GetEnumeratorStatement(host, m);

                m.block.AddStatement(stmt);
                return(m);
            }
Ejemplo n.º 31
0
 GetEnumeratorMethod(IteratorStorey host, FullNamedExpression returnType, MemberName name)
     : base(host, null, returnType, Modifiers.DEBUGGER_HIDDEN, name, ToplevelBlock.Flags.CompilerGenerated | ToplevelBlock.Flags.NoFlowAnalysis)
 {
 }
Ejemplo n.º 32
0
 public void AddUsing(Location usingLocation, MemberName nspace, Location semicolonLocation)
 {
     curNamespace.Peek().usings.Add(new Using(usingLocation, nspace, semicolonLocation));
 }
Ejemplo n.º 33
0
 public void AddUsingAlias(Location usingLocation, Tokenizer.LocatedToken identifier, Location assignLocation, MemberName nspace, Location semicolonLocation)
 {
     curNamespace.Peek().usings.Add(new AliasUsing(usingLocation, identifier, assignLocation, nspace, semicolonLocation));
 }
Ejemplo n.º 34
0
		//
		// Creates a host for the anonymous method
		//
		AnonymousMethodMethod DoCreateMethodHost (EmitContext ec)
		{
			//
			// Anonymous method body can be converted to
			//
			// 1, an instance method in current scope when only `this' is hoisted
			// 2, a static method in current scope when neither `this' nor any variable is hoisted
			// 3, an instance method in compiler generated storey when any hoisted variable exists
			//

			Modifiers modifiers;
			TypeDefinition parent = null;

			var src_block = Block.Original.Explicit;
			if (src_block.HasCapturedVariable || src_block.HasCapturedThis) {
				parent = storey = FindBestMethodStorey ();

				if (storey == null) {
					var sm = src_block.ParametersBlock.TopBlock.StateMachine;

					//
					// Remove hoisted this demand when simple instance method is enough (no hoisted variables only this)
					//
					if (src_block.HasCapturedThis && src_block.ParametersBlock.StateMachine == null) {
						src_block.ParametersBlock.TopBlock.RemoveThisReferenceFromChildrenBlock (src_block);

						//
						// Special case where parent class is used to emit instance method
						// because currect storey is of value type (async host) and we don't
						// want to create another childer storey to host this reference only
						//
						if (sm != null && sm.Kind == MemberKind.Struct)
							parent = sm.Parent.PartialContainer;
					}

					//
					// For iterators we can host everything in one class
					//
					if (sm is IteratorStorey)
						parent = storey = sm;
				}

				modifiers = storey != null ? Modifiers.INTERNAL : Modifiers.PRIVATE;
			} else {
				if (ec.CurrentAnonymousMethod != null)
					parent = storey = ec.CurrentAnonymousMethod.Storey;

				modifiers = Modifiers.STATIC | Modifiers.PRIVATE;
			}

			if (parent == null)
				parent = ec.CurrentTypeDefinition.Parent.PartialContainer;

			string name = CompilerGeneratedContainer.MakeName (parent != storey ? block_name : null,
				"m", null, ec.Module.CounterAnonymousMethods++);

			MemberName member_name;
			if (storey == null && ec.CurrentTypeParameters != null) {

				var hoisted_tparams = ec.CurrentTypeParameters;
				var type_params = new TypeParameters (hoisted_tparams.Count);
				for (int i = 0; i < hoisted_tparams.Count; ++i) {
				    type_params.Add (hoisted_tparams[i].CreateHoistedCopy (null));
				}

				member_name = new MemberName (name, type_params, Location);
			} else {
				member_name = new MemberName (name, Location);
			}

			return new AnonymousMethodMethod (parent,
				this, storey, new TypeExpression (ReturnType, Location), modifiers,
				member_name, parameters);
		}
Ejemplo n.º 35
0
 public void ImplementMethod(MemberName name, TypeSpec ifaceType, MethodData method, bool clear_one, out MethodSpec ambiguousCandidate, ref bool optional)
 {
     InterfaceMethod(name, ifaceType, method, clear_one ? Operation.ClearOne : Operation.ClearAll, out ambiguousCandidate, ref optional);
 }
Ejemplo n.º 36
0
		protected CompilerGeneratedContainer (TypeContainer parent, MemberName name, Modifiers mod)
			: this (parent, name, mod, MemberKind.Class)
		{
		}
Ejemplo n.º 37
0
 protected FieldBase(TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
     : base(parent, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE, name, attrs)
 {
     if ((mod & Modifiers.ABSTRACT) != 0)
     {
         Report.Error(681, Location, "The modifier 'abstract' is not valid on fields. Try using a property instead");
     }
 }
Ejemplo n.º 38
0
 GetEnumeratorMethod(IteratorStorey host, FullNamedExpression returnType, MemberName name)
     : base(host, null, returnType, Modifiers.DEBUGGER_HIDDEN, name)
 {
 }
Ejemplo n.º 39
0
 public DocumentationMemberContext(MemberCore host, MemberName contextName)
 {
     this.host        = host;
     this.contextName = contextName;
 }
Ejemplo n.º 40
0
 public GetEnumeratorMethod(IteratorStorey host, FullNamedExpression returnType, MemberName name)
     : base(host, returnType, 0, name)
 {
     Block.AddStatement(new GetEnumeratorStatement(host, this));
 }
Ejemplo n.º 41
0
		public ClassOrStruct (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
			: base (parent, name, attrs, kind)
		{
		}
Ejemplo n.º 42
0
        protected override bool DoDefineMembers()
        {
            current_field   = AddCompilerGeneratedField("$current", iterator_type_expr);
            disposing_field = AddCompilerGeneratedField("$disposing", new TypeExpression(Compiler.BuiltinTypes.Bool, Location));

            if (Iterator.IsEnumerable && hoisted_params != null)
            {
                //
                // Iterators are independent, each GetEnumerator call has to
                // create same enumerator therefore we have to keep original values
                // around for re-initialization
                //
                hoisted_params_copy = new List <HoistedParameter> (hoisted_params.Count);
                foreach (HoistedParameter hp in hoisted_params)
                {
                    //
                    // Don't create field copy for unmodified captured parameters
                    //
                    HoistedParameter hp_copy;
                    if (hp.IsAssigned)
                    {
                        hp_copy = new HoistedParameter(hp, "<$>" + hp.Field.Name);
                    }
                    else
                    {
                        hp_copy = null;
                    }

                    hoisted_params_copy.Add(hp_copy);
                }
            }

            if (generic_enumerator_type != null)
            {
                Define_Current(true);
            }

            Define_Current(false);
            new DisposeMethod(this);
            Define_Reset();

            if (Iterator.IsEnumerable)
            {
                FullNamedExpression explicit_iface = new TypeExpression(Compiler.BuiltinTypes.IEnumerable, Location);
                var name = new MemberName("GetEnumerator", null, explicit_iface, Location.Null);

                if (generic_enumerator_type != null)
                {
                    explicit_iface = new TypeExpression(generic_enumerable_type, Location);
                    var    gname           = new MemberName("GetEnumerator", null, explicit_iface, Location.Null);
                    Method gget_enumerator = GetEnumeratorMethod.Create(this, new TypeExpression(generic_enumerator_type, Location), gname);

                    //
                    // Just call generic GetEnumerator implementation
                    //
                    var    stmt           = new Return(new Invocation(new DynamicMethodGroupExpr(gget_enumerator, Location), null), Location);
                    Method get_enumerator = GetEnumeratorMethod.Create(this, new TypeExpression(Compiler.BuiltinTypes.IEnumerator, Location), name, stmt);

                    Members.Add(get_enumerator);
                    Members.Add(gget_enumerator);
                }
                else
                {
                    Members.Add(GetEnumeratorMethod.Create(this, new TypeExpression(Compiler.BuiltinTypes.IEnumerator, Location), name));
                }
            }

            return(base.DoDefineMembers());
        }
Ejemplo n.º 43
0
		//
		// Returns full metadata method name
		//
		public string GetFullName (MemberName name)
		{
			return GetFullName (name.Name);
		}
Ejemplo n.º 44
0
 public EnumMember(Enum parent, MemberName name, Attributes attrs)
     : base(parent, new EnumTypeExpr(), Modifiers.PUBLIC, name, attrs)
 {
 }
Ejemplo n.º 45
0
 public AliasUsing(Location usingLocation, Tokenizer.LocatedToken identifier, Location assignLocation, MemberName nspace, Location semicolonLocation)
 {
     this.UsingLocation     = usingLocation;
     this.Identifier        = identifier;
     this.AssignLocation    = assignLocation;
     this.Nspace            = nspace;
     this.SemicolonLocation = semicolonLocation;
 }
Ejemplo n.º 46
0
		public InterfaceMemberBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
			: base (parent, type, mod, allowed_mod, Modifiers.PRIVATE, name, attrs)
		{
			IsInterface = parent.Kind == MemberKind.Interface;
			IsExplicitImpl = (MemberName.ExplicitInterface != null);
			explicit_mod_flags = mod;
		}
Ejemplo n.º 47
0
 public Field(TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
     : base(parent, type, mod, AllowedModifiers, name, attrs)
 {
 }
Ejemplo n.º 48
0
		protected MemberBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers def_mod, MemberName name, Attributes attrs)
			: base (parent, name, attrs)
		{
			this.Parent = parent;
			this.type_expr = type;

			if (name != MemberName.Null)
				ModFlags = ModifiersExtensions.Check (allowed_mod, mod, def_mod, Location, Report);
		}
Ejemplo n.º 49
0
        public Delegate(TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, ParametersCompiled param_list,
                        Attributes attrs)
            : base(parent, name, attrs, MemberKind.Delegate)

        {
            this.ReturnType = type;
            ModFlags        = ModifiersExtensions.Check(AllowedModifiers, mod_flags,
                                                        IsTopLevel ? Modifiers.INTERNAL :
                                                        Modifiers.PRIVATE, name.Location, Report);
            parameters = param_list;
            spec       = new TypeSpec(Kind, null, this, null, ModFlags | Modifiers.SEALED);
        }
Ejemplo n.º 50
0
		public TypeDefinition (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
			: base (parent, name, attrs, kind)
		{
			PartialContainer = this;
			members = new List<MemberCore> ();
		}
Ejemplo n.º 51
0
 public Field(DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name,
              Attributes attrs)
     : base(parent, type, mod ^ Modifiers.ROLE, AllowedModifiers, name, attrs)
 {
     isRole = (mod & Modifiers.ROLE) == Modifiers.ROLE;
 }
Ejemplo n.º 52
0
			public AnonymousMethodMethod (TypeDefinition parent, AnonymousExpression am, AnonymousMethodStorey storey,
							  TypeExpr return_type,
							  Modifiers mod, MemberName name,
							  ParametersCompiled parameters)
				: base (parent, return_type, mod | Modifiers.COMPILER_GENERATED,
						name, parameters, null)
			{
				this.AnonymousMethod = am;
				this.Storey = storey;

				Parent.PartialContainer.Members.Add (this);
				Block = new ToplevelBlock (am.block, parameters);
			}
Ejemplo n.º 53
0
 public RoleField(DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs) : base(parent, type, mod, name, attrs)
 {
 }
Ejemplo n.º 54
0
		private AnonymousTypeClass (ModuleContainer parent, MemberName name, IList<AnonymousTypeParameter> parameters, Location loc)
			: base (parent, name, parent.Evaluator != null ? Modifiers.PUBLIC : Modifiers.INTERNAL)
		{
			this.parameters = parameters;
		}
Ejemplo n.º 55
0
 public StateMachineMethod(StateMachine host, StateMachineInitializer expr, FullNamedExpression returnType, Modifiers mod, MemberName name)
     : base(host, returnType, mod | Modifiers.COMPILER_GENERATED,
            name, ParametersCompiled.EmptyReadOnlyParameters, null)
 {
     this.expr = expr;
     Block     = new ToplevelBlock(host.Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
 }
Ejemplo n.º 56
0
 /// <summary>
 ///   Whether the specified method is an interface method implementation
 /// </summary>
 public MethodSpec IsInterfaceMethod(MemberName name, TypeSpec ifaceType, MethodData method, out MethodSpec ambiguousCandidate, ref bool optional)
 {
     return(InterfaceMethod(name, ifaceType, method, Operation.Lookup, out ambiguousCandidate, ref optional));
 }
Ejemplo n.º 57
0
 public MemberName(MemberName left, string name, Location loc)
 {
     this.Name     = name;
     this.Location = loc;
     this.Left     = left;
 }