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


C# Operator.ToString方法代码示例

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


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

示例1: OperName

		//
		// Returns a stringified representation of the Operator
		//
		public static string OperName (Operator oper)
		{
			switch (oper) {
			case Operator.UnaryPlus:
				return "+";
			case Operator.UnaryNegation:
				return "-";
			case Operator.LogicalNot:
				return "!";
			case Operator.OnesComplement:
				return "~";
			case Operator.AddressOf:
				return "&";
			}

			throw new NotImplementedException (oper.ToString ());
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:20,代码来源:expression.cs

示例2: EmitOperatorOpcode


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

			case Operator.Addition:
				if (ec.HasSet (EmitContext.Options.CheckedScope)) {
					if (l == TypeManager.int32_type || l == TypeManager.int64_type)
						opcode = OpCodes.Add_Ovf;
					else if (!IsFloat (l))
						opcode = OpCodes.Add_Ovf_Un;
					else
						opcode = OpCodes.Add;
				} else
					opcode = OpCodes.Add;
				break;

			case Operator.Subtraction:
				if (ec.HasSet (EmitContext.Options.CheckedScope)) {
					if (l == TypeManager.int32_type || l == TypeManager.int64_type)
						opcode = OpCodes.Sub_Ovf;
					else if (!IsFloat (l))
						opcode = OpCodes.Sub_Ovf_Un;
					else
						opcode = OpCodes.Sub;
				} else
					opcode = OpCodes.Sub;
				break;

			case Operator.RightShift:
				if (IsUnsigned (l))
					opcode = OpCodes.Shr_Un;
				else
					opcode = OpCodes.Shr;
				break;
				
			case Operator.LeftShift:
				opcode = OpCodes.Shl;
				break;

			case Operator.Equality:
				opcode = OpCodes.Ceq;
				break;

			case Operator.Inequality:
				ig.Emit (OpCodes.Ceq);
				ig.Emit (OpCodes.Ldc_I4_0);
				
				opcode = OpCodes.Ceq;
				break;

			case Operator.LessThan:
				if (IsUnsigned (l))
					opcode = OpCodes.Clt_Un;
				else
					opcode = OpCodes.Clt;
				break;

			case Operator.GreaterThan:
				if (IsUnsigned (l))
					opcode = OpCodes.Cgt_Un;
				else
					opcode = OpCodes.Cgt;
				break;

			case Operator.LessThanOrEqual:
				if (IsUnsigned (l) || IsFloat (l))
					ig.Emit (OpCodes.Cgt_Un);
				else
					ig.Emit (OpCodes.Cgt);
				ig.Emit (OpCodes.Ldc_I4_0);
				
				opcode = OpCodes.Ceq;
				break;

			case Operator.GreaterThanOrEqual:
				if (IsUnsigned (l) || IsFloat (l))
					ig.Emit (OpCodes.Clt_Un);
				else
					ig.Emit (OpCodes.Clt);
				
				ig.Emit (OpCodes.Ldc_I4_0);
				
				opcode = OpCodes.Ceq;
				break;

			case Operator.BitwiseOr:
				opcode = OpCodes.Or;
				break;

			case Operator.BitwiseAnd:
				opcode = OpCodes.And;
				break;

			case Operator.ExclusiveOr:
				opcode = OpCodes.Xor;
				break;

			default:
				throw new InternalErrorException (oper.ToString ());
			}

			ig.Emit (opcode);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:expression.cs

示例3: GetOperatorMetadataName

		static string GetOperatorMetadataName (Operator op)
		{
			CSharp.Operator.OpType op_type;
			switch (op) {
			case Operator.Addition:
				op_type = CSharp.Operator.OpType.Addition; break;
			case Operator.BitwiseAnd:
				op_type = CSharp.Operator.OpType.BitwiseAnd; break;
			case Operator.BitwiseOr:
				op_type = CSharp.Operator.OpType.BitwiseOr; break;
			case Operator.Division:
				op_type = CSharp.Operator.OpType.Division; break;
			case Operator.Equality:
				op_type = CSharp.Operator.OpType.Equality; break;
			case Operator.ExclusiveOr:
				op_type = CSharp.Operator.OpType.ExclusiveOr; break;
			case Operator.GreaterThan:
				op_type = CSharp.Operator.OpType.GreaterThan; break;
			case Operator.GreaterThanOrEqual:
				op_type = CSharp.Operator.OpType.GreaterThanOrEqual; break;
			case Operator.Inequality:
				op_type = CSharp.Operator.OpType.Inequality; break;
			case Operator.LeftShift:
				op_type = CSharp.Operator.OpType.LeftShift; break;
			case Operator.LessThan:
				op_type = CSharp.Operator.OpType.LessThan; break;
			case Operator.LessThanOrEqual:
				op_type = CSharp.Operator.OpType.LessThanOrEqual; break;
			case Operator.Modulus:
				op_type = CSharp.Operator.OpType.Modulus; break;
			case Operator.Multiply:
				op_type = CSharp.Operator.OpType.Multiply; break;
			case Operator.RightShift:
				op_type = CSharp.Operator.OpType.RightShift; break;
			case Operator.Subtraction:
				op_type = CSharp.Operator.OpType.Subtraction; break;
			default:
				throw new InternalErrorException (op.ToString ());
			}

			return CSharp.Operator.GetMetadataName (op_type);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:42,代码来源:expression.cs

示例4: OperName

		/// <summary>
		///   Returns a stringified representation of the Operator
		/// </summary>
		static string OperName (Operator oper)
		{
			switch (oper){
			case Operator.Multiply:
				return "*";
			case Operator.Division:
				return "/";
			case Operator.Modulus:
				return "%";
			case Operator.Addition:
				return "+";
			case Operator.Subtraction:
				return "-";
			case Operator.LeftShift:
				return "<<";
			case Operator.RightShift:
				return ">>";
			case Operator.LessThan:
				return "<";
			case Operator.GreaterThan:
				return ">";
			case Operator.LessThanOrEqual:
				return "<=";
			case Operator.GreaterThanOrEqual:
				return ">=";
			case Operator.Equality:
				return "==";
			case Operator.Inequality:
				return "!=";
			case Operator.BitwiseAnd:
				return "&";
			case Operator.BitwiseOr:
				return "|";
			case Operator.ExclusiveOr:
				return "^";
			case Operator.LogicalOr:
				return "||";
			case Operator.LogicalAnd:
				return "&&";
			}

			return oper.ToString ();
		}
开发者ID:emtees,项目名称:old-code,代码行数:46,代码来源:expression.cs


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