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

C# CSharp.Operator类代码示例

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

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



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

示例1: PredefinedOperator

			public PredefinedOperator (Type ltype, Type rtype, Operator op_mask, Type return_type)
			{
				if ((op_mask & Operator.ValuesOnlyMask) != 0)
					throw new InternalErrorException ("Only masked values can be used");

				this.left = ltype;
				this.right = rtype;
				this.OperatorsMask = op_mask;
				this.ReturnType = return_type;
			}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:10,代码来源:expression.cs


示例2: Visit

			public override void Visit(Operator o)
			{
				var newOperator = new OperatorDeclaration();
				newOperator.OperatorType = (OperatorType)o.OperatorType;
				
				var location = LocationsBag.GetMemberLocation(o);
				AddAttributeSection(newOperator, o);
				AddModifiers(newOperator, location);
				
				
				if (o.OperatorType == Operator.OpType.Implicit) {
					if (location != null && location.Count > 0) {
						newOperator.AddChild(new CSharpTokenNode(Convert(location [0]), OperatorDeclaration.ImplicitRole), OperatorDeclaration.ImplicitRole);
						if (location.Count > 1)
							newOperator.AddChild(new CSharpTokenNode(Convert(location [1]), OperatorDeclaration.OperatorKeywordRole), OperatorDeclaration.OperatorKeywordRole);
					}
					newOperator.AddChild(ConvertToType(o.TypeExpression), Roles.Type);
				} else if (o.OperatorType == Operator.OpType.Explicit) {
					if (location != null && location.Count > 0) {
						newOperator.AddChild(new CSharpTokenNode(Convert(location [0]), OperatorDeclaration.ExplicitRole), OperatorDeclaration.ExplicitRole);
						if (location.Count > 1)
							newOperator.AddChild(new CSharpTokenNode(Convert(location [1]), OperatorDeclaration.OperatorKeywordRole), OperatorDeclaration.OperatorKeywordRole);
					}
					newOperator.AddChild(ConvertToType(o.TypeExpression), Roles.Type);
				} else {
					newOperator.AddChild(ConvertToType(o.TypeExpression), Roles.Type);

					if (location != null && location.Count > 0)
						newOperator.AddChild(new CSharpTokenNode(Convert(location [0]), OperatorDeclaration.OperatorKeywordRole), OperatorDeclaration.OperatorKeywordRole);
					
					if (location != null && location.Count > 1) {
						var r = OperatorDeclaration.GetRole(newOperator.OperatorType);
						newOperator.AddChild(new CSharpTokenNode(Convert(location [1]), r), r);
					}
				}
				if (location != null && location.Count > 2)
					newOperator.AddChild(new CSharpTokenNode(Convert(location [2]), Roles.LPar), Roles.LPar);
				AddParameter(newOperator, o.ParameterInfo);
				if (location != null && location.Count > 3)
					newOperator.AddChild(new CSharpTokenNode(Convert(location [3]), Roles.RPar), Roles.RPar);
				
				if (o.Block != null) {
					newOperator.AddChild((BlockStatement)o.Block.Accept(this), Roles.Body);
				} else {
					if (location != null && location.Count >= 5)
						newOperator.AddChild(new CSharpTokenNode(Convert(location [4]), Roles.Semicolon), Roles.Semicolon);
				}
				typeStack.Peek().AddChild(newOperator, Roles.TypeMemberRole);
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:49,代码来源:CSharpParser.cs


示例3: AddOperator

		public void AddOperator (Operator op)
		{
			if (!AddMember (op))
				return;

			if (operators == null)
				operators = new List<MemberCore> ();

			operators.Add (op);
		}
开发者ID:jordanbtucker,项目名称:mono,代码行数:10,代码来源:class.cs


示例4: IsUnaryOperator

static bool IsUnaryOperator (Operator.OpType op)
{
	switch (op) {
		
	case Operator.OpType.LogicalNot: 
	case Operator.OpType.OnesComplement: 
	case Operator.OpType.Increment:
	case Operator.OpType.Decrement:
	case Operator.OpType.True: 
	case Operator.OpType.False: 
	case Operator.OpType.UnaryPlus: 
	case Operator.OpType.UnaryNegation:
		return true;
	}
	return false;
}
开发者ID:segaman,项目名称:NRefactory,代码行数:16,代码来源:cs-parser.cs


示例5: Visit

			public override void Visit (Operator o)
			{
				OperatorDeclaration newOperator = new OperatorDeclaration ();
				newOperator.OperatorType = (OperatorType)o.OperatorType;
				
				var location = LocationsBag.GetMemberLocation (o);
				AddAttributeSection (newOperator, o);
				AddModifiers (newOperator, location);
				
				
				if (o.OperatorType == Operator.OpType.Implicit) {
					if (location != null) {
						newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "implicit".Length), OperatorDeclaration.OperatorTypeRole);
						newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
					}
					newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type);
				} else if (o.OperatorType == Operator.OpType.Explicit) {
					if (location != null) {
						newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "explicit".Length), OperatorDeclaration.OperatorTypeRole);
						newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
					}
					newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type);
				} else {
					newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type);
					
					if (location != null)
						newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
					
					int opLength = OperatorDeclaration.GetToken(newOperator.OperatorType).Length;
					if (location != null)
						newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), opLength), OperatorDeclaration.OperatorTypeRole);
				}
				if (location != null)
					newOperator.AddChild (new CSharpTokenNode (Convert (location[2]), 1), OperatorDeclaration.Roles.LPar);
				AddParameter (newOperator, o.ParameterInfo);
				if (location != null)
					newOperator.AddChild (new CSharpTokenNode (Convert (location[3]), 1), OperatorDeclaration.Roles.RPar);
				
				if (o.Block != null) {
					newOperator.AddChild ((BlockStatement)o.Block.Accept (this), OperatorDeclaration.Roles.Body);
				} else {
					if (location != null && location.Count >= 5)
						newOperator.AddChild (new CSharpTokenNode (Convert (location[4]), 1), MethodDeclaration.Roles.Semicolon);
				}
				typeStack.Peek ().AddChild (newOperator, TypeDeclaration.MemberRole);
			}
开发者ID:N3X15,项目名称:ILSpy,代码行数:46,代码来源:CSharpParser.cs


示例6: yyparse


//.........这里部分代码省略.........
  {
		Report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants");
	  }
  break;
case 236:
#line 1928 "cs-parser.jay"
  {
	  	Report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators");
	  }
  break;
case 237:
#line 1932 "cs-parser.jay"
  {
	  	Report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors");
	  }
  break;
case 238:
#line 1936 "cs-parser.jay"
  {
	  	Report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations");
	  }
  break;
case 239:
#line 1943 "cs-parser.jay"
  {
	  }
  break;
case 240:
#line 1946 "cs-parser.jay"
  {
		if (yyVals[-2+yyTop] == null)
			break;

		OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop];
		Operator op = new Operator (
			current_class, decl.optype, decl.ret_type, (Modifiers) yyVals[-3+yyTop], 
			current_local_parameters,
			(ToplevelBlock) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop], decl.location);

		if (RootContext.Documentation != null) {
			op.DocComment = tmpComment;
			Lexer.doc_state = XmlCommentState.Allowed;
		}

		/* Note again, checking is done in semantic analysis*/
		current_container.AddOperator (op);

		current_local_parameters = null;
	  }
  break;
case 242:
#line 1970 "cs-parser.jay"
  { yyVal = null; }
  break;
case 244:
#line 1976 "cs-parser.jay"
  {
		Report.Error (590, GetLocation (yyVals[0+yyTop]), "User-defined operators cannot return void");
		yyVal = TypeManager.system_void_expr;		
	  }
  break;
case 245:
#line 1984 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.DefaultValue;
	  }
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs


示例7: Visit

		public virtual void Visit (Operator o)
		{
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:3,代码来源:visit.cs


示例8: Binary

		public Binary (Operator oper, Expression left, Expression right, bool isCompound)
			: this (oper, left, right)
		{
			this.is_compound = isCompound;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:5,代码来源:expression.cs


示例9: PredefinedPointerOperator

			public PredefinedPointerOperator (Type ltype, Type rtype, Operator op_mask, Type retType)
				: base (ltype, rtype, op_mask, retType)
			{
			}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:4,代码来源:expression.cs


示例10: PredefinedShiftOperator

			public PredefinedShiftOperator (Type ltype, Operator op_mask) :
				base (ltype, TypeManager.int32_type, op_mask)
			{
			}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:4,代码来源:expression.cs


示例11: PredefinedStringOperator

			public PredefinedStringOperator (Type ltype, Type rtype, Operator op_mask)
				: base (ltype, rtype, op_mask)
			{
				ReturnType = TypeManager.string_type;
			}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:5,代码来源:expression.cs


示例12: OperatorEntry

			public OperatorEntry (int f, Operator o)
			{
				flags = f;

				ret_type = o.OperatorMethod.GetReturnType ();
				Type [] pt = o.OperatorMethod.ParameterTypes;
				type1 = pt [0];
				type2 = pt [1];
				op = o;
				ot = o.OperatorType;
			}
开发者ID:emtees,项目名称:old-code,代码行数:11,代码来源:class.cs


示例13: OperName

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

			if (is_compound)
				return s + "=";

			return s;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:71,代码来源:expression.cs


示例14: AddOperator

		public AdditionResult AddOperator (Operator op)
		{
			if (operators == null)
				operators = new ArrayList ();

			operators.Add (op);

			return AdditionResult.Success;
		}
开发者ID:emtees,项目名称:old-code,代码行数:9,代码来源:class.cs


示例15: Error_OperatorCannotBeApplied

		public static void Error_OperatorCannotBeApplied (ResolveContext ec, Expression left, Expression right, Operator oper, Location loc)
		{
			new Binary (oper, left, right).Error_OperatorCannotBeApplied (ec, left, right);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:4,代码来源:expression.cs


示例16: case_246

void case_246()
#line 1986 "cs-parser.jay"
{
		OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop];
		if (decl != null) {
			Operator op = new Operator (
				current_class, decl.optype, decl.ret_type, (Modifiers) yyVals[-3+yyTop], 
				current_local_parameters,
				(ToplevelBlock) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop], decl.location);

			if (RootContext.Documentation != null) {
				op.DocComment = tmpComment;
				Lexer.doc_state = XmlCommentState.Allowed;
			}

			/* Note again, checking is done in semantic analysis*/
			current_container.AddOperator (op);

			lbag.AddMember (op, GetModifierLocations (), lbag.GetLocations (decl));
		}
		
		current_local_parameters = null;
	  }
开发者ID:Ein,项目名称:monodevelop,代码行数:23,代码来源:cs-parser.cs


示例17: 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


示例18: OperatorDeclaration

	public OperatorDeclaration (Operator.OpType op, FullNamedExpression ret_type, Location location)
	{
		optype = op;
		this.ret_type = ret_type;
		this.location = location;
	}
开发者ID:segaman,项目名称:NRefactory,代码行数:6,代码来源:cs-parser.cs


示例19: EmitOperatorOpcode

		public static void EmitOperatorOpcode (EmitContext ec, Operator oper, Type l)
		{
			OpCode opcode;
			ILGenerator ig = ec.ig;

			switch (oper){
			case Operator.Multiply:
				if (ec.HasSet (EmitContext.Options.CheckedScope)) {
					if (l == TypeManager.int32_type || l == TypeManager.int64_type)
						opcode = OpCodes.Mul_Ovf;
					else if (!IsFloat (l))
						opcode = OpCodes.Mul_Ovf_Un;
					else
						opcode = OpCodes.Mul;
				} else
					opcode = OpCodes.Mul;
				
				break;
				
			case Operator.Division:
				if (IsUnsigned (l))
					opcode = OpCodes.Div_Un;
				else
					opcode = OpCodes.Div;
				break;
				
			case Operator.Modulus:
				if (IsUnsigned (l))
					opcode = OpCodes.Rem_Un;
				else
					opcode = OpCodes.Rem;
				break;

			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);
				
//.........这里部分代码省略.........
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:expression.cs


示例20: case_236

void case_236()
#line 2067 "cs-parser.jay"
{
		OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop];
		if (decl != null) {
			Operator op = new Operator (
				current_type, decl.optype, decl.ret_type, (Modifiers) yyVals[-3+yyTop], 
				current_local_parameters,
				(ToplevelBlock) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop], decl.location);
				
			if (op.Block == null)
				op.ParameterInfo.CheckParameters (op);

			if (doc_support) {
				op.DocComment = tmpComment;
				Lexer.doc_state = XmlCommentState.Allowed;
			}

			/* Note again, checking is done in semantic analysis*/
			current_type.AddOperator (op);

			lbag.AddMember (op, GetModifierLocations (), lbag.GetLocations (decl));
			if (yyVals[0+yyTop] == null) { /* Semicolon*/
				lbag.AddLocation (op, savedLocation); 
			}
		}
		
		current_local_parameters = null;
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:29,代码来源:cs-parser.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# CSharp.Parameter类代码示例发布时间:2022-05-26
下一篇:
C# CSharp.NewInitialize类代码示例发布时间: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