當前位置: 首頁>>代碼示例>>C#>>正文


C# CSharp.Operator類代碼示例

本文整理匯總了C#中Mono.CSharp.Operator的典型用法代碼示例。如果您正苦於以下問題:C# Operator類的具體用法?C# Operator怎麽用?C# Operator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Operator類屬於Mono.CSharp命名空間,在下文中一共展示了Operator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的Mono.CSharp.Operator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。