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


C# UnaryExpression类代码示例

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


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

示例1: TestComplexExpression

        public void TestComplexExpression()
        {
            const string VAR_X = "x";
             const string VAR_Y = "y";
             const string VAR_Z = "z";

             var ctx = new Context();
             ctx.SetValue(VAR_X, true);
             ctx.SetValue(VAR_Y, true);
             ctx.SetValue(VAR_Z, false);

             var constExp = new ConstExpression(TRUE_TOKEN);
             var unaryExp = new UnaryExpression(constExp);
             Assert.AreEqual(false, unaryExp.Interpret(ctx));

             var binaryExp =
                 new BinaryExpression(
                     new BinaryExpression(VAR_X,
                                          BinaryOp.And,
                                          unaryExp),
                     BinaryOp.Or,
                     new BinaryExpression(new UnaryExpression(VAR_Y),
                                          BinaryOp.And,
                                          VAR_Z));

             Assert.AreEqual(false, binaryExp.Interpret(ctx));
        }
开发者ID:solarplexus6,项目名称:Oop,代码行数:27,代码来源:Zad2Test.cs

示例2: E

		ISemantic E(UnaryExpression x)
		{
			if (x is NewExpression)
				return E((NewExpression)x);
			else if (x is CastExpression)
				return E((CastExpression)x);
			else if (x is UnaryExpression_Cat)
				return E((UnaryExpression_Cat)x);
			else if (x is UnaryExpression_Increment)
				return E((UnaryExpression_Increment)x);
			else if (x is UnaryExpression_Decrement)
				return E((UnaryExpression_Decrement)x);
			else if (x is UnaryExpression_Add)
				return E((UnaryExpression_Add)x);
			else if (x is UnaryExpression_Sub)
				return E((UnaryExpression_Sub)x);
			else if (x is UnaryExpression_Not)
				return E((UnaryExpression_Not)x);
			else if (x is UnaryExpression_Mul)
				return E((UnaryExpression_Mul)x);
			else if (x is UnaryExpression_And)
				return E((UnaryExpression_And)x);
			else if (x is DeleteExpression)
				return E((DeleteExpression)x);
			else if (x is UnaryExpression_Type)
				return E((UnaryExpression_Type)x);

			return null;
		}
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:29,代码来源:Evaluation.UnaryExpressions.cs

示例3: TestDoFoldConstantInPositiveSquareRoot

 public void TestDoFoldConstantInPositiveSquareRoot()
 {
     AbstractExpr input = new UnaryExpression(Polynomial.CreateConstant(4), new PositiveSquareroot());
     IAbstractExpr result = input.Accept(visitor, Ig.nore);
     Assert.AreNotEqual(input, result);
     Assert.AreEqual(Polynomial.CreateConstant(2), result);
 }
开发者ID:hmmueller,项目名称:Movimentum,代码行数:7,代码来源:TestConstantFoldingVisitor.cs

示例4: getSimpleIsTrue

 /// <summary>
 /// 获取简单表达式
 /// </summary>
 /// <param name="binaryExpression">一元表达式</param>
 /// <returns>简单表达式</returns>
 private static Expression getSimpleIsTrue(UnaryExpression binaryExpression)
 {
     if (binaryExpression.Expression.IsConstant)
     {
         return new logicConstantExpression((bool)((ConstantExpression)binaryExpression.Expression).Value);
     }
     return binaryExpression;
 }
开发者ID:khaliyo,项目名称:fastCSharp,代码行数:13,代码来源:UnaryExpression.cs

示例5: EmitUnaryExpression

        void EmitUnaryExpression(UnaryExpression expr, MethodInfo method)
        {
            // Compute the operands
            VisitExpression(expr.Operand);

            // Call the operator method
            IL.Emit(OpCodes.Call, method);
        }
开发者ID:MilesBoulanger,项目名称:game-creator,代码行数:8,代码来源:NaiveDotNetTraverser.cs

示例6: getSimpleNot

 /// <summary>
 /// 获取简单表达式
 /// </summary>
 /// <param name="binaryExpression">一元表达式</param>
 /// <returns>简单表达式</returns>
 private static Expression getSimpleNot(UnaryExpression binaryExpression)
 {
     if (binaryExpression.Expression.IsConstant)
     {
         return new ConstantExpression(!(bool)((ConstantExpression)binaryExpression.Expression).Value);
     }
     return binaryExpression;
 }
开发者ID:khaliyo,项目名称:fastCSharp,代码行数:13,代码来源:UnaryExpression.cs

示例7: Match

		public bool Match(UnaryExpression unary)
		{
			if (unary.Operator == Operator.Neg)
			{
				bin = unary.Expression as BinaryExpression;
				if (bin != null && bin.Operator == Operator.ISub)
					return true;
			}
			return false;
		}
开发者ID:gitter-badger,项目名称:reko,代码行数:10,代码来源:NegSub_Rule.cs

示例8: VisitRefTypeExpression

 public override Expression VisitRefTypeExpression(RefTypeExpression reftypexp) {
   if (reftypexp == null) return null;
   Expression result = base.VisitRefTypeExpression (reftypexp);
   if (result != reftypexp) return result;
   UnaryExpression refanytype = new UnaryExpression(reftypexp.Operand, NodeType.Refanytype, SystemTypes.RuntimeTypeHandle, reftypexp.SourceContext);
   ExpressionList arguments = new ExpressionList(1);
   arguments.Add(refanytype);
   MemberBinding mb = new MemberBinding(null, Runtime.GetTypeFromHandle);
   return new MethodCall(mb, arguments, NodeType.Call, SystemTypes.Type);
 }
开发者ID:dbremner,项目名称:specsharp,代码行数:10,代码来源:Normalizer.cs

示例9: EmitThrow

        private void EmitThrow(UnaryExpression expr, CompilationFlags flags) {
            if (expr.Operand == null) {
                CheckRethrow();

                _ilg.Emit(OpCodes.Rethrow);
            } else {
                EmitExpression(expr.Operand);
                _ilg.Emit(OpCodes.Throw);
            }

            EmitUnreachable(expr, flags);
        }
开发者ID:stabbylambda,项目名称:mono,代码行数:12,代码来源:LambdaCompiler.Unary.cs

示例10: EmitUnary

 //CONFORMING
 private void EmitUnary(UnaryExpression node) {
     if (node.Method != null) {
         EmitUnaryMethod(node);
     } else if (node.NodeType == ExpressionType.NegateChecked && TypeUtils.IsInteger(node.Operand.Type)) {
         _ilg.EmitInt(0);
         _ilg.EmitConvertToType(typeof(int), node.Operand.Type, false);
         EmitExpression(node.Operand);
         EmitBinaryOperator(ExpressionType.SubtractChecked, node.Operand.Type, node.Operand.Type, node.Type, false);
     } else {
         EmitExpression(node.Operand);
         EmitUnaryOperator(node.NodeType, node.Operand.Type, node.Type);
     }
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:14,代码来源:LambdaCompiler.Unary.cs

示例11: EmitThrow

        private void EmitThrow(UnaryExpression expr, EmitAs emitAs) {
            if (expr.Operand == null) {
                CheckRethrow();

                _ilg.Emit(OpCodes.Rethrow);
            } else {
                EmitExpression(expr.Operand);
                _ilg.Emit(OpCodes.Throw);
            }
            if (emitAs != EmitAs.Void && expr.Type != typeof(void)) {
                _ilg.EmitDefault(expr.Type);
            }
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:13,代码来源:LambdaCompiler.Unary.cs

示例12: EmitQuote

        private void EmitQuote(UnaryExpression quote) {
            // emit the quoted expression as a runtime constant
            EmitConstant(quote.Operand, quote.Type);

            // Heuristic: only emit the tree rewrite logic if we have hoisted
            // locals.
            if (_scope.NearestHoistedLocals != null) {
                // HoistedLocals is internal so emit as System.Object
                EmitConstant(_scope.NearestHoistedLocals, typeof(object));
                _scope.EmitGet(_scope.NearestHoistedLocals.SelfVariable);
                _ilg.Emit(OpCodes.Call, typeof(RuntimeOps).GetMethod("Quote"));

                if (quote.Type != typeof(Expression)) {
                    _ilg.Emit(OpCodes.Castclass, quote.Type);
                }
            }
        }
开发者ID:stabbylambda,项目名称:mono,代码行数:17,代码来源:LambdaCompiler.Unary.cs

示例13: EmitUnary

 private void EmitUnary(UnaryExpression node, CompilationFlags flags) {
     if (node.Method != null) {
         EmitUnaryMethod(node, flags);
     } else if (node.NodeType == ExpressionType.NegateChecked && TypeUtils.IsInteger(node.Operand.Type)) {
         EmitExpression(node.Operand);
         LocalBuilder loc = GetLocal(node.Operand.Type);
         _ilg.Emit(OpCodes.Stloc, loc);
         _ilg.EmitInt(0);
         _ilg.EmitConvertToType(typeof(int), node.Operand.Type, false);
         _ilg.Emit(OpCodes.Ldloc, loc);
         FreeLocal(loc);
         EmitBinaryOperator(ExpressionType.SubtractChecked, node.Operand.Type, node.Operand.Type, node.Type, false);
     } else {
         EmitExpression(node.Operand);
         EmitUnaryOperator(node.NodeType, node.Operand.Type, node.Type);
     }
 }
开发者ID:stabbylambda,项目名称:mono,代码行数:17,代码来源:LambdaCompiler.Unary.cs

示例14: EmitQuote

        //CONFORMING
        private void EmitQuote(UnaryExpression quote) {
            // emit the quoted expression as a runtime constant
            EmitConstant(quote.Operand, quote.Type);

            // Heuristic: only emit the tree rewrite logic if we have hoisted
            // locals. TODO: we could use an even smarter logic here by
            // detecting if any nodes actually need to be rewritten
            if (_scope.NearestHoistedLocals != null) {
                // HoistedLocals is internal so emit as System.Object
                EmitConstant(_scope.NearestHoistedLocals, typeof(object));
                _scope.EmitGet(_scope.NearestHoistedLocals.SelfVariable);
                _ilg.EmitCall(typeof(RuntimeOps).GetMethod("Quote"));

                if (quote.Type != typeof(Expression)) {
                    _ilg.Emit(OpCodes.Castclass, quote.Type);
                }
            }
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:19,代码来源:LambdaCompiler.Unary.cs

示例15: PostWalk

 public virtual void PostWalk(UnaryExpression node) { }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:1,代码来源:PythonWalker.Generated.cs


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