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


C# CSharp.DefaultValueExpression类代码示例

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


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

示例1: Inflate

		public AParametersCollection Inflate (TypeParameterInflator inflator)
		{
			TypeSpec[] inflated_types = null;
			bool default_value = false;

			for (int i = 0; i < Count; ++i) {
				var inflated_param = inflator.Inflate (types[i]);
				if (inflated_types == null) {
					if (inflated_param == types[i])
						continue;

					default_value |= FixedParameters[i].HasDefaultValue;
					inflated_types = new TypeSpec[types.Length];
					Array.Copy (types, inflated_types, types.Length);
				} else {
					if (inflated_param == types[i])
						continue;

					default_value |= FixedParameters[i].HasDefaultValue;
				}

				inflated_types[i] = inflated_param;
			}

			if (inflated_types == null)
				return this;

			var clone = (AParametersCollection) MemberwiseClone ();
			clone.types = inflated_types;

			//
			// Default expression is original expression from the parameter
			// declaration context which can be of nested enum in generic class type.
			// In such case we end up with expression type of G<T>.E and e.g. parameter
			// type of G<int>.E and conversion would fail without inflate in this
			// context.
			//
			if (default_value) {
				clone.parameters = new IParameterData[Count];
				for (int i = 0; i < Count; ++i) {
					var fp = FixedParameters[i];
					clone.FixedParameters[i] = fp;

					if (!fp.HasDefaultValue)
						continue;

					var expr = fp.DefaultValue;

					if (inflated_types[i] == expr.Type)
						continue;

					var c = expr as Constant;
					if (c != null) {
						//
						// It may fail we are inflating before type validation is done
						//
						c = Constant.ExtractConstantFromValue (inflated_types[i], c.GetValue (), expr.Location);
						if (c == null)
							expr = new DefaultValueExpression (new TypeExpression (inflated_types[i], expr.Location), expr.Location);
						else
							expr = c;
					} else if (expr is DefaultValueExpression)
						expr = new DefaultValueExpression (new TypeExpression (inflated_types[i], expr.Location), expr.Location);

					clone.FixedParameters[i] = new ParameterData (fp.Name, fp.ModFlags, expr);
				}
			}

			return clone;
		}
开发者ID:bl8,项目名称:mono,代码行数:70,代码来源:parameter.cs

示例2: Visit

			public override object Visit(Mono.CSharp.DefaultValueExpression defaultValueExpression)
			{
				var result = new DefaultValueExpression();
				result.AddChild(new CSharpTokenNode(Convert(defaultValueExpression.Location), DefaultValueExpression.DefaultKeywordRole), DefaultValueExpression.DefaultKeywordRole);
				var location = LocationsBag.GetLocations(defaultValueExpression);
				if (location != null)
					result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
				result.AddChild(ConvertToType(defaultValueExpression.Expr), Roles.Type);
				if (location != null && location.Count > 1)
					result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:12,代码来源:CSharpParser.cs

示例3: case_556

void case_556()
#line 4028 "cs-parser.jay"
{
		if (lang_version < LanguageVersion.ISO_2)
			FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression");

		yyVal = new DefaultValueExpression ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:9,代码来源:cs-parser.cs

示例4: CreateParameters

		//
		// Imports System.Reflection parameters
		//
		AParametersCollection CreateParameters (TypeSpec parent, ParameterInfo[] pi, MethodBase method)
		{
			int varargs = method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0 ? 1 : 0;

			if (pi.Length == 0 && varargs == 0)
				return ParametersCompiled.EmptyReadOnlyParameters;

			TypeSpec[] types = new TypeSpec[pi.Length + varargs];
			IParameterData[] par = new IParameterData[pi.Length + varargs];
			bool is_params = false;
			for (int i = 0; i < pi.Length; i++) {
				ParameterInfo p = pi[i];
				Parameter.Modifier mod = 0;
				Expression default_value = null;
				if (p.ParameterType.IsByRef) {
					if ((p.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
						mod = Parameter.Modifier.OUT;
					else
						mod = Parameter.Modifier.REF;

					//
					// Strip reference wrapping
					//
					var el = p.ParameterType.GetElementType ();
					types[i] = ImportType (el, new DynamicTypeReader (p));	// TODO: 1-based positio to be csc compatible
				} else if (i == 0 && method.IsStatic && parent.IsStatic && parent.MemberDefinition.DeclaringAssembly.HasExtensionMethod &&
					HasAttribute (CustomAttributeData.GetCustomAttributes (method), "ExtensionAttribute", CompilerServicesNamespace)) {
					mod = Parameter.Modifier.This;
					types[i] = ImportType (p.ParameterType);
				} else {
					types[i] = ImportType (p.ParameterType, new DynamicTypeReader (p));

					if (i >= pi.Length - 2 && types[i] is ArrayContainer) {
						if (HasAttribute (CustomAttributeData.GetCustomAttributes (p), "ParamArrayAttribute", "System")) {
							mod = Parameter.Modifier.PARAMS;
							is_params = true;
						}
					}

					if (!is_params && p.IsOptional) {
						object value = p.RawDefaultValue;
						var ptype = types[i];
						if ((p.Attributes & ParameterAttributes.HasDefault) != 0 && ptype.Kind != MemberKind.TypeParameter && (value != null || TypeSpec.IsReferenceType (ptype))) {
							if (value == null) {
								default_value = Constant.CreateConstant (ptype, null, Location.Null);
							} else {
								default_value = ImportParameterConstant (value);

								if (ptype.IsEnum) {
									default_value = new EnumConstant ((Constant) default_value, ptype);
								}
							}
						} else if (value == Missing.Value) {
							default_value = EmptyExpression.MissingValue;
						} else if (value == null) {
							default_value = new DefaultValueExpression (new TypeExpression (ptype, Location.Null), Location.Null);
						} else if (ptype.BuiltinType == BuiltinTypeSpec.Type.Decimal) {
							default_value = ImportParameterConstant (value);
						}
					}
				}

				par[i] = new ParameterData (p.Name, mod, default_value);
			}

			if (varargs != 0) {
				par[par.Length - 1] = new ArglistParameter (Location.Null);
				types[types.Length - 1] = InternalType.Arglist;
			}

			return method != null ?
				new ParametersImported (par, types, varargs != 0, is_params) :
				new ParametersImported (par, types, is_params);
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:77,代码来源:import.cs

示例5: case_551

void case_551()
#line 3780 "cs-parser.jay"
{
		if (RootContext.Version < LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression");

		yyVal = new DefaultValueExpression ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
开发者ID:Ein,项目名称:monodevelop,代码行数:9,代码来源:cs-parser.cs

示例6: Visit

		public virtual object Visit (DefaultValueExpression defaultValueExpression)
		{
			return null;
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs

示例7: IsApplicable


//.........这里部分代码省略.........

                            // When using parameters which should not be available to the user
                            if (index >= param_count)
                                break;

                            if (!arg_moved) {
                                arguments.MarkReorderedArgument (na);
                                arg_moved = true;
                            }

                            Argument temp = arguments[index];
                            arguments[index] = arguments[i];
                            arguments[i] = temp;

                            if (temp == null)
                                break;
                        }
                    }
                } else {
                    arg_count = arguments.Count;
                }
            } else if (arguments != null) {
                arg_count = arguments.Count;
            }

            //
            // 1. Handle generic method using type arguments when specified or type inference
            //
            if (candidate.IsGeneric) {
                if (type_arguments != null) {
                    var g_args_count = candidate.Arity;
                    if (g_args_count != type_arguments.Count)
                        return int.MaxValue - 20000 + System.Math.Abs (type_arguments.Count - g_args_count);

                    method = candidate.MakeGenericMethod (type_arguments.Arguments);
                    candidate = method;
                    pd = candidate.Parameters;
                } else {
                    int score = TypeManager.InferTypeArguments (ec, arguments, ref candidate);
                    if (score != 0)
                        return score - 20000;

                    pd = candidate.Parameters;
                }
            } else {
                if (type_arguments != null)
                    return int.MaxValue - 15000;
            }

            //
            // 2. Each argument has to be implicitly convertible to method parameter
            //
            method = candidate;
            Parameter.Modifier p_mod = 0;
            TypeSpec pt = null;
            for (int i = 0; i < arg_count; i++) {
                Argument a = arguments [i];
                if (a == null) {
                    if (!pd.FixedParameters [i].HasDefaultValue)
                        throw new InternalErrorException ();

                    Expression e = pd.FixedParameters [i].DefaultValue as Constant;
                    if (e == null)
                        e = new DefaultValueExpression (new TypeExpression (pd.Types [i], loc), loc).Resolve (ec);

                    arguments [i] = new Argument (e, Argument.AType.Default);
                    continue;
                }

                if (p_mod != Parameter.Modifier.PARAMS) {
                    p_mod = pd.FixedParameters [i].ModFlags & ~(Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK);
                    pt = pd.Types [i];
                } else {
                    params_expanded_form = true;
                }

                Parameter.Modifier a_mod = a.Modifier & ~(Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK);
                int score = 1;
                if (!params_expanded_form)
                    score = IsArgumentCompatible (ec, a_mod, a, p_mod & ~Parameter.Modifier.PARAMS, pt);

                if (score != 0 && (p_mod & Parameter.Modifier.PARAMS) != 0 && delegate_type == null) {
                    // It can be applicable in expanded form
                    score = IsArgumentCompatible (ec, a_mod, a, 0, TypeManager.GetElementType (pt));
                    if (score == 0)
                        params_expanded_form = true;
                }

                if (score != 0) {
                    if (params_expanded_form)
                        ++score;
                    return (arg_count - i) * 2 + score;
                }
            }

            if (arg_count != param_count)
                params_expanded_form = true;

            return 0;
        }
开发者ID:speier,项目名称:shake,代码行数:101,代码来源:ecore.cs

示例8: yyparse


//.........这里部分代码省略.........
	  }
  break;
case 543:
#line 3762 "cs-parser.jay"
  {
		yyVal = end_anonymous ((ToplevelBlock) yyVals[0+yyTop]);
	}
  break;
case 544:
#line 3769 "cs-parser.jay"
  {
		yyVal = ParametersCompiled.Undefined;
	  }
  break;
case 546:
#line 3777 "cs-parser.jay"
  {
	  	valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
	  }
  break;
case 547:
#line 3781 "cs-parser.jay"
  {
		valid_param_mod = 0;
	  	yyVal = yyVals[-1+yyTop];
	  }
  break;
case 548:
#line 3789 "cs-parser.jay"
  {
		if (RootContext.Version < LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression");

		yyVal = new DefaultValueExpression ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 550:
#line 3800 "cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 551:
#line 3804 "cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 553:
#line 3812 "cs-parser.jay"
  {
		yyVal = new Cast ((FullNamedExpression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 554:
#line 3816 "cs-parser.jay"
  {
		yyVal = new Cast ((FullNamedExpression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 556:
#line 3828 "cs-parser.jay"
  { 
	  	yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs

示例9: DefaultValueNullLiteral

			public DefaultValueNullLiteral (DefaultValueExpression expr)
				: base (expr.type, expr.loc)
			{
			}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:4,代码来源:expression.cs

示例10: Visit

 public override object Visit(Mono.CSharp.DefaultValueExpression defaultValueExpression)
 {
     var result = new DefaultValueExpression ();
     result.AddChild (new CSharpTokenNode (Convert (defaultValueExpression.Location), "default".Length), CastExpression.Roles.Keyword);
     var location = LocationsBag.GetLocations (defaultValueExpression);
     if (location != null)
         result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), CastExpression.Roles.LPar);
     result.AddChild ((DomNode)defaultValueExpression.Expr.Accept (this), CastExpression.Roles.ReturnType);
     if (location != null)
         result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CastExpression.Roles.RPar);
     return result;
 }
开发者ID:infodoc,项目名称:NRefactory,代码行数:12,代码来源:CSharpParser.cs

示例11: yyparse


//.........这里部分代码省略.........
	  }
  break;
case 562:
#line 4111 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]);
	  }
  break;
case 563:
#line 4118 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		yyVal = ParametersCompiled.Undefined;
	  }
  break;
case 565:
#line 4126 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
	  	valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
	  }
  break;
case 566:
#line 4130 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		valid_param_mod = 0;
	  	yyVal = yyVals[-1+yyTop];
	  }
  break;
case 567:
#line 4138 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		if (lang_version < LanguageVersion.ISO_2)
			FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression");

		yyVal = new DefaultValueExpression ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 569:
#line 4150 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 570:
#line 4154 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 571:
#line 4158 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		yyVal = new Cast ((FullNamedExpression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 572:
#line 4163 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		if (!async_block) {
			report.Error (1992, GetLocation (yyVals[-1+yyTop]),
				"The `await' operator can only be used when its containing method or lambda expression is marked with the `async' modifier");
		} else {
			current_block.ParametersBlock.IsAsync = true;
		}
		
开发者ID:runefs,项目名称:Marvin,代码行数:66,代码来源:cs-parser.cs

示例12: CreateParameters

		//
		// Imports System.Reflection parameters
		//
		AParametersCollection CreateParameters (TypeSpec parent, ParameterInfo[] pi, MethodBase method)
		{
			int varargs = method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0 ? 1 : 0;

			if (pi.Length == 0 && varargs == 0)
				return ParametersCompiled.EmptyReadOnlyParameters;

			TypeSpec[] types = new TypeSpec[pi.Length + varargs];
			IParameterData[] par = new IParameterData[pi.Length + varargs];
			bool is_params = false;
			for (int i = 0; i < pi.Length; i++) {
				ParameterInfo p = pi[i];
				Parameter.Modifier mod = 0;
				Expression default_value = null;
				if (p.ParameterType.IsByRef) {
					if ((p.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
						mod = Parameter.Modifier.OUT;
					else
						mod = Parameter.Modifier.REF;

					//
					// Strip reference wrapping
					//
					var el = p.ParameterType.GetElementType ();
					types[i] = ImportType (el, p, 0);	// TODO: 1 to be csc compatible
				} else if (i == 0 && method.IsStatic && parent.IsStatic && parent.MemberDefinition.DeclaringAssembly.HasExtensionMethod &&
					HasExtensionAttribute (CustomAttributeData.GetCustomAttributes (method)) != null) {
					mod = Parameter.Modifier.This;
					types[i] = ImportType (p.ParameterType);
				} else {
					types[i] = ImportType (p.ParameterType, p, 0);

					if (i >= pi.Length - 2 && types[i] is ArrayContainer) {
						if (HasAttribute (CustomAttributeData.GetCustomAttributes (p), typeof (ParamArrayAttribute))) {
							mod = Parameter.Modifier.PARAMS;
							is_params = true;
						}
					}

					if (!is_params && p.IsOptional) {
						object value = p.RawDefaultValue;
						var ptype = types[i];
						if (((p.Attributes & ParameterAttributes.HasDefault) != 0 && ptype.Kind != MemberKind.TypeParameter)) {
							//
							// Use value type as int constant can be used for object parameter type
							//
							var dtype = value == null ? ptype : ImportType (value.GetType ());
							default_value = Constant.CreateConstant (null, dtype, value, Location.Null);
						} else if (value == Missing.Value) {
							default_value = EmptyExpression.MissingValue;
						} else {
							if (ptype == TypeManager.decimal_type)
								default_value = ReadDecimalConstant (CustomAttributeData.GetCustomAttributes (p));

							if (default_value == null)
								default_value = new DefaultValueExpression (new TypeExpression (ptype, Location.Null), Location.Null);
						}
					}
				}

				par[i] = new ParameterData (p.Name, mod, default_value);
			}

			if (varargs != 0) {
				par[par.Length - 1] = new ArglistParameter (Location.Null);
				types[types.Length - 1] = InternalType.Arglist;
			}

			return method != null ?
				new ParametersImported (par, types, varargs != 0, is_params) :
				new ParametersImported (par, types, is_params);
		}
开发者ID:davidwaters,项目名称:mono,代码行数:75,代码来源:import.cs

示例13: case_549

void case_549()
#line 3747 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
		if (lang_version < LanguageVersion.ISO_2)
			FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression");

		yyVal = new DefaultValueExpression ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:9,代码来源:cs-parser.cs


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