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


C# CodeExpression.Last方法代码示例

本文整理汇总了C#中System.CodeDom.CodeExpression.Last方法的典型用法代码示例。如果您正苦于以下问题:C# CodeExpression.Last方法的具体用法?C# CodeExpression.Last怎么用?C# CodeExpression.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.CodeDom.CodeExpression的用法示例。


在下文中一共展示了CodeExpression.Last方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateSpecialNameCall

		private void GenerateSpecialNameCall(Table table, HardwireCodeGenerationContext generator, bool isVoid, bool isCtor, bool isStatic, bool isExtension, CodeExpression[] arguments, CodeExpression paramThis, string declaringType, string specialName, CodeStatementCollection coll)
		{
			ReflectionSpecialName special = new ReflectionSpecialName(specialName);
			CodeExpression exp = null;
			CodeStatement stat = null;

			switch (special.Type)
			{
				case ReflectionSpecialNameType.IndexGetter:
					if (isStatic)
						EmitInvalid(generator, coll, "Static indexers are not supported by hardwired descriptors.");
					else
						exp = new CodeIndexerExpression(paramThis, arguments);
					break;
				case ReflectionSpecialNameType.IndexSetter:
					if (isStatic)
						EmitInvalid(generator, coll, "Static indexers are not supported by hardwired descriptors.");
					else
					{
						coll.Add(new CodeVariableDeclarationStatement(declaringType, "tmp", paramThis));

						stat = new CodeAssignStatement(new CodeIndexerExpression(new CodeVariableReferenceExpression("tmp"),
							arguments.Take(arguments.Length - 1).ToArray()), arguments.Last());
					}
					break;
				case ReflectionSpecialNameType.ImplicitCast:
				case ReflectionSpecialNameType.ExplicitCast:
					exp = paramThis;
					break;
				case ReflectionSpecialNameType.OperatorTrue:
					GenerateBooleanOperator(paramThis, coll, true);
					break;
				case ReflectionSpecialNameType.OperatorFalse:
					generator.Minor("'false' operator is implemented in terms of 'true' operator.");
					GenerateBooleanOperator(paramThis, coll, false);
					break;
				case ReflectionSpecialNameType.PropertyGetter:
					exp = new CodePropertyReferenceExpression(paramThis, special.Argument);
					break;
				case ReflectionSpecialNameType.PropertySetter:
					{
						if (isStatic)
						{
							var memberExp = new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(declaringType), special.Argument);

							coll.Add(new CodeAssignStatement(memberExp, arguments[0]));
						}
						else
						{
							coll.Add(new CodeVariableDeclarationStatement(declaringType, "tmp", paramThis));

							var memberExp = new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("tmp"), special.Argument);

							coll.Add(new CodeAssignStatement(memberExp, arguments[0]));
						}
						coll.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null)));
					}
					break;
				case ReflectionSpecialNameType.OperatorAdd:
					exp = BinaryOperator(CodeBinaryOperatorType.Add, paramThis, arguments);
					break;
				case ReflectionSpecialNameType.OperatorAnd:
					exp = BinaryOperator(CodeBinaryOperatorType.BitwiseAnd, paramThis, arguments);
					break;
				case ReflectionSpecialNameType.OperatorOr:
					exp = BinaryOperator(CodeBinaryOperatorType.BitwiseOr, paramThis, arguments);
					break;
				case ReflectionSpecialNameType.OperatorDec:
					exp = generator.TargetLanguage.UnaryDecrement(arguments[0]);
					if (exp == null) EmitInvalid(generator, coll, string.Format("Language {0} does not support decrement operators.", generator.TargetLanguage.Name));
					break;
				case ReflectionSpecialNameType.OperatorDiv:
					exp = BinaryOperator(CodeBinaryOperatorType.Divide, paramThis, arguments);
					break;
				case ReflectionSpecialNameType.OperatorEq:
					exp = BinaryOperator(CodeBinaryOperatorType.ValueEquality, paramThis, arguments);
					break;
				case ReflectionSpecialNameType.OperatorXor:
					exp = generator.TargetLanguage.BinaryXor(arguments[0], arguments[1]);
					if (exp == null) EmitInvalid(generator, coll, string.Format("Language {0} does not support XOR operators.", generator.TargetLanguage.Name));
					break;
				case ReflectionSpecialNameType.OperatorGt:
					exp = BinaryOperator(CodeBinaryOperatorType.GreaterThan, paramThis, arguments);
					break;
				case ReflectionSpecialNameType.OperatorGte:
					exp = BinaryOperator(CodeBinaryOperatorType.GreaterThanOrEqual, paramThis, arguments);
					break;
				case ReflectionSpecialNameType.OperatorInc:
					exp = generator.TargetLanguage.UnaryIncrement(arguments[0]);
					if (exp == null) EmitInvalid(generator, coll, string.Format("Language {0} does not support increment operators.", generator.TargetLanguage.Name));
					break;
				case ReflectionSpecialNameType.OperatorNeq:
					exp = BinaryOperator(CodeBinaryOperatorType.IdentityInequality, paramThis, arguments);
					break;
				case ReflectionSpecialNameType.OperatorLt:
					exp = BinaryOperator(CodeBinaryOperatorType.LessThan, paramThis, arguments);
					break;
				case ReflectionSpecialNameType.OperatorLte:
					exp = BinaryOperator(CodeBinaryOperatorType.LessThanOrEqual, paramThis, arguments);
					break;
//.........这里部分代码省略.........
开发者ID:InfectedBytes,项目名称:moonsharp,代码行数:101,代码来源:MethodMemberDescriptorGenerator.cs


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