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

C# Ast.UnaryOperatorExpression类代码示例

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

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



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

示例1: VisitUnaryOperatorExpression

		public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
		{
			if (unaryOperatorExpression.Op == UnaryOperatorType.Not) {
				return unaryOperatorExpression.Expression.AcceptVisitor(this, data) == SymbolDefined ? null : SymbolDefined;
			} else {
				return null;
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:8,代码来源:ConditionalCompilation.cs


示例2: GenerateCode

		public override void GenerateCode(List<AbstractNode> nodes, IList items)
		{
			TypeReference intReference = new TypeReference("System.Int32");
			MethodDeclaration method = new MethodDeclaration("GetHashCode", Modifiers.Public | Modifiers.Override, intReference, null, null);
			Expression expr = CallGetHashCode(new IdentifierExpression(currentClass.Fields[0].Name));
			for (int i = 1; i < currentClass.Fields.Count; i++) {
				IdentifierExpression identifier = new IdentifierExpression(currentClass.Fields[i].Name);
				expr = new BinaryOperatorExpression(expr, BinaryOperatorType.ExclusiveOr,
				                                    CallGetHashCode(identifier));
			}
			method.Body = new BlockStatement();
			method.Body.AddChild(new ReturnStatement(expr));
			nodes.Add(method);
			
			TypeReference boolReference = new TypeReference("System.Boolean");
			TypeReference objectReference = new TypeReference("System.Object");
			
			method = new MethodDeclaration("Equals", Modifiers.Public | Modifiers.Override, boolReference, null, null);
			method.Parameters.Add(new ParameterDeclarationExpression(objectReference, "obj"));
			method.Body = new BlockStatement();
			
			TypeReference currentType = ConvertType(currentClass.DefaultReturnType);
			expr = new TypeOfIsExpression(new IdentifierExpression("obj"), currentType);
			expr = new ParenthesizedExpression(expr);
			expr = new UnaryOperatorExpression(expr, UnaryOperatorType.Not);
			method.Body.AddChild(new IfElseStatement(expr, new ReturnStatement(new PrimitiveExpression(false, "false"))));
			
			expr = new BinaryOperatorExpression(new ThisReferenceExpression(),
			                                    BinaryOperatorType.Equality,
			                                    new IdentifierExpression("obj"));
			method.Body.AddChild(new IfElseStatement(expr, new ReturnStatement(new PrimitiveExpression(true, "true"))));
			
			VariableDeclaration var = new VariableDeclaration("my" + currentClass.Name,
			                                                  new CastExpression(currentType, new IdentifierExpression("obj"), CastType.Cast),
			                                                  currentType);
			method.Body.AddChild(new LocalVariableDeclaration(var));
			
			expr = TestEquality(var.Name, currentClass.Fields[0]);
			for (int i = 1; i < currentClass.Fields.Count; i++) {
				expr = new BinaryOperatorExpression(expr, BinaryOperatorType.LogicalAnd,
				                                    TestEquality(var.Name, currentClass.Fields[i]));
			}
			
			method.Body.AddChild(new ReturnStatement(expr));
			
			nodes.Add(method);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:47,代码来源:EqualsCodeGenerator.cs


示例3: NotExpr

	void NotExpr(
//#line  1993 "VBNET.ATG" 
out Expression outExpr) {

//#line  1994 "VBNET.ATG" 
		UnaryOperatorType uop = UnaryOperatorType.None; 
		while (la.kind == 164) {
			lexer.NextToken();

//#line  1995 "VBNET.ATG" 
			uop = UnaryOperatorType.Not; 
		}
		ComparisonExpr(
//#line  1996 "VBNET.ATG" 
out outExpr);

//#line  1997 "VBNET.ATG" 
		if (uop != UnaryOperatorType.None)
		outExpr = new UnaryOperatorExpression(outExpr, uop);
		
	}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:21,代码来源:Parser.cs


示例4: CreateIncrementStatement

 private object CreateIncrementStatement(UnaryOperatorExpression unaryOperatorExpression)
 {
     object obj = this.CreateIncrementStatement(unaryOperatorExpression, 1, NRefactoryToPythonConverter.GetBinaryOperator(BinaryOperatorType.Add));
     return obj;
 }
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:5,代码来源:NRefactoryToPythonConverter.cs


示例5: VisitUnaryOperatorExpression

		public sealed override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) {
			this.BeginVisit(unaryOperatorExpression);
			object result = this.TrackedVisitUnaryOperatorExpression(unaryOperatorExpression, data);
			this.EndVisit(unaryOperatorExpression);
			return result;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:6,代码来源:NodeTrackingAstVisitor.cs


示例6: VisitUnaryOperatorExpression

		public virtual object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) {
			throw new global::System.NotImplementedException("UnaryOperatorExpression");
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:3,代码来源:NotImplementedAstVisitor.cs


示例7: NotExpr

	void NotExpr(
#line  1810 "VBNET.ATG" 
out Expression outExpr) {

#line  1811 "VBNET.ATG" 
		UnaryOperatorType uop = UnaryOperatorType.None; 
		while (la.kind == 150) {
			lexer.NextToken();

#line  1812 "VBNET.ATG" 
			uop = UnaryOperatorType.Not; 
		}
		ComparisonExpr(
#line  1813 "VBNET.ATG" 
out outExpr);

#line  1814 "VBNET.ATG" 
		if (uop != UnaryOperatorType.None)
		outExpr = new UnaryOperatorExpression(outExpr, uop);
		
	}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:21,代码来源:Parser.cs


示例8: PrimaryExpr


//.........这里部分代码省略.........
			Expect(21);

#line  1986 "cs.ATG" 
			pexpr = new CheckedExpression(expr); 
		} else if (la.kind == 118) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1987 "cs.ATG" 
out expr);
			Expect(21);

#line  1987 "cs.ATG" 
			pexpr = new UncheckedExpression(expr); 
		} else SynErr(209);

#line  1989 "cs.ATG" 
		if (pexpr != null) {
		if (pexpr.StartLocation.IsEmpty)
			pexpr.StartLocation = startLocation;
		if (pexpr.EndLocation.IsEmpty)
			pexpr.EndLocation = t.EndLocation;
		}
		
		while (StartOf(35)) {

#line  1997 "cs.ATG" 
			startLocation = la.Location; 
			switch (la.kind) {
			case 31: {
				lexer.NextToken();

#line  1999 "cs.ATG" 
				pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); 
				break;
			}
			case 32: {
				lexer.NextToken();

#line  2001 "cs.ATG" 
				pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); 
				break;
			}
			case 47: {
				PointerMemberAccess(
#line  2003 "cs.ATG" 
out pexpr, pexpr);
				break;
			}
			case 15: {
				MemberAccess(
#line  2004 "cs.ATG" 
out pexpr, pexpr);
				break;
			}
			case 20: {
				lexer.NextToken();

#line  2008 "cs.ATG" 
				List<Expression> parameters = new List<Expression>(); 

#line  2009 "cs.ATG" 
				pexpr = new InvocationExpression(pexpr, parameters); 
				if (StartOf(25)) {
					Argument(
#line  2010 "cs.ATG" 
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:67,代码来源:Parser.cs


示例9: CreateDecrementStatement

		/// <summary>
		/// Converts a post or pre decrement expression to an assign statement.
		/// This converts "i--" and "--i" to "i -= 1" since python
		/// does not support post increment expressions.
		/// </summary>
		object CreateDecrementStatement(UnaryOperatorExpression unaryOperatorExpression)
		{
			return CreateIncrementStatement(unaryOperatorExpression, 1, GetBinaryOperator(BinaryOperatorType.Subtract));
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:9,代码来源:NRefactoryToPythonConverter.cs


示例10: TrackedVisitUnaryOperatorExpression

		public override object TrackedVisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
		{
			switch (unaryOperatorExpression.Op) {
				case UnaryOperatorType.PostIncrement:
				case UnaryOperatorType.Increment:
					// Change i++ or ++i to i += 1
					return CreateIncrementStatement(unaryOperatorExpression);
				case UnaryOperatorType.Decrement:
				case UnaryOperatorType.PostDecrement:
					// Change --i or i-- to i -= 1.
					return CreateDecrementStatement(unaryOperatorExpression);
				case UnaryOperatorType.Minus:
					return CreateUnaryOperatorStatement(GetBinaryOperator(BinaryOperatorType.Subtract), unaryOperatorExpression.Expression);
				case UnaryOperatorType.Plus:
					return CreateUnaryOperatorStatement(GetBinaryOperator(BinaryOperatorType.Add), unaryOperatorExpression.Expression);
				case UnaryOperatorType.Not:
					return CreateUnaryOperatorStatement("not ", unaryOperatorExpression.Expression);
				case UnaryOperatorType.BitNot:
					return CreateUnaryOperatorStatement("~", unaryOperatorExpression.Expression);
			}
			return null;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:22,代码来源:NRefactoryToPythonConverter.cs


示例11: VisitUnaryOperatorExpression

 public virtual object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) {
     throw CreateException(unaryOperatorExpression);
 }
开发者ID:hallvar,项目名称:Joddes.CS,代码行数:3,代码来源:JsVisitor.cs


示例12: VisitUnaryOperatorExpression

		public virtual object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) {
			Debug.Assert((unaryOperatorExpression != null));
			Debug.Assert((unaryOperatorExpression.Expression != null));
			nodeStack.Push(unaryOperatorExpression.Expression);
			unaryOperatorExpression.Expression.AcceptVisitor(this, data);
			unaryOperatorExpression.Expression = ((Expression)(nodeStack.Pop()));
			return null;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:8,代码来源:AbstractAstTransformer.cs


示例13: VisitUnaryOperatorExpression

		public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
		{
			TypedValue value = Evaluate(unaryOperatorExpression.Expression);
			UnaryOperatorType op = unaryOperatorExpression.Op;
			
			if (op == UnaryOperatorType.Dereference) {
				if (!value.Type.IsPointer)
					throw new GetValueException("Target object is not a pointer");
				return new TypedValue(value.Value.Dereference(), (DebugType)value.Type.GetElementType());
			}
			
			if (!value.Type.IsPrimitive)
				throw new GetValueException("Primitive value expected");
			
			if (op == UnaryOperatorType.Decrement || op == UnaryOperatorType.PostDecrement ||
			    op == UnaryOperatorType.Increment || op == UnaryOperatorType.PostIncrement)
			{
				TypedValue oldValue = value;
				TypedValue newValue = null;
				try {
					if (op == UnaryOperatorType.Decrement || op == UnaryOperatorType.PostDecrement)
						newValue = (TypedValue)VisitAssignmentExpression(new AssignmentExpression(unaryOperatorExpression.Expression, AssignmentOperatorType.Subtract, new PrimitiveExpression(1)), null);
					if (op == UnaryOperatorType.Increment || op == UnaryOperatorType.PostIncrement)
						newValue = (TypedValue)VisitAssignmentExpression(new AssignmentExpression(unaryOperatorExpression.Expression, AssignmentOperatorType.Add, new PrimitiveExpression(1)), null);
				} catch (EvaluateException e) {
					throw new EvaluateException(unaryOperatorExpression, e.Message);
				}
				if (op == UnaryOperatorType.PostDecrement || op == UnaryOperatorType.PostIncrement) {
					return oldValue;
				} else {
					// Note: the old unaryOparatorExpression is still cached and still has the old value
					return newValue;
				}
			}
			
			if (op == UnaryOperatorType.Minus) {
				object val = value.PrimitiveValue;
				// Special case - it would promote the value to long otherwise
				if (val is uint && (uint)val == (uint)1 << 31)
					return CreateValue(int.MinValue);
				
				// Special case - it would overflow otherwise
				if (val is ulong && (ulong)val == (ulong)1 << 63)
					return CreateValue(long.MinValue);
			}
			
			if (op == UnaryOperatorType.Plus || op == UnaryOperatorType.Minus ||
			    op == UnaryOperatorType.BitNot || op == UnaryOperatorType.Not)
			{
				Type[] overloads;
				if (op == UnaryOperatorType.Not) {
					overloads = new Type[] { typeof(bool) };
				} else if (op == UnaryOperatorType.Minus) {
					overloads = new Type[] { typeof(int), typeof(long), typeof(ulong), typeof(float), typeof(double) };
				} else {
					overloads = new Type[] { typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double) };
				}
				foreach(Type argType in overloads) {
					if (value.Type.CanPromoteTo(argType)) {
						object a = Convert.ChangeType(value.PrimitiveValue, argType);
						object res;
						try {
							res = PerformUnaryOperation(a, op, argType);
						} catch (ArithmeticException e) {
							// Can happen for smaller int or long
							throw new EvaluateException(unaryOperatorExpression, e.Message);
						}
						if (res != null)
							return CreateValue(res);
						break; // Match only one overload
					}
				}
			}
			
			throw new EvaluateException(unaryOperatorExpression, "Can not use the unary operator {0} on type {1}", op.ToString(), value.Type.FullName);
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:76,代码来源:ExpressionEvaluator.cs


示例14: VisitUnaryOperatorExpression

 public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
 {
     if (unaryOperatorExpression.Op == UnaryOperatorType.PostIncrement || unaryOperatorExpression.Op == UnaryOperatorType.Increment)
         UnlockWith(unaryOperatorExpression);
     return base.VisitUnaryOperatorExpression(unaryOperatorExpression, data);
 }
开发者ID:timdams,项目名称:strokes,代码行数:6,代码来源:ShorthandArithmeticOperatorAchievement.cs


示例15: PrimaryExpr


//.........这里部分代码省略.........
#line  1924 "cs.ATG" 
out expr);
			Expect(21);

#line  1924 "cs.ATG" 
			pexpr = new UncheckedExpression(expr); 
		} else if (la.kind == 64) {
			lexer.NextToken();
			AnonymousMethodExpr(
#line  1925 "cs.ATG" 
out expr);

#line  1925 "cs.ATG" 
			pexpr = expr; 
		} else SynErr(208);

#line  1927 "cs.ATG" 
		if (pexpr != null) {
		if (pexpr.StartLocation.IsEmpty)
			pexpr.StartLocation = startLocation;
		if (pexpr.EndLocation.IsEmpty)
			pexpr.EndLocation = t.EndLocation;
		}
		
		while (StartOf(36)) {

#line  1935 "cs.ATG" 
			startLocation = la.Location; 
			switch (la.kind) {
			case 31: {
				lexer.NextToken();

#line  1937 "cs.ATG" 
				pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); 
				break;
			}
			case 32: {
				lexer.NextToken();

#line  1939 "cs.ATG" 
				pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); 
				break;
			}
			case 47: {
				PointerMemberAccess(
#line  1941 "cs.ATG" 
out pexpr, pexpr);
				break;
			}
			case 15: {
				MemberAccess(
#line  1942 "cs.ATG" 
out pexpr, pexpr);
				break;
			}
			case 20: {
				lexer.NextToken();

#line  1946 "cs.ATG" 
				List<Expression> parameters = new List<Expression>(); 

#line  1947 "cs.ATG" 
				pexpr = new InvocationExpression(pexpr, parameters); 
				if (StartOf(26)) {
					Argument(
#line  1948 "cs.ATG" 
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:67,代码来源:Parser.cs


示例16: NotExpr

	void NotExpr(
#line  1735 "VBNET.ATG" 
out Expression outExpr) {

#line  1736 "VBNET.ATG" 
		UnaryOperatorType uop = UnaryOperatorType.None; 
		while (la.kind == 129) {
			lexer.NextToken();

#line  1737 "VBNET.ATG" 
			uop = UnaryOperatorType.Not; 
		}
		ComparisonExpr(
#line  1738 "VBNET.ATG" 
out outExpr);

#line  1739 "VBNET.ATG" 
		if (uop != UnaryOperatorType.None)
		outExpr = new UnaryOperatorExpression(outExpr, uop);
		
	}
开发者ID:almazik,项目名称:ILSpy,代码行数:21,代码来源:Parser.cs


示例17: UnaryExpr

	void UnaryExpr(
#line  1834 "VBNET.ATG" 
out Expression uExpr) {

#line  1836 "VBNET.ATG" 
		Expression expr;
		UnaryOperatorType uop = UnaryOperatorType.None;
		bool isUOp = false;
		
		while (la.kind == 14 || la.kind == 15 || la.kind == 16) {
			if (la.kind == 14) {
				lexer.NextToken();

#line  1840 "VBNET.ATG" 
				uop = UnaryOperatorType.Plus; isUOp = true; 
			} else if (la.kind == 15) {
				lexer.NextToken();

#line  1841 "VBNET.ATG" 
				uop = UnaryOperatorType.Minus; isUOp = true; 
			} else {
				lexer.NextToken();

#line  1842 "VBNET.ATG" 
				uop = UnaryOperatorType.Star;  isUOp = true;
			}
		}
		ExponentiationExpr(
#line  1844 "VBNET.ATG" 
out expr);

#line  1846 "VBNET.ATG" 
		if (isUOp) {
		uExpr = new UnaryOperatorExpression(expr, uop);
		} else {
			uExpr = expr;
		}
		
	}
开发者ID:almazik,项目名称:ILSpy,代码行数:39,代码来源:Parser.cs


示例18: CreateIncrementStatement

		/// <summary>
		/// Converts a post or pre increment expression to an assign statement.
		/// This converts "i++" and "++i" to "i += 1" since python
		/// does not support post increment expressions.
		/// </summary>
		object CreateIncrementStatement(UnaryOperatorExpression unaryOperatorExpression, int increment, string binaryOperator)
		{
			unaryOperatorExpression.Expression.AcceptVisitor(this, null);
			Append(" " + binaryOperator + "= ");
			Append(increment.ToString());
			
			return null;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:13,代码来源:NRefactoryToPythonConverter.cs


示例19: VisitUnaryOperatorExpression

			public override object VisitUnaryOperatorExpression (UnaryOperatorExpression expression, object data)
			{
				Console.WriteLine ("UnaryOperatorExpression");
				IntegrateTemporaryVariableVisitorOptions options = (IntegrateTemporaryVariableVisitorOptions)data;
				if (IsExpressionToReplace (expression.Expression, options)) {
					if (IsUnary (options.Initializer))
						options.Changes.Add (ReplaceExpression (expression.Expression, options.Initializer, options)); else
						options.Changes.Add (ReplaceExpression (expression.Expression, new ParenthesizedExpression (options.Initializer), options));
					return null;
				} else {
					return base.VisitUnaryOperatorExpression (expression, data);
				}
			}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:13,代码来源:IntegrateTemporaryVariableRefactoring.cs


示例20: VisitUnaryOperatorExpression

		public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
		{
			IReturnType type = ResolveType(unaryOperatorExpression.Expression);
			if (type == null)
				return null;
			switch (unaryOperatorExpression.Op) {
				case UnaryOperatorType.AddressOf:
					return CreateResolveResult(new PointerReturnType(type));
				case UnaryOperatorType.Dereference:
					PointerReturnType prt = type.CastToDecoratingReturnType<PointerReturnType>();
					if (prt != null) {
						return CreateResolveResult(prt.BaseType);
					} else {
						return null;
					}
				case UnaryOperatorType.Await:
					var crt = type.CastToConstructedReturnType();
					if (crt != null && crt.Name == "Task" && crt.TypeArguments.Count == 1) {
						return CreateResolveResult(crt.TypeArguments[0]);
					} else {
						return null;
					}
				default:
					return CreateResolveResult(type);
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:26,代码来源:ResolveVisitor.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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