Base class for structs, classes, enumerations and interfaces.
They all create new declaration spaces. This provides the common foundation for managing those name spaces.
Inheritance: MemberCore
Exemple #1
0
		protected override bool AddMemberType (DeclSpace ds)
		{
			if (!AddToContainer (ds, ds.Name))
				return false;
			ds.NamespaceEntry.NS.AddDeclSpace (ds.Basename, ds);
			return true;
		}
Exemple #2
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;
		}
Exemple #3
0
		public Const (DeclSpace parent, FullNamedExpression type, string name,
			      Expression expr, int mod_flags, Attributes attrs, Location loc)
			: base (parent, type, mod_flags, AllowedModifiers,
				new MemberName (name, loc), attrs)
		{
			initializer = expr;
			ModFlags |= Modifiers.STATIC;
		}
        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)
        {
        }
        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);
        }
Exemple #6
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");
		}
Exemple #7
0
 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);
 }
Exemple #8
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);
				}
			}
		}
Exemple #9
0
        public Const(DeclSpace parent, FullNamedExpression type, string name,
            Expression expr, Modifiers mod_flags, Attributes attrs, Location loc)
            : base(parent, type, mod_flags, AllowedModifiers,
				new MemberName (name, loc), attrs)
        {
            if (expr != null)
                initializer = new ConstInitializer (this, expr);

            ModFlags |= Modifiers.STATIC;
        }
		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);
			}
		}
Exemple #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);

            if (IsStatic && RootContext.Version == LanguageVersion.ISO_1) {
                Report.FeatureIsNotAvailable (Location, "static classes");
            }
        }
 		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;
		}
        public Delegate(NamespaceEntry ns, DeclSpace parent, FullNamedExpression type,
				 Modifiers mod_flags, MemberName name, ParametersCompiled param_list,
				 Attributes attrs)
            : base(ns, 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);
        }
Exemple #14
0
		// TypeContainer

		//
		// Generates xml doc comments (if any), and if required,
		// handle warning report.
		//
		internal static void GenerateTypeDocComment (TypeContainer t,
			DeclSpace ds, Report Report)
		{
			GenerateDocComment (t, ds, Report);

			if (t.DefaultStaticConstructor != null)
				t.DefaultStaticConstructor.GenerateDocComment (t);

			if (t.InstanceConstructors != null)
				foreach (Constructor c in t.InstanceConstructors)
					c.GenerateDocComment (t);

			if (t.Types != null)
				foreach (TypeContainer tc in t.Types)
					tc.GenerateDocComment (t);

			if (t.Delegates != null)
				foreach (Delegate de in t.Delegates)
					de.GenerateDocComment (t);

			if (t.Constants != null)
				foreach (Const c in t.Constants)
					c.GenerateDocComment (t);

			if (t.Fields != null)
				foreach (FieldBase f in t.Fields)
					f.GenerateDocComment (t);

			if (t.Events != null)
				foreach (Event e in t.Events)
					e.GenerateDocComment (t);

			if (t.Indexers != null)
				foreach (Indexer ix in t.Indexers)
					ix.GenerateDocComment (t);

			if (t.Properties != null)
				foreach (Property p in t.Properties)
					p.GenerateDocComment (t);

			if (t.Methods != null)
				foreach (MethodOrOperator m in t.Methods)
					m.GenerateDocComment (t);

			if (t.Operators != null)
				foreach (Operator o in t.Operators)
					o.GenerateDocComment (t);
		}
Exemple #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];
				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 (null, src, dst);
				for (int i = 0; i < type_params.Length; ++i) {
					src[i].InflateConstraints (inflator, dst[i]);
				}
			}
		}
Exemple #16
0
		public InterfaceMemberBase (DeclSpace parent, GenericMethod generic,
				   FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
				   MemberName name, Attributes attrs)
			: base (parent, generic, type, mod, allowed_mod, Modifiers.PRIVATE,
				name, attrs)
		{
			IsInterface = parent.PartialContainer.Kind == MemberKind.Interface;
			IsExplicitImpl = (MemberName.ExplicitInterface != null);
			explicit_mod_flags = mod;
		}
Exemple #17
0
		public Interface (NamespaceContainer ns, DeclSpace parent, MemberName name, Modifiers mod,
				  Attributes attrs)
			: base (ns, parent, name, attrs, MemberKind.Interface)
		{
			var accmods = parent.Parent == null ? Modifiers.INTERNAL : Modifiers.PRIVATE;

			this.ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod, accmods, name.Location, Report);
			spec = new TypeSpec (Kind, null, this, null, ModFlags);
		}
Exemple #18
0
		public override void AddBasesForPart (DeclSpace part, List<FullNamedExpression> bases)
		{
			if (part.Name == "System.Object")
				Report.Error (537, part.Location,
					"The class System.Object cannot have a base class or implement an interface.");
			base.AddBasesForPart (part, bases);
		}
Exemple #19
0
		public TypeContainer (NamespaceContainer ns, DeclSpace parent, MemberName name,
				      Attributes attrs, MemberKind kind)
			: base (ns, parent, name, attrs)
		{
			if (parent != null && parent.NamespaceEntry != ns)
				throw new InternalErrorException ("A nested type should be in the same NamespaceEntry as its enclosing class");

			this.Kind = kind;
			this.PartialContainer = this;
		}
Exemple #20
0
		public ClassOrStruct (NamespaceContainer ns, DeclSpace parent,
				      MemberName name, Attributes attrs, MemberKind kind)
			: base (ns, parent, name, attrs, kind)
		{
		}
Exemple #21
0
			void AddConstraints (AbstractCSharpNode parent, DeclSpace d)
			{
				if (d == null || d.Constraints == null)
					return;
				for (int i = 0; i < d.Constraints.Count; i++) {
					Constraints c = d.Constraints[i];
					var location = LocationsBag.GetLocations (c);
					var constraint = new Constraint ();
					parent.AddChild (new CSharpTokenNode (Convert (location[0]), "where".Length), InvocationExpression.Roles.Keyword);
					parent.AddChild (new Identifier (c.TypeParameter.Value, Convert (c.TypeParameter.Location)), InvocationExpression.Roles.Identifier);
					parent.AddChild (new CSharpTokenNode (Convert (location[1]), 1), InvocationExpression.Roles.Colon);
					foreach (var expr in c.ConstraintExpressions)
						parent.AddChild ((INode)expr.Accept (this), InvocationExpression.Roles.TypeArgument);
				}
			}
			public void AddTypeParameter (AbstractTypeParameterMember member, DeclSpace decl)
			{
				if (!decl.IsGeneric || decl.CurrentTypeParameters == null)
					return;
				
				foreach (var typeParameter in decl.CurrentTypeParameters) {
					var par = ConvertTemplateDefinition (typeParameter);
					member.AddTypeParameter (par);
				}
			}
Exemple #23
0
		protected virtual void RemoveMemberType (DeclSpace ds)
		{
			RemoveFromContainer (ds.Basename);
		}
Exemple #24
0
		//
		// Generates xml doc comments (if any), and if required,
		// handle warning report.
		//
		internal override void GenerateDocComment (DeclSpace ds)
		{
			DocUtil.GenerateTypeDocComment (this, ds, Report);
		}
Exemple #25
0
		public Const (DeclSpace parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
			: base (parent, type, mod_flags, AllowedModifiers, name, attrs)
		{
			ModFlags |= Modifiers.STATIC;
		}
Exemple #26
0
		public MemberCore (DeclSpace parent, MemberName name, Attributes attrs)
		{
			this.Parent = parent as TypeContainer;
			member_name = name;
			caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected;
			AddAttributes (attrs, this);
		}
Exemple #27
0
		public DeclSpace (NamespaceContainer ns, DeclSpace parent, MemberName name,
				  Attributes attrs)
			: base (parent, name, attrs)
		{
			NamespaceEntry = ns;
			Basename = name.Basename;
			defined_names = new Dictionary<string, MemberCore> ();
			PartialContainer = null;
			if (name.TypeArguments != null) {
				is_generic = true;
				count_type_params = name.TypeArguments.Count;
			}
			if (parent != null)
				count_type_params += parent.count_type_params;
		}
Exemple #28
0
		protected MemberBase (DeclSpace parent, GenericMethod generic,
				      FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers def_mod,
				      MemberName name, Attributes attrs)
			: base (parent, name, attrs)
		{
			this.ds = generic != null ? generic : (DeclSpace) parent;
			this.type_expr = type;
			ModFlags = ModifiersExtensions.Check (allowed_mod, mod, def_mod, Location, Report);
			GenericMethod = generic;
			if (GenericMethod != null)
				GenericMethod.ModFlags = ModFlags;
		}
Exemple #29
0
		public virtual void AddBasesForPart (DeclSpace part, List<FullNamedExpression> bases)
		{
			// FIXME: get rid of partial_parts and store lists of bases of each part here
			// assumed, not verified: 'part' is in 'partial_parts' 
			((TypeContainer) part).type_bases = bases;
		}
Exemple #30
0
			void AddConstraints (AstNode parent, DeclSpace d)
			{
				if (d == null || d.Constraints == null)
					return;
				for (int i = 0; i < d.PlainConstraints.Count; i++) {
					Constraints c = d.PlainConstraints [i];
					var location = LocationsBag.GetLocations (c);
					var constraint = new Constraint ();
					constraint.AddChild (new CSharpTokenNode (Convert (c.Location), "where".Length), InvocationExpression.Roles.Keyword);
					constraint.AddChild (new SimpleType (Identifier.Create (c.TypeParameter.Value, Convert (c.TypeParameter.Location))), Constraint.TypeParameterRole);
					if (location != null)
						constraint.AddChild (new CSharpTokenNode (Convert (location [0]), 1), Constraint.ColonRole);
					var commaLocs = LocationsBag.GetLocations (c.ConstraintExpressions);
					int curComma = 0;
					foreach (var expr in c.ConstraintExpressions) {
						constraint.AddChild (ConvertToType (expr), Constraint.BaseTypeRole);
						if (commaLocs != null && curComma < commaLocs.Count)
							constraint.AddChild (new CSharpTokenNode (Convert (commaLocs[curComma++]), 1), InvocationExpression.Roles.Comma);
					}
					parent.AddChild (constraint, AstNode.Roles.Constraint);
				}
			}