コード例 #1
0
ファイル: anonymous.cs プロジェクト: nzaugg/mono
		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);
			}
		}
コード例 #2
0
ファイル: class.cs プロジェクト: JoeSGeorge/NRefactory
 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);
 }
コード例 #3
0
ファイル: method.cs プロジェクト: spencerhakim/mono
		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;
		}
コード例 #4
0
ファイル: enum.cs プロジェクト: segaman/NRefactory
 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);
 }
コード例 #5
0
ファイル: field.cs プロジェクト: stabbylambda/mono
		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");
		}
コード例 #6
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)
        {
        }
コード例 #7
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);
        }
コード例 #8
0
ファイル: property.cs プロジェクト: speier/shake
 public Accessor(ToplevelBlock b, Modifiers mod, Attributes attrs, ParametersCompiled p, Location loc)
 {
     Block = b;
     Attributes = attrs;
     Location = loc;
     Parameters = p;
     ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod, 0, loc, RootContext.ToplevelTypes.Compiler.Report);
 }
コード例 #9
0
ファイル: anonymous.cs プロジェクト: rabink/mono
		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);
		}
コード例 #10
0
ファイル: enum.cs プロジェクト: 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);
 }
コード例 #11
0
ファイル: const.cs プロジェクト: speier/shake
        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;
        }
コード例 #12
0
ファイル: anonymous.cs プロジェクト: pgoron/monodevelop
		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);
				}
			}
		}
コード例 #13
0
ファイル: delegate.cs プロジェクト: svermeulen/NRefactory
        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);
        }
コード例 #14
0
ファイル: class.cs プロジェクト: speier/shake
        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");
            }
        }
コード例 #15
0
ファイル: modifiers.cs プロジェクト: speier/shake
        // <summary>
        //   Checks the object @mod modifiers to be in @allowed.
        //   Returns the new mask.  Side effect: reports any
        //   incorrect attributes.
        // </summary>
        public static Modifiers Check(Modifiers allowed, Modifiers mod, Modifiers def_access, Location l, Report Report)
        {
            int invalid_flags = (~(int) allowed) & ((int) mod & ((int) Modifiers.TOP - 1));
            int i;

            if (invalid_flags == 0){

                if ((mod & Modifiers.UNSAFE) != 0){
                    RootContext.CheckUnsafeOption (l, Report);
                }

                //
                // If no accessibility bits provided
                // then provide the defaults.
                //
                if ((mod & Modifiers.AccessibilityMask) == 0) {
                    mod |= def_access;
                    if (def_access != 0)
                        mod |= Modifiers.DEFAULT_ACCESS_MODIFER;
                    return mod;
                }

                //
                // Make sure that no conflicting accessibility
                // bits have been set.  Protected+Internal is
                // allowed, that is why they are placed on bits
                // 1 and 4 (so the shift 3 basically merges them)
                //
                int a = (int) mod;
                a &= 15;
                a |= (a >> 3);
                a = ((a & 2) >> 1) + (a & 5);
                a = ((a & 4) >> 2) + (a & 3);
                if (a > 1)
                    Report.Error (107, l, "More than one protection modifier specified");

                return mod;
            }

            for (i = 1; i <= (int) Modifiers.TOP; i <<= 1) {
                if ((i & invalid_flags) == 0)
                    continue;

                Error_InvalidModifier (l, Name ((Modifiers) i), Report);
            }

            return allowed & mod;
        }
コード例 #16
0
ファイル: modifiers.cs プロジェクト: runefs/Marvin
		public static string AccessibilityName (Modifiers mod)
		{
			switch (mod & Modifiers.AccessibilityMask) {
			case Modifiers.PUBLIC:
				return "public";
			case Modifiers.PROTECTED:
				return "protected";
			case Modifiers.PROTECTED | Modifiers.INTERNAL:
				return "protected internal";
			case Modifiers.INTERNAL:
				return "internal";
			case Modifiers.PRIVATE:
				return "private";
			default:
				throw new NotImplementedException (mod.ToString ());
			}
		}
コード例 #17
0
		static public string Name (Modifiers i)
		{
			string s = "";
			
			switch (i) {
			case Modifiers.NEW:
				s = "new"; break;
			case Modifiers.PUBLIC:
				s = "public"; break;
			case Modifiers.PROTECTED:
				s = "protected"; break;
			case Modifiers.INTERNAL:
				s = "internal"; break;
			case Modifiers.PRIVATE:
				s = "private"; break;
			case Modifiers.ABSTRACT:
				s = "abstract"; break;
			case Modifiers.SEALED:
				s = "sealed"; break;
			case Modifiers.STATIC:
				s = "static"; break;
			case Modifiers.READONLY:
				s = "readonly"; break;
			case Modifiers.VIRTUAL:
				s = "virtual"; break;
			case Modifiers.OVERRIDE:
				s = "override"; break;
			case Modifiers.EXTERN:
				s = "extern"; break;
			case Modifiers.VOLATILE:
				s = "volatile"; break;
			case Modifiers.UNSAFE:
				s = "unsafe"; break;
			case Modifiers.ASYNC:
				s = "async"; break;
			case Modifiers.AS_DYNAMIC:
				s = "dynamic"; break;
			}

			return s;
		}
コード例 #18
0
 public void SetDefinition(ITypeDefinition td, MetaType type, Modifiers mod)
 {
     this.definition = td;
     this.info       = type;
     this.modifiers |= (mod & ~Modifiers.AccessibilityMask);
 }
コード例 #19
0
 public InteractiveMethod(TypeDefinition parent, FullNamedExpression returnType, Modifiers mod, ParametersCompiled parameters)
     : base(parent, returnType, mod, new MemberName("Host"), parameters, null)
 {
 }
コード例 #20
0
ファイル: decl.cs プロジェクト: rahulrborkar/mono
        protected MemberSpec(MemberKind kind, TypeSpec declaringType, IMemberDefinition definition, Modifiers modifiers)
        {
            this.Kind          = kind;
            this.declaringType = declaringType;
            this.definition    = definition;
            this.modifiers     = modifiers;

            state = StateFlags.Obsolete_Undetected | StateFlags.CLSCompliant_Undetected | StateFlags.MissingDependency_Undetected;
        }
コード例 #21
0
ファイル: field.cs プロジェクト: raj581/Marvin
 public RoleField(DeclSpace parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs) : base(parent, type, mod, name, attrs)
 {
 }
コード例 #22
0
ファイル: field.cs プロジェクト: agallero/mono
		public Field (TypeContainer parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
			: base (parent, type, mod, AllowedModifiers, name, attrs)
		{
		}
コード例 #23
0
ファイル: field.cs プロジェクト: agallero/mono
		public FieldSpec (TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, FieldInfo info, Modifiers modifiers)
			: base (MemberKind.Field, declaringType, definition, modifiers)
		{
			this.metaInfo = info;
			this.memberType = memberType;
		}
コード例 #24
0
ファイル: class.cs プロジェクト: jordanbtucker/mono
		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;
		}
コード例 #25
0
ファイル: class.cs プロジェクト: fvalette/mono
		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);
		}
コード例 #26
0
ファイル: field.cs プロジェクト: raj581/Marvin
 public FieldSpec(TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, FieldInfo info, Modifiers modifiers)
     : base(MemberKind.Field, declaringType, definition, modifiers)
 {
     _isRole         = (modifiers & Modifiers.ROLE) != 0;
     this.metaInfo   = info;
     this.memberType = memberType;
 }
コード例 #27
0
ファイル: field.cs プロジェクト: raj581/Marvin
        public FixedFieldSpec(TypeSpec declaringType, IMemberDefinition definition, FieldInfo info, FieldSpec element, Modifiers modifiers)
            : base(declaringType, definition, element.MemberType, info, modifiers)
        {
            this.element = element;

            // It's never CLS-Compliant
            state &= ~StateFlags.CLSCompliant_Undetected;
        }
コード例 #28
0
ファイル: method.cs プロジェクト: OpenFlex/playscript-mono
		public static Method Create (TypeDefinition parent, FullNamedExpression returnType, Modifiers mod,
				   MemberName name, ParametersCompiled parameters, Attributes attrs)
		{
			var m = new Method (parent, returnType, mod, name, parameters, attrs);

			if ((mod & Modifiers.PARTIAL) != 0) {
				const Modifiers invalid_partial_mod = Modifiers.AccessibilityMask | Modifiers.ABSTRACT | Modifiers.EXTERN |
					Modifiers.NEW | Modifiers.OVERRIDE | Modifiers.SEALED | Modifiers.VIRTUAL;

				if ((mod & invalid_partial_mod) != 0) {
					m.Report.Error (750, m.Location,
						"A partial method cannot define access modifier or any of abstract, extern, new, override, sealed, or virtual modifiers");
					mod &= ~invalid_partial_mod;
				}

				if ((parent.ModFlags & Modifiers.PARTIAL) == 0) {
					m.Report.Error (751, m.Location, 
						"A partial method must be declared within a partial class or partial struct");
				}
			}

			if ((mod & Modifiers.STATIC) == 0 && parameters.HasExtensionMethodType) {
				m.Report.Error (1105, m.Location, "`{0}': Extension methods must be declared static",
					m.GetSignatureForError ());
			}


			return m;
		}
コード例 #29
0
ファイル: class.cs プロジェクト: jordanbtucker/mono
		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);
		}
コード例 #30
0
ファイル: anonymous.cs プロジェクト: rabink/mono
			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);
			}
コード例 #31
0
ファイル: class.cs プロジェクト: jordanbtucker/mono
		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;
		}
コード例 #32
0
ファイル: iterators.cs プロジェクト: yehia2amer/Alter-Native
 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);
 }
コード例 #33
0
ファイル: field.cs プロジェクト: agallero/mono
		public FixedFieldSpec (TypeSpec declaringType, IMemberDefinition definition, FieldInfo info, FieldSpec element, Modifiers modifiers)
			: base (declaringType, definition, element.MemberType, info, modifiers)
		{
			this.element = element;

			// It's never CLS-Compliant
			state &= ~StateFlags.CLSCompliant_Undetected;
		}
コード例 #34
0
 public Field(TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs)
     : base(parent, type, mod, AllowedModifiers, name, attrs)
 {
 }
コード例 #35
0
ファイル: class.cs プロジェクト: fvalette/mono
		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;
		}
コード例 #36
0
ファイル: field.cs プロジェクト: raj581/Marvin
 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;
 }
コード例 #37
0
ファイル: anonymous.cs プロジェクト: rabink/mono
		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);
			}
		}
コード例 #38
0
        public TypeSpec(MemberKind kind, TypeSpec declaringType, ITypeDefinition definition, MetaType info, Modifiers modifiers)
            : base(kind, declaringType, definition, modifiers)
        {
            this.declaringType = declaringType;
            this.info          = info;

            if (definition != null && definition.TypeParametersCount > 0)
            {
                state |= StateFlags.IsGeneric;
            }
        }
コード例 #39
0
ファイル: anonymous.cs プロジェクト: rabink/mono
		protected CompilerGeneratedContainer (TypeContainer parent, MemberName name, Modifiers mod)
			: this (parent, name, mod, MemberKind.Class)
		{
		}
コード例 #40
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");
     }
 }
コード例 #41
0
ファイル: anonymous.cs プロジェクト: rabink/mono
			public HoistedField (HoistedStoreyClass parent, FullNamedExpression type, Modifiers mod, string name,
				  Attributes attrs, Location loc)
				: base (parent, type, mod, new MemberName (name, loc), attrs)
			{
			}
コード例 #42
0
 public EnumSpec(TypeSpec declaringType, ITypeDefinition definition, TypeSpec underlyingType, MetaType info, Modifiers modifiers)
     : base(MemberKind.Enum, declaringType, definition, info, modifiers | Modifiers.SEALED)
 {
     this.underlying = underlyingType;
 }