• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CSharp.MethodSpec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Mono.CSharp.MethodSpec的典型用法代码示例。如果您正苦于以下问题:C# MethodSpec类的具体用法?C# MethodSpec怎么用?C# MethodSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MethodSpec类属于Mono.CSharp命名空间,在下文中一共展示了MethodSpec类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PendingImplementation

		PendingImplementation (TypeContainer container, MissingInterfacesInfo[] missing_ifaces, MethodSpec[] abstract_methods, int total)
		{
			var type_builder = container.Definition;
			
			this.container = container;
			pending_implementations = new TypeAndMethods [total];

			int i = 0;
			if (abstract_methods != null) {
				int count = abstract_methods.Length;
				pending_implementations [i].methods = new MethodSpec [count];
				pending_implementations [i].need_proxy = new MethodSpec [count];

				pending_implementations [i].methods = abstract_methods;
				pending_implementations [i].found = new MethodData [count];
				pending_implementations [i].type = type_builder;
				++i;
			}

			foreach (MissingInterfacesInfo missing in missing_ifaces) {
				var iface = missing.Type;
				var mi = MemberCache.GetInterfaceMethods (iface);

				int count = mi.Count;
				pending_implementations [i].type = iface;
				pending_implementations [i].optional = missing.Optional;
				pending_implementations [i].methods = mi;
				pending_implementations [i].found = new MethodData [count];
				pending_implementations [i].need_proxy = new MethodSpec [count];
				i++;
			}
		}
开发者ID:jkells,项目名称:mono,代码行数:32,代码来源:pending.cs


示例2: ApplyAttributeBuilder

		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Target == AttributeTargets.ReturnValue) {
				if (return_attributes == null)
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);

				return_attributes.ApplyAttributeBuilder (a, ctor, cdata, pa);
				return;
			}

			base.ApplyAttributeBuilder (a, ctor, cdata, pa);
		}
开发者ID:silk,项目名称:monodevelop,代码行数:12,代码来源:delegate.cs


示例3: ApplyAttributeBuilder

		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Type == pa.CLSCompliant) {
				method.Compiler.Report.Warning (3023, 1, a.Location,
					"CLSCompliant attribute has no meaning when applied to return types. Try putting it on the method instead");
			}

			// This occurs after Warning -28
			if (builder == null)
				return;

			base.ApplyAttributeBuilder (a, ctor, cdata, pa);
		}
开发者ID:Ein,项目名称:monodevelop,代码行数:13,代码来源:parameter.cs


示例4: CheckReservedNameConflict

		protected void CheckReservedNameConflict (string prefix, MethodSpec accessor)
		{
			string name;
			AParametersCollection parameters;
			if (accessor != null) {
				name = accessor.Name;
				parameters = accessor.Parameters;
			} else {
				name = prefix + ShortName;
				if (IsExplicitImpl)
					name = MemberName.Left + "." + name;

				if (this is Indexer) {
					parameters = ((Indexer) this).ParameterInfo;
					if (prefix[0] == 's') {
						var data = new IParameterData[parameters.Count + 1];
						Array.Copy (parameters.FixedParameters, data, data.Length - 1);
						data[data.Length - 1] = new ParameterData ("value", Parameter.Modifier.NONE);
						var types = new TypeSpec[data.Length];
						Array.Copy (parameters.Types, types, data.Length - 1);
						types[data.Length - 1] = member_type;

						parameters = new ParametersImported (data, types, false);
					}
				} else {
					if (prefix[0] == 's')
						parameters = ParametersCompiled.CreateFullyResolved (new[] { member_type });
					else
						parameters = ParametersCompiled.EmptyReadOnlyParameters;
				}
			}

			var conflict = MemberCache.FindMember (Parent.Definition,
				new MemberFilter (name, 0, MemberKind.Method, parameters, null),
				BindingRestriction.DeclaredOnly | BindingRestriction.NoAccessors);

			if (conflict != null) {
				Report.SymbolRelatedToPreviousError (conflict);
				Report.Error (82, Location, "A member `{0}' is already reserved", conflict.GetSignatureForError ());
			}
		}
开发者ID:bbqchickenrobot,项目名称:playscript-mono,代码行数:41,代码来源:property.cs


示例5: ApplyAttributeBuilder

		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
#if false
			if (a.Type == pa.MarshalAs) {
				UnmanagedMarshal marshal = a.GetMarshal (this);
				if (marshal != null) {
					builder.SetMarshal (marshal);
				}
				return;
			}
#endif
			if (a.HasSecurityAttribute) {
				a.Error_InvalidSecurityParent ();
				return;
			}

			if (a.Type == pa.Dynamic) {
				a.Error_MisusedDynamicAttribute ();
				return;
			}

			builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), cdata);
		}
开发者ID:bl8,项目名称:mono,代码行数:23,代码来源:parameter.cs


示例6: CheckBase

		protected override bool CheckBase ()
		{
			if (!base.CheckBase ())
				return false;

			if ((caching_flags & Flags.MethodOverloadsExist) != 0)
				CheckForDuplications ();
			
			if (IsExplicitImpl)
				return true;

			// For System.Object only
			if (Parent.BaseType == null)
				return true;

			MemberSpec candidate;
			bool overrides = false;
			var base_member = FindBaseMember (out candidate, ref overrides);

			if ((ModFlags & Modifiers.OVERRIDE) != 0) {
				if (base_member == null) {
					if (candidate == null) {
						if (this is Method && ((Method)this).ParameterInfo.IsEmpty && MemberName.Name == Destructor.MetadataName && MemberName.Arity == 0) {
							Report.Error (249, Location, "Do not override `{0}'. Use destructor syntax instead",
								"object.Finalize()");
						} else {
							Report.Error (115, Location, "`{0}' is marked as an override but no suitable {1} found to override",
								GetSignatureForError (), SimpleName.GetMemberType (this));
						}
					} else {
						Report.SymbolRelatedToPreviousError (candidate);
						if (this is Event)
							Report.Error (72, Location, "`{0}': cannot override because `{1}' is not an event",
								GetSignatureForError (), TypeManager.GetFullNameSignature (candidate));
						else if (this is PropertyBase)
							Report.Error (544, Location, "`{0}': cannot override because `{1}' is not a property",
								GetSignatureForError (), TypeManager.GetFullNameSignature (candidate));
						else
							Report.Error (505, Location, "`{0}': cannot override because `{1}' is not a method",
								GetSignatureForError (), TypeManager.GetFullNameSignature (candidate));
					}

					return false;
				}

				//
				// Handles ambiguous overrides
				//
				if (candidate != null) {
					Report.SymbolRelatedToPreviousError (candidate);
					Report.SymbolRelatedToPreviousError (base_member);

					// Get member definition for error reporting
					var m1 = MemberCache.GetMember (base_member.DeclaringType.GetDefinition (), base_member);
					var m2 = MemberCache.GetMember (candidate.DeclaringType.GetDefinition (), candidate);

					Report.Error (462, Location,
						"`{0}' cannot override inherited members `{1}' and `{2}' because they have the same signature when used in type `{3}'",
						GetSignatureForError (), m1.GetSignatureForError (), m2.GetSignatureForError (), Parent.GetSignatureForError ());
				}

				if (!CheckOverrideAgainstBase (base_member))
					return false;

				ObsoleteAttribute oa = base_member.GetAttributeObsolete ();
				if (oa != null) {
					if (OptAttributes == null || !OptAttributes.Contains (Module.PredefinedAttributes.Obsolete)) {
						Report.SymbolRelatedToPreviousError (base_member);
						Report.Warning (672, 1, Location, "Member `{0}' overrides obsolete member `{1}'. Add the Obsolete attribute to `{0}'",
							GetSignatureForError (), base_member.GetSignatureForError ());
					}
				} else {
					if (OptAttributes != null && OptAttributes.Contains (Module.PredefinedAttributes.Obsolete)) {
						Report.SymbolRelatedToPreviousError (base_member);
						Report.Warning (809, 1, Location, "Obsolete member `{0}' overrides non-obsolete member `{1}'",
							GetSignatureForError (), base_member.GetSignatureForError ());
					}
				}

				base_method = base_member as MethodSpec;
				return true;
			}

			if (base_member == null && candidate != null && (!(candidate is IParametersMember) || !(this is IParametersMember)))
				base_member = candidate;

			if (base_member == null) {
				if ((ModFlags & Modifiers.NEW) != 0) {
					if (base_member == null) {
						Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required",
							GetSignatureForError ());
					}
				}
			} else {
				if ((ModFlags & Modifiers.NEW) == 0) {
					ModFlags |= Modifiers.NEW;
					if (!IsCompilerGenerated) {
						Report.SymbolRelatedToPreviousError (base_member);
						if (!IsInterface && (base_member.Modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) != 0) {
							Report.Warning (114, 2, Location, "`{0}' hides inherited member `{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword",
//.........这里部分代码省略.........
开发者ID:fvalette,项目名称:mono,代码行数:101,代码来源:class.cs


示例7: ApplyAttributeBuilder

		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			base.ApplyAttributeBuilder (a, ctor, cdata, pa);

			//
			// When struct constains fixed fixed and struct layout has explicitly
			// set CharSet, its value has to be propagated to compiler generated
			// fixed types
			//
			if (a.Type == pa.StructLayout) {
				var value = a.GetNamedValue ("CharSet");
				if (value == null)
					return;

				for (int i = 0; i < Members.Count; ++i) {
					FixedField ff = Members [i] as FixedField;
					if (ff == null)
						continue;

					ff.CharSet = (CharSet) System.Enum.Parse (typeof (CharSet), value.GetValue ().ToString ());
				}
			}
		}
开发者ID:fvalette,项目名称:mono,代码行数:23,代码来源:class.cs


示例8: SetCustomAttribute

		public void SetCustomAttribute (MethodSpec ctor, byte[] data)
		{
			FieldBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), data);
		}
开发者ID:agallero,项目名称:mono,代码行数:4,代码来源:field.cs


示例9: ApplyAttributeBuilder

		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Target == AttributeTargets.Method) {
				foreach (var m in members) {
					var c = m as Constructor;
					if (c == null)
						continue;

					if (c.IsPrimaryConstructor) {
						c.ApplyAttributeBuilder (a, ctor, cdata, pa);
						return;
					}
				}

				throw new InternalErrorException ();
			}

			if (has_normal_indexers && a.Type == pa.DefaultMember) {
				Report.Error (646, a.Location, "Cannot specify the `DefaultMember' attribute on type containing an indexer");
				return;
			}

			if (a.Type == pa.Required) {
				Report.Error (1608, a.Location, "The RequiredAttribute attribute is not permitted on C# types");
				return;
			}

			TypeBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), cdata);
		} 
开发者ID:razzfazz,项目名称:mono,代码行数:29,代码来源:class.cs


示例10: Define

		public override bool Define ()
		{
			if (!base.Define ())
				return false;

			if (!CheckBase ())
				return false;

			MemberKind kind;
			if (this is Operator)
				kind = MemberKind.Operator;
			else if (this is Destructor)
				kind = MemberKind.Destructor;
			else
				kind = MemberKind.Method;

			string explicit_name;

			if (IsPartialDefinition) {
				caching_flags &= ~Flags.Excluded_Undetected;
				caching_flags |= Flags.Excluded;

				// Add to member cache only when a partial method implementation has not been found yet
				if ((caching_flags & Flags.PartialDefinitionExists) != 0)
					return true;

				if (IsExplicitImpl)
					return true;

				explicit_name = null;
			} else {
				MethodData = new MethodData (this, ModFlags, flags, this, base_method);

				if (!MethodData.Define (Parent.PartialContainer, GetFullName (MemberName)))
					return false;

				explicit_name = MethodData.MetadataName;
			}

			spec = new MethodSpec (kind, Parent.Definition, this, ReturnType, parameters, ModFlags);
			if (MemberName.Arity > 0)
				spec.IsGeneric = true;

			Parent.MemberCache.AddMember (this, explicit_name, spec);

			return true;
		}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:47,代码来源:method.cs


示例11: CheckImplementingMethodConstraints

		public static bool CheckImplementingMethodConstraints (TypeContainer container, MethodSpec method, MethodSpec baseMethod)
		{
			var tparams = method.Constraints;
			var base_tparams = baseMethod.Constraints;
			for (int i = 0; i < tparams.Length; ++i) {
				if (!tparams[i].HasSameConstraintsImplementation (base_tparams[i])) {
					container.Compiler.Report.SymbolRelatedToPreviousError (method);
					container.Compiler.Report.SymbolRelatedToPreviousError (baseMethod);

					// Using container location because the interface can be implemented
					// by base class
					container.Compiler.Report.Error (425, container.Location,
						"The constraints for type parameter `{0}' of method `{1}' must match the constraints for type parameter `{2}' of interface method `{3}'. Consider using an explicit interface implementation instead",
						tparams[i].GetSignatureForError (), method.GetSignatureForError (),
						base_tparams[i].GetSignatureForError (), baseMethod.GetSignatureForError ());
 
					return false;
				}
			}

			return true;
		}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:22,代码来源:method.cs


示例12: ApplyToExtraTarget

		protected virtual void ApplyToExtraTarget (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			throw new NotSupportedException ("You forgot to define special attribute target handling");
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:4,代码来源:method.cs


示例13: Define

		//
		// Creates the ConstructorBuilder
		//
		public override bool Define ()
		{
			if (ConstructorBuilder != null)
				return true;

			if (!CheckAbstractAndExtern (block != null))
				return false;
			
			// Check if arguments were correct.
			if (!CheckBase ())
				return false;

			if (Parent.PrimaryConstructorParameters != null && !IsPrimaryConstructor && !IsStatic) {
				if (Parent.Kind == MemberKind.Struct && Initializer is ConstructorThisInitializer && Initializer.Arguments == null) {
					Report.Error (8043, Location, "`{0}': Structs with primary constructor cannot specify default constructor initializer",
						GetSignatureForError ());
				} else if (Initializer == null || Initializer is ConstructorBaseInitializer) {
					Report.Error (8037, Location, "`{0}': Instance constructor of type with primary constructor must specify `this' constructor initializer",
						GetSignatureForError ());
				}
			}

			var ca = ModifiersExtensions.MethodAttr (ModFlags) | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName;

			ConstructorBuilder = Parent.TypeBuilder.DefineConstructor (
				ca, CallingConventions,
				parameters.GetMetaInfo ());

			spec = new MethodSpec (MemberKind.Constructor, Parent.Definition, this, Compiler.BuiltinTypes.Void, parameters, ModFlags);
			
			Parent.MemberCache.AddMember (spec);
			
			if (block != null) {
				// It's here only to report an error
				if (block.IsIterator) {
					member_type = Compiler.BuiltinTypes.Void;
					Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags);
				}

				if (Compiler.Settings.WriteMetadataOnly)
					block = null;
			}

			return true;
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:48,代码来源:method.cs


示例14: ApplyAttributeBuilder

		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Type == pa.Conditional) {
				Error_ConditionalAttributeIsNotValid ();
				return;
			}

			base.ApplyAttributeBuilder (a, ctor, cdata, pa);
		}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:9,代码来源:method.cs


示例15: ApplyAttributeBuilder

		public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			if (a.Type == pa.FieldOffset) {
				status |= Status.HAS_OFFSET;

				if (!Parent.PartialContainer.HasExplicitLayout) {
					Report.Error (636, Location, "The FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit)");
					return;
				}

				if ((ModFlags & Modifiers.STATIC) != 0 || this is Const) {
					Report.Error (637, Location, "The FieldOffset attribute is not allowed on static or const fields");
					return;
				}
			}

			if (a.Type == pa.FixedBuffer) {
				Report.Error (1716, Location, "Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the 'fixed' field modifier instead");
				return;
			}

#if false
			if (a.Type == pa.MarshalAs) {
				UnmanagedMarshal marshal = a.GetMarshal (this);
				if (marshal != null) {
					FieldBuilder.SetMarshal (marshal);
				}
				return;
			}
#endif
			if ((a.HasSecurityAttribute)) {
				a.Error_InvalidSecurityParent ();
				return;
			}

			if (a.Type == pa.Dynamic) {
				a.Error_MisusedDynamicAttribute ();
				return;
			}

			FieldBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), cdata);
		}
开发者ID:agallero,项目名称:mono,代码行数:42,代码来源:field.cs


示例16: CreateHoistedBaseCallProxy

		//
		// Creates a proxy base method call inside this container for hoisted base member calls
		//
		public MethodSpec CreateHoistedBaseCallProxy (ResolveContext rc, MethodSpec method)
		{
			Method proxy_method;

			//
			// One proxy per base method is enough
			//
			if (hoisted_base_call_proxies == null) {
				hoisted_base_call_proxies = new Dictionary<MethodSpec, Method> ();
				proxy_method = null;
			} else {
				hoisted_base_call_proxies.TryGetValue (method, out proxy_method);
			}

			if (proxy_method == null) {
				string name = CompilerGeneratedContainer.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count);

				MemberName member_name;
				TypeArguments targs = null;
				TypeSpec return_type = method.ReturnType;
				var local_param_types = method.Parameters.Types;

				if (method.IsGeneric) {
					//
					// Copy all base generic method type parameters info
					//
					var hoisted_tparams = method.GenericDefinition.TypeParameters;
					var tparams = new TypeParameters ();

					targs = new TypeArguments ();
					targs.Arguments = new TypeSpec[hoisted_tparams.Length];
					for (int i = 0; i < hoisted_tparams.Length; ++i) {
						var tp = hoisted_tparams[i];
						var local_tp = new TypeParameter (tp, null, new MemberName (tp.Name, Location), null);
						tparams.Add (local_tp);

						targs.Add (new SimpleName (tp.Name, Location));
						targs.Arguments[i] = local_tp.Type;
					}

					member_name = new MemberName (name, tparams, Location);

					//
					// Mutate any method type parameters from original
					// to newly created hoisted version
					//
					var mutator = new TypeParameterMutator (hoisted_tparams, tparams);
					return_type = mutator.Mutate (return_type);
					local_param_types = mutator.Mutate (local_param_types);
				} else {
					member_name = new MemberName (name);
				}

				var base_parameters = new Parameter[method.Parameters.Count];
				for (int i = 0; i < base_parameters.Length; ++i) {
					var base_param = method.Parameters.FixedParameters[i];
					base_parameters[i] = new Parameter (new TypeExpression (local_param_types [i], Location),
						base_param.Name, base_param.ModFlags, null, Location);
					base_parameters[i].Resolve (this, i);
				}

				var cloned_params = ParametersCompiled.CreateFullyResolved (base_parameters, method.Parameters.Types);
				if (method.Parameters.HasArglist) {
					cloned_params.FixedParameters[0] = new Parameter (null, "__arglist", Parameter.Modifier.NONE, null, Location);
					cloned_params.Types[0] = Module.PredefinedTypes.RuntimeArgumentHandle.Resolve ();
				}

				// Compiler generated proxy
				proxy_method = new Method (this, new TypeExpression (return_type, Location),
					Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN,
					member_name, cloned_params, null);

				var block = new ToplevelBlock (Compiler, proxy_method.ParameterInfo, Location) {
					IsCompilerGenerated = true
				};

				var mg = MethodGroupExpr.CreatePredefined (method, method.DeclaringType, Location);
				mg.InstanceExpression = new BaseThis (method.DeclaringType, Location);
				if (targs != null)
					mg.SetTypeArguments (rc, targs);

				// Get all the method parameters and pass them as arguments
				var real_base_call = new Invocation (mg, block.GetAllParametersArguments ());
				Statement statement;
				if (method.ReturnType.Kind == MemberKind.Void)
					statement = new StatementExpression (real_base_call);
				else
					statement = new Return (real_base_call, Location);

				block.AddStatement (statement);
				proxy_method.Block = block;

				members.Add (proxy_method);
				proxy_method.Define ();
				proxy_method.PrepareEmit ();

				hoisted_base_call_proxies.Add (method, proxy_method);
//.........这里部分代码省略.........
开发者ID:fvalette,项目名称:mono,代码行数:101,代码来源:class.cs


示例17: MethodData

		public MethodData (InterfaceMemberBase member,
				   Modifiers modifiers, MethodAttributes flags, 
				   IMethodData method,
				   MethodSpec parent_method)
			: this (member, modifiers, flags, method)
		{
			this.parent_method = parent_method;
		}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:8,代码来源:method.cs


示例18: ApplyToExtraTarget

		protected virtual void ApplyToExtraTarget (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
		{
			// We ignore this error in AS as attributes are always applied to getters/setters (seems like a missing feature in C#).
			if (a.Location.SourceFile != null && a.Location.SourceFile.FileType == SourceFileType.PlayScript)
				return;

			throw new NotSupportedException ("You forgot to define special attribute target handling");
		}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:8,代码来源:method.cs


示例19: DoResolve

		protected override Expression DoResolve (ResolveContext ec)
		{
			eclass = ExprClass.Value;

			// FIXME: Hack
			var caller_builder = (Constructor) ec.MemberContext;

			//
			// Spec mandates that constructor initializer will not have `this' access
			//
			using (ec.Set (ResolveContext.Options.BaseInitializer)) {
				if (argument_list != null) {
					bool dynamic;
					argument_list.Resolve (ec, out dynamic);

					if (dynamic) {
						ec.Report.Error (1975, loc,
							"The constructor call cannot be dynamically dispatched within constructor initializer");

						return null;
					}
				}

				type = ec.CurrentType;
				if (this is ConstructorBaseInitializer) {
					if (ec.CurrentType.BaseType == null)
						return this;

					type = ec.CurrentType.BaseType;
					if (ec.CurrentType.IsStruct) {
						ec.Report.Error (522, loc,
							"`{0}': Struct constructors cannot call base constructors", caller_builder.GetSignatureForError ());
						return this;
					}
				} else {
					//
					// It is legal to have "this" initializers that take no arguments
					// in structs
					//
					// struct D { public D (int a) : this () {}
					//
					if (ec.CurrentType.IsStruct && argument_list == null)
						return this;
				}

				base_ctor = ConstructorLookup (ec, type, ref argument_list, loc);
			}
	
			if (base_ctor != null && base_ctor.MemberDefinition == caller_builder.Spec.MemberDefinition) {
				ec.Report.Error (516, loc, "Constructor `{0}' cannot call itself",
					caller_builder.GetSignatureForError ());
			}

			return this;
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:55,代码来源:method.cs


示例20: DoResolve

		protected override Expression DoResolve (ResolveContext ec)
		{
			eclass = ExprClass.Value;

			// FIXME: Hack
			var caller_builder = (Constructor) ec.MemberContext;

			//
			// Spec mandates that constructor initializer will not have `this' access
			//
			using (ec.Set (ResolveContext.Options.BaseInitializer)) {
				if (argument_list != null) {
					bool dynamic;
					argument_list.Resolve (ec, out dynamic);

					// If actionscript, convert dynamic constructor arguments to type System.Object.
					if (dynamic && ec.FileType == SourceFileType.PlayScript) {
						var ctors = MemberCache.FindMembers (ec.CurrentType.BaseType, Constructor.ConstructorName, true);
						if (ctors != null) {
							if (argument_list.AsTryResolveDynamicArgs(ec, ctors)) {
								dynamic = false;
							}
						}
					}

					if (dynamic) {
						ec.Report.Error (1975, loc,
							"The constructor call cannot be dynamically dispatched within constructor initializer");

						return null;
					}
				}

				type = ec.CurrentType;
				if (this is ConstructorBaseInitializer) {
					if (ec.CurrentType.BaseType == null)
						return this;

					type = ec.CurrentType.BaseType;
					if (ec.CurrentType.IsStruct) {
						ec.Report.Error (522, loc,
							"`{0}': Struct constructors cannot call base constructors", caller_builder.GetSignatureForError ());
						return this;
					}
				} else {
					//
					// It is legal to have "this" initializers that take no arguments
					// in structs, they are just no-ops.
					//
					// struct D { public D (int a) : this () {}
					//
					if (ec.CurrentType.IsStruct && argument_list == null)
						return this;
				}

				base_ctor = ConstructorLookup (ec, type, ref argument_list, loc);
			}
	
			if (base_ctor != null && base_ctor.MemberDefinition == caller_builder.Spec.MemberDefinition) {
				ec.Report.Error (516, loc, "Constructor `{0}' cannot call itself",
					caller_builder.GetSignatureForError ());
			}

			return this;
		}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:65,代码来源:method.cs



注:本文中的Mono.CSharp.MethodSpec类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CSharp.Modifiers类代码示例发布时间:2022-05-26
下一篇:
C# CSharp.MethodGroupExpr类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap