当前位置: 首页>>代码示例>>C#>>正文


C# CSharp.TypeExpr类代码示例

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


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

示例1: Enum

 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);
 }
开发者ID:speier,项目名称:shake,代码行数:9,代码来源:enum.cs

示例2: ResolveBaseTypes

        protected override TypeExpr[] ResolveBaseTypes(out TypeExpr base_class)
        {
            var mtype = Iterator.OriginalIteratorType;
            if (Mutator != null)
                mtype = Mutator.Mutate (mtype);

            iterator_type_expr = new TypeExpression (mtype, Location);
            generic_args = new TypeArguments (iterator_type_expr);

            var list = new List<FullNamedExpression> ();
            if (Iterator.IsEnumerable) {
                enumerable_type = new TypeExpression (
                    TypeManager.ienumerable_type, Location);
                list.Add (enumerable_type);

                if (TypeManager.generic_ienumerable_type != null) {
                    generic_enumerable_type = new GenericTypeExpr (
                        TypeManager.generic_ienumerable_type,
                        generic_args, Location);
                    list.Add (generic_enumerable_type);
                }
            }

            enumerator_type = new TypeExpression (
                TypeManager.ienumerator_type, Location);
            list.Add (enumerator_type);

            list.Add (new TypeExpression (TypeManager.idisposable_type, Location));

            if (TypeManager.generic_ienumerator_type != null) {
                generic_enumerator_type = new GenericTypeExpr (
                    TypeManager.generic_ienumerator_type,
                    generic_args, Location);
                list.Add (generic_enumerator_type);
            }

            type_bases = list;

            return base.ResolveBaseTypes (out base_class);
        }
开发者ID:speier,项目名称:shake,代码行数:40,代码来源:iterators.cs

示例3: ResolveBaseTypes

		/// <summary>
		///   This function computes the Base class and also the
		///   list of interfaces that the class or struct @c implements.
		///   
		///   The return value is an array (might be null) of
		///   interfaces implemented (as Types).
		///   
		///   The @base_class argument is set to the base object or null
		///   if this is `System.Object'. 
		/// </summary>
		protected virtual TypeExpr[] ResolveBaseTypes (out TypeExpr base_class)
		{
			base_class = null;
			if (type_bases == null)
				return null;

			int count = type_bases.Count;
			TypeExpr [] ifaces = null;
			var base_context = new BaseContext (this);
			for (int i = 0, j = 0; i < count; i++){
				FullNamedExpression fne = type_bases [i];

				TypeExpr fne_resolved = fne.ResolveAsTypeTerminal (base_context, false);
				if (fne_resolved == null)
					continue;

				if (i == 0 && Kind == MemberKind.Class && !fne_resolved.Type.IsInterface) {
					if (fne_resolved.Type == InternalType.Dynamic) {
						Report.Error (1965, Location, "Class `{0}' cannot derive from the dynamic type",
							GetSignatureForError ());

						continue;
					}
					
					base_type = fne_resolved.Type;
					base_class = fne_resolved;
					continue;
				}

				if (ifaces == null)
					ifaces = new TypeExpr [count - i];

				if (fne_resolved.Type.IsInterface) {
					for (int ii = 0; ii < j; ++ii) {
						if (fne_resolved.Type == ifaces [ii].Type) {
							Report.Error (528, Location, "`{0}' is already listed in interface list",
								fne_resolved.GetSignatureForError ());
							break;
						}
					}

					if (Kind == MemberKind.Interface && !IsAccessibleAs (fne_resolved.Type)) {
						Report.Error (61, fne.Location,
							"Inconsistent accessibility: base interface `{0}' is less accessible than interface `{1}'",
							fne_resolved.GetSignatureForError (), GetSignatureForError ());
					}
				} else {
					Report.SymbolRelatedToPreviousError (fne_resolved.Type);
					if (Kind != MemberKind.Class) {
						Report.Error (527, fne.Location, "Type `{0}' in interface list is not an interface", fne_resolved.GetSignatureForError ());
					} else if (base_class != null)
						Report.Error (1721, fne.Location, "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')",
							GetSignatureForError (), base_class.GetSignatureForError (), fne_resolved.GetSignatureForError ());
					else {
						Report.Error (1722, fne.Location, "`{0}': Base class `{1}' must be specified as first",
							GetSignatureForError (), fne_resolved.GetSignatureForError ());
					}
				}

				ifaces [j++] = fne_resolved;
			}

			return ifaces;
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:74,代码来源:class.cs

示例4: AnonymousMethodMethod

			public AnonymousMethodMethod (DeclSpace parent, AnonymousExpression am, AnonymousMethodStorey storey,
							  GenericMethod generic, TypeExpr return_type,
							  Modifiers mod, string real_name, MemberName name,
							  ParametersCompiled parameters)
				: base (parent, generic, return_type, mod | Modifiers.COMPILER_GENERATED,
						name, parameters, null)
			{
				this.AnonymousMethod = am;
				this.Storey = storey;
				this.RealName = real_name;

				Parent.PartialContainer.AddMethod (this);
				Block = new ToplevelBlock (am.block, parameters);
			}
开发者ID:nzaugg,项目名称:mono,代码行数:14,代码来源:anonymous.cs

示例5: Enum

		public Enum (NamespaceContainer ns, TypeContainer parent, TypeExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
			: base (ns, 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);
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:8,代码来源:enum.cs

示例6: ResolveTypes

		/// <summary>
		///   Resolve the constraints into actual types.
		/// </summary>
		public bool ResolveTypes (IResolveContext ec)
		{
			if (resolved_types)
				return true;

			resolved_types = true;

			foreach (object obj in constraints) {
				GenericTypeExpr cexpr = obj as GenericTypeExpr;
				if (cexpr == null)
					continue;

				if (!cexpr.CheckConstraints (ec))
					return false;
			}

			if (type_param_constraints.Count != 0) {
				ArrayList seen = new ArrayList ();
				TypeExpr prev_constraint = class_constraint;
				foreach (TypeParameterExpr expr in type_param_constraints) {
					if (!CheckTypeParameterConstraints (expr.TypeParameter, ref prev_constraint, seen))
						return false;
					seen.Clear ();
				}
			}

			for (int i = 0; i < iface_constraints.Count; ++i) {
				TypeExpr iface_constraint = (TypeExpr) iface_constraints [i];
				iface_constraint = iface_constraint.ResolveAsTypeTerminal (ec, false);
				if (iface_constraint == null)
					return false;
				iface_constraints [i] = iface_constraint;
			}

			if (class_constraint != null) {
				class_constraint = class_constraint.ResolveAsTypeTerminal (ec, false);
				if (class_constraint == null)
					return false;
			}

			return true;
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:45,代码来源:generic.cs

示例7: CheckTypeParameterConstraints

		bool CheckTypeParameterConstraints (TypeParameter tparam, ref TypeExpr prevConstraint, ArrayList seen)
		{
			seen.Add (tparam);

			Constraints constraints = tparam.Constraints;
			if (constraints == null)
				return true;

			if (constraints.HasValueTypeConstraint) {
				Report.Error (456, loc,
					"Type parameter `{0}' has the `struct' constraint, so it cannot be used as a constraint for `{1}'",
					tparam.Name, name);
				return false;
			}

			//
			//  Checks whether there are no conflicts between type parameter constraints
			//
			//   class Foo<T, U>
			//      where T : A
			//      where U : A, B	// A and B are not convertible
			//
			if (constraints.HasClassConstraint) {
				if (prevConstraint != null) {
					Type t2 = constraints.ClassConstraint;
					TypeExpr e2 = constraints.class_constraint;

					if (!Convert.ImplicitReferenceConversionExists (prevConstraint, t2) &&
						!Convert.ImplicitReferenceConversionExists (e2, prevConstraint.Type)) {
						Report.Error (455, loc,
							"Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'",
							name, TypeManager.CSharpName (prevConstraint.Type), TypeManager.CSharpName (t2));
						return false;
					}
				}

				prevConstraint = constraints.class_constraint;
			}

			if (constraints.type_param_constraints == null)
				return true;

			foreach (TypeParameterExpr expr in constraints.type_param_constraints) {
				if (seen.Contains (expr.TypeParameter)) {
					Report.Error (454, loc, "Circular constraint " +
						      "dependency involving `{0}' and `{1}'",
						      tparam.Name, expr.GetSignatureForError ());
					return false;
				}

				if (!CheckTypeParameterConstraints (expr.TypeParameter, ref prevConstraint, seen))
					return false;
			}

			return true;
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:56,代码来源:generic.cs

示例8: Resolve

		/// <summary>
		///   Resolve the constraints - but only resolve things into Expression's, not
		///   into actual types.
		/// </summary>
		public bool Resolve (IResolveContext ec)
		{
			if (resolved)
				return true;

			iface_constraints = new ArrayList (2);	// TODO: Too expensive allocation
			type_param_constraints = new ArrayList ();

			foreach (object obj in constraints) {
				if (HasConstructorConstraint) {
					Report.Error (401, loc,
						      "The new() constraint must be the last constraint specified");
					return false;
				}

				if (obj is SpecialConstraint) {
					SpecialConstraint sc = (SpecialConstraint) obj;

					if (sc == SpecialConstraint.Constructor) {
						if (!HasValueTypeConstraint) {
							attrs |= GenericParameterAttributes.DefaultConstructorConstraint;
							continue;
						}

						Report.Error (451, loc, "The `new()' constraint " +
							"cannot be used with the `struct' constraint");
						return false;
					}

					if ((num_constraints > 0) || HasReferenceTypeConstraint || HasValueTypeConstraint) {
						Report.Error (449, loc, "The `class' or `struct' " +
							      "constraint must be the first constraint specified");
						return false;
					}

					if (sc == SpecialConstraint.ReferenceType)
						attrs |= GenericParameterAttributes.ReferenceTypeConstraint;
					else
						attrs |= GenericParameterAttributes.NotNullableValueTypeConstraint;
					continue;
				}

				int errors = Report.Errors;
				FullNamedExpression fn = ((Expression) obj).ResolveAsTypeStep (ec, false);

				if (fn == null) {
					if (errors != Report.Errors)
						return false;

					NamespaceEntry.Error_NamespaceNotFound (loc, ((Expression)obj).GetSignatureForError ());
					return false;
				}

				TypeExpr expr;
				GenericTypeExpr cexpr = fn as GenericTypeExpr;
				if (cexpr != null) {
					expr = cexpr.ResolveAsBaseTerminal (ec, false);
				} else
					expr = ((Expression) obj).ResolveAsTypeTerminal (ec, false);

				if ((expr == null) || (expr.Type == null))
					return false;

				if (!ec.GenericDeclContainer.IsAccessibleAs (fn.Type)) {
					Report.SymbolRelatedToPreviousError (fn.Type);
					Report.Error (703, loc,
						"Inconsistent accessibility: constraint type `{0}' is less accessible than `{1}'",
						fn.GetSignatureForError (), ec.GenericDeclContainer.GetSignatureForError ());
					return false;
				}

				TypeParameterExpr texpr = expr as TypeParameterExpr;
				if (texpr != null)
					type_param_constraints.Add (expr);
				else if (expr.IsInterface)
					iface_constraints.Add (expr);
				else if (class_constraint != null || iface_constraints.Count != 0) {
					Report.Error (406, loc,
						"The class type constraint `{0}' must be listed before any other constraints. Consider moving type constraint to the beginning of the constraint list",
						expr.GetSignatureForError ());
					return false;
				} else if (HasReferenceTypeConstraint || HasValueTypeConstraint) {
					Report.Error (450, loc, "`{0}': cannot specify both " +
						      "a constraint class and the `class' " +
						      "or `struct' constraint", expr.GetSignatureForError ());
					return false;
				} else
					class_constraint = expr;

				num_constraints++;
			}

			ArrayList list = new ArrayList ();
			foreach (TypeExpr iface_constraint in iface_constraints) {
				foreach (Type type in list) {
					if (!type.Equals (iface_constraint.Type))
//.........这里部分代码省略.........
开发者ID:lewurm,项目名称:benchmarker,代码行数:101,代码来源:generic.cs

示例9: GetNormalPartialBases

        TypeExpr[] GetNormalPartialBases(ref TypeExpr base_class)
        {
            var ifaces = new List<TypeExpr> (0);
            if (iface_exprs != null)
                ifaces.AddRange (iface_exprs);

            foreach (TypeContainer part in partial_parts) {
                TypeExpr new_base_class;
                TypeExpr[] new_ifaces = part.ResolveBaseTypes (out new_base_class);
                if (new_base_class != TypeManager.system_object_expr) {
                    if (base_class == TypeManager.system_object_expr)
                        base_class = new_base_class;
                    else {
                        if (new_base_class != null && !TypeManager.IsEqual (new_base_class.Type, base_class.Type)) {
                            Report.SymbolRelatedToPreviousError (base_class.Location, "");
                            Report.Error (263, part.Location,
                                "Partial declarations of `{0}' must not specify different base classes",
                                part.GetSignatureForError ());

                            return null;
                        }
                    }
                }

                if (new_ifaces == null)
                    continue;

                foreach (TypeExpr iface in new_ifaces) {
                    if (ifaces.Contains (iface))
                        continue;

                    ifaces.Add (iface);
                }
            }

            if (ifaces.Count == 0)
                return null;

            return ifaces.ToArray ();
        }
开发者ID:speier,项目名称:shake,代码行数:40,代码来源:class.cs

示例10: DefineBaseTypes

        bool DefineBaseTypes()
        {
            iface_exprs = ResolveBaseTypes (out base_type);
            if (partial_parts != null) {
                iface_exprs = GetNormalPartialBases (ref base_type);
            }

            var cycle = CheckRecursiveDefinition (this);
            if (cycle != null) {
                Report.SymbolRelatedToPreviousError (cycle);
                if (this is Interface) {
                    Report.Error (529, Location,
                        "Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'",
                        GetSignatureForError (), cycle.GetSignatureForError ());
                } else {
                    Report.Error (146, Location,
                        "Circular base class dependency involving `{0}' and `{1}'",
                        GetSignatureForError (), cycle.GetSignatureForError ());
                }

                base_type = null;
            }

            if (iface_exprs != null) {
                foreach (TypeExpr iface in iface_exprs) {
                    // Prevents a crash, the interface might not have been resolved: 442144
                    if (iface == null)
                        continue;

                    var iface_type = iface.Type;

                    if (!spec.AddInterface (iface_type))
                        continue;

                    if (iface_type.IsGeneric && spec.Interfaces != null) {
                        foreach (var prev_iface in iface_exprs) {
                            if (prev_iface == iface)
                                break;

                            if (!TypeSpecComparer.Unify.IsEqual (iface_type, prev_iface.Type))
                                continue;

                            Report.Error (695, Location,
                                "`{0}' cannot implement both `{1}' and `{2}' because they may unify for some type parameter substitutions",
                                GetSignatureForError (), prev_iface.GetSignatureForError (), iface_type.GetSignatureForError ());
                        }
                    }

                    TypeBuilder.AddInterfaceImplementation (iface_type.GetMetaInfo ());

                    // Ensure the base is always setup
                    var compiled_iface = iface_type.MemberDefinition as Interface;
                    if (compiled_iface != null) {
                        // TODO: Need DefineBaseType only
                        compiled_iface.DefineType ();
                    }

                    if (iface_type.Interfaces != null) {
                        var base_ifaces = new List<TypeSpec> (iface_type.Interfaces);
                        for (int i = 0; i < base_ifaces.Count; ++i) {
                            var ii_iface_type = base_ifaces[i];
                            if (spec.AddInterface (ii_iface_type)) {
                                TypeBuilder.AddInterfaceImplementation (ii_iface_type.GetMetaInfo ());

                                if (ii_iface_type.Interfaces != null)
                                    base_ifaces.AddRange (ii_iface_type.Interfaces);
                            }
                        }
                    }
                }
            }

            if (Kind == MemberKind.Interface) {
                spec.BaseType = TypeManager.object_type;
                return true;
            }

            TypeSpec base_ts;
            if (base_type != null)
                base_ts = base_type.Type;
            else if (spec.IsStruct)
                base_ts = TypeManager.value_type;
            else if (spec.IsEnum)
                base_ts = TypeManager.enum_type;
            else if (spec.IsDelegate)
                base_ts = TypeManager.multicast_delegate_type;
            else
                base_ts = null;

            if (base_ts != null) {
                spec.BaseType = base_ts;

                // Set base type after type creation
                TypeBuilder.SetParent (base_ts.GetMetaInfo ());
            }

            return true;
        }
开发者ID:speier,项目名称:shake,代码行数:98,代码来源:class.cs

示例11: ResolveBaseTypes

 protected override TypeExpr[] ResolveBaseTypes(out TypeExpr base_class)
 {
     TypeExpr[] ifaces = base.ResolveBaseTypes (out base_class);
     base_class = TypeManager.system_valuetype_expr;
     return ifaces;
 }
开发者ID:speier,项目名称:shake,代码行数:6,代码来源:class.cs

示例12: AddTemporaryVariable

		public LocalInfo AddTemporaryVariable (TypeExpr te, Location loc)
		{
			Report.Debug (64, "ADD TEMPORARY", this, Toplevel, loc);

			if (temporary_variables == null)
				temporary_variables = new List<LocalInfo> ();

			int id = ++next_temp_id;
			string name = "$s_" + id.ToString ();

			LocalInfo li = new LocalInfo (te, name, this, loc);
			li.CompilerGenerated = true;
			temporary_variables.Add (li);
			return li;
		}
开发者ID:tgiphil,项目名称:mono,代码行数:15,代码来源:statement.cs

示例13: ResolveBaseTypes

		protected override TypeExpr[] ResolveBaseTypes (out TypeExpr base_class)
		{
			base_type = TypeManager.enum_type;
			base_class = base_type_expr;
			return null;
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:6,代码来源:enum.cs

示例14: ResolveBaseTypes

		protected override TypeExpr [] ResolveBaseTypes (out TypeExpr base_class)
		{
			var mtype = Iterator.OriginalIteratorType;
			if (Mutator != null)
				mtype = Mutator.Mutate (mtype);

			iterator_type_expr = new TypeExpression (mtype, Location);
			generic_args = new TypeArguments (iterator_type_expr);

			var list = new List<FullNamedExpression> ();
			if (Iterator.IsEnumerable) {
				enumerable_type = new TypeExpression (Compiler.BuiltinTypes.IEnumerable, Location);
				list.Add (enumerable_type);

				if (Module.PredefinedTypes.IEnumerableGeneric.Define ()) {
					generic_enumerable_type = new GenericTypeExpr (Module.PredefinedTypes.IEnumerableGeneric.TypeSpec, generic_args, Location);
					list.Add (generic_enumerable_type);
				}
			}

			enumerator_type = new TypeExpression (Compiler.BuiltinTypes.IEnumerator, Location);
			list.Add (enumerator_type);

			list.Add (new TypeExpression (Compiler.BuiltinTypes.IDisposable, Location));

			var ienumerator_generic = Module.PredefinedTypes.IEnumeratorGeneric;
			if (ienumerator_generic.Define ()) {
				generic_enumerator_type = new GenericTypeExpr (ienumerator_generic.TypeSpec, generic_args, Location);
				list.Add (generic_enumerator_type);
			}

			type_bases = list;

			return base.ResolveBaseTypes (out base_class);
		}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:35,代码来源:iterators.cs

示例15: ResolveParameterExpressionType

		//
		// System.Linq.Expressions.ParameterExpression type
		//
		public static TypeExpr ResolveParameterExpressionType (IMemberContext ec, Location location)
		{
			if (parameter_expr_tree_type != null)
				return parameter_expr_tree_type;

			TypeSpec p_type = TypeManager.parameter_expression_type;
			if (p_type == null) {
				p_type = TypeManager.CoreLookupType (ec.Compiler, "System.Linq.Expressions", "ParameterExpression", MemberKind.Class, true);
				TypeManager.parameter_expression_type = p_type;
			}

			parameter_expr_tree_type = new TypeExpression (p_type, location).
				ResolveAsTypeTerminal (ec, false);

			return parameter_expr_tree_type;
		}
开发者ID:Ein,项目名称:monodevelop,代码行数:19,代码来源:parameter.cs


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