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

C# BinaryExpression类代码示例

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

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



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

示例1: CompileBinaryExpression

        public static void CompileBinaryExpression(BinaryExpression expression, bool useInterpreter, bool expected)
        {
            Expression<Func<bool>> e = Expression.Lambda<Func<bool>>(expression, Enumerable.Empty<ParameterExpression>());
            Func<bool> f = e.Compile(useInterpreter);

            Assert.Equal(expected, f());
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:7,代码来源:GeneralBinaryTests.cs


示例2: GetResultIndexExpression

 protected Expression GetResultIndexExpression()
 {
     var resultVarIndex = ReadWord();
     Expression resultVarIndexExp = resultVarIndex.ToLiteral();
     if ((resultVarIndex & 0x2000) == 0x2000)
     {
         int a = ReadWord();
         if ((a & 0x2000) == 0x2000)
         {
             var variableExp = ReadVariable(a & ~0x2000);
             var literalExp = variableExp as IntegerLiteralExpression;
             if (literalExp != null)
             {
                 resultVarIndex += Convert.ToInt32(literalExp.Value);
                 resultVarIndex &= ~0x2000;
                 resultVarIndexExp = resultVarIndex.ToLiteral();
             }
             else
             {
                 resultVarIndexExp = new BinaryExpression(
                     new BinaryExpression(resultVarIndexExp, Operator.Add, variableExp), 
                     Operator.And,
                     new UnaryExpression(0x2000.ToLiteral(), Operator.Not));
             }
         }
         else
         {
             resultVarIndex = resultVarIndex + (a & 0xFFF);	
             resultVarIndex &= ~0x2000;
             resultVarIndexExp = resultVarIndex.ToLiteral();
         }
     }
     return resultVarIndexExp;
 }
开发者ID:scemino,项目名称:nscumm,代码行数:34,代码来源:ScriptParser3_Variable.cs


示例3: Match

		public bool Match(BinaryExpression exp)
		{
			if (exp.Operator != Operator.IAdd)
				return false;
			id = exp.Left as Identifier;
			
			bin = exp.Right as BinaryExpression;
			if ((id == null || bin == null) && exp.Operator  == Operator.IAdd)
			{
				id = exp.Right as Identifier;
				bin = exp.Left as BinaryExpression;
			}
			if (id == null || bin == null)
				return false;

			if (bin.Operator != Operator.SMul && bin.Operator != Operator.UMul && bin.Operator != Operator.IMul)
				return false;

			Identifier idInner = bin.Left as Identifier;
			cInner = bin.Right as Constant;
			if (idInner == null ||cInner == null)
				return false;

			if (idInner != id)
				return false;

			return true;
		}
开发者ID:killbug2004,项目名称:reko,代码行数:28,代码来源:Add_mul_id_c_id_Rule.cs


示例4: EmitBinaryMethod

 //CONFORMING
 private void EmitBinaryMethod(BinaryExpression b) {
     if (b.IsLifted) {
         ParameterExpression p1 = Expression.Variable(TypeUtils.GetNonNullableType(b.Left.Type), null);
         ParameterExpression p2 = Expression.Variable(TypeUtils.GetNonNullableType(b.Right.Type), null);
         MethodCallExpression mc = Expression.Call(null, b.Method, p1, p2);
         Type resultType = null;
         if (b.IsLiftedToNull) {
             resultType = TypeUtils.GetNullableType(mc.Type);
         } else {
             switch (b.NodeType) {
                 case ExpressionType.Equal:
                 case ExpressionType.NotEqual:
                 case ExpressionType.LessThan:
                 case ExpressionType.LessThanOrEqual:
                 case ExpressionType.GreaterThan:
                 case ExpressionType.GreaterThanOrEqual:
                     if (mc.Type != typeof(bool)) {
                         throw Error.ArgumentMustBeBoolean();
                     }
                     resultType = typeof(bool);
                     break;
                 default:
                     resultType = TypeUtils.GetNullableType(mc.Type);
                     break;
             }
         }
         IList<ParameterExpression> variables = new ParameterExpression[] { p1, p2 };
         IList<Expression> arguments = new Expression[] { b.Left, b.Right };
         ValidateLift(variables, arguments);
         EmitLift(b.NodeType, resultType, mc, variables, arguments);
     } else {
         EmitMethodCallExpression(Expression.Call(null, b.Method, b.Left, b.Right));
     }
 }
开发者ID:joshholmes,项目名称:ironruby,代码行数:35,代码来源:LambdaCompiler.Binary.cs


示例5: AddressOf

        private void AddressOf(BinaryExpression node, Type type)
        {
            Debug.Assert(node.NodeType == ExpressionType.ArrayIndex && node.Method == null);

            if (TypeUtils.AreEquivalent(type, node.Type))
            {
                EmitExpression(node.Left);
                EmitExpression(node.Right);
                Type rightType = node.Right.Type;
                if (TypeUtils.IsNullableType(rightType))
                {
                    LocalBuilder loc = GetLocal(rightType);
                    _ilg.Emit(OpCodes.Stloc, loc);
                    _ilg.Emit(OpCodes.Ldloca, loc);
                    _ilg.EmitGetValue(rightType);
                    FreeLocal(loc);
                }
                Type indexType = TypeUtils.GetNonNullableType(rightType);
                if (indexType != typeof(int))
                {
                    _ilg.EmitConvertToType(indexType, typeof(int), isChecked: true);
                }
                _ilg.Emit(OpCodes.Ldelema, node.Type);
            }
            else
            {
                EmitExpressionAddress(node, type);
            }
        }
开发者ID:alessandromontividiu03,项目名称:corefx,代码行数:29,代码来源:LambdaCompiler.Address.cs


示例6: VisitBinaryExpression

 public override Expression VisitBinaryExpression(BinaryExpression binaryExpression){
   if (binaryExpression == null) return null;
   binaryExpression.Operand2 = this.VisitExpression(binaryExpression.Operand2);
   binaryExpression.Operand1 = this.VisitExpression(binaryExpression.Operand1);
   if (binaryExpression.Type == null) binaryExpression.Type = binaryExpression.Operand1.Type; //Hack: need proper inferencing
   return binaryExpression;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:7,代码来源:Unstacker.cs


示例7: Exs_OrWithSelf

 public void Exs_OrWithSelf()
 {
     BuildExpressionSimplifier();
     var expr = new BinaryExpression(Operator.Or, foo.DataType, foo, foo);
     var result = expr.Accept(simplifier);
     Assert.AreSame(foo, result);
 }
开发者ID:killbug2004,项目名称:reko,代码行数:7,代码来源:ExpressionSimplifierTests.cs


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


示例9: MatchMul

		public bool MatchMul(BinaryExpression b)
		{
			if (b.Operator == Operator.SMul || b.Operator == Operator.UMul || b.Operator == Operator.IMul)
			{
				Constant c = b.Left as Constant;
				Expression e = b.Right;
				if (c == null)
				{
					c = b.Right as Constant;
					e = b.Left;
				}
				if (c != null)
				{
					elemSize = c;
					Index = e;
					return true;
				}
			}
			if (b.Operator == Operator.Shl)
			{
				Constant c = b.Right as Constant;
				if (c != null)
				{
					elemSize = b.Operator.ApplyConstants(Constant.Create(b.Left.DataType, 1), c);
					Index = b.Left;
					return true;
				}
			}
			return false;
		}
开发者ID:killbug2004,项目名称:reko,代码行数:30,代码来源:ArrayExpressionMatcher.cs


示例10: VisitBinaryExpression

 public override Expression VisitBinaryExpression(BinaryExpression be) {
   be.Operand1 = this.VisitExpression(be.Operand1);
   bool hcr = this.hasContextReference;
   this.hasContextReference = false;
   be.Operand2 = this.VisitExpression(be.Operand2);
   this.hasContextReference |= hcr;
   return (Expression) this.Compose(be, this.GetComposer(be.Operand1), this.GetComposer(be.Operand2));
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:8,代码来源:Partitioner.cs


示例11: EvcBinaryExpression

 public void EvcBinaryExpression()
 {
     Identifier a = new Identifier("a", PrimitiveType.Word32, new TemporaryStorage("a", 1, PrimitiveType.Word32));
     BinaryExpression a1 = new BinaryExpression(Operator.IAdd, PrimitiveType.Word32, a, a);
     BinaryExpression a2 = new BinaryExpression(Operator.IAdd, PrimitiveType.Word32, a, a);
     Assert.IsTrue(eq.Equals(a1, a2));
     Assert.AreEqual(eq.GetHashCode(a1), eq.GetHashCode(a2));
 }
开发者ID:nemerle,项目名称:reko,代码行数:8,代码来源:ExpressionValueComparerTests.cs


示例12: ExsConstants

		public void ExsConstants()
		{
			BuildExpressionSimplifier();
			Expression expr = new BinaryExpression(Operator.IAdd, PrimitiveType.Word32, 
				Constant.Word32(1), Constant.Word32(2));
			Constant c = (Constant) expr.Accept(simplifier);

			Assert.AreEqual(3, c.ToInt32());
		}
开发者ID:killbug2004,项目名称:reko,代码行数:9,代码来源:ExpressionSimplifierTests.cs


示例13: EmitBinaryExpression

        void EmitBinaryExpression(BinaryExpression expr, MethodInfo method)
        {
            // Compute the operands
            VisitExpression(expr.Left);
            VisitExpression(expr.Right);

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


示例14: AddZeroToEffectiveAddress

 /// <summary>
 /// Extends an effective address ''id'' to ''id'' + 0. 
 /// </summary>
 /// <remarks>
 /// The purpose here is to extend the effective address to avoid premature typing of id.
 /// If later in the type inference process [[id]] is discovered to be a signed integer, the
 /// decompiler can accomodate that by having the added 0 be [[pointer]] or [[member pointer]].
 /// This is not possible if all we have is the id.
 /// </remarks>
 /// <param name="ea"></param>
 /// <returns></returns>
 private Expression AddZeroToEffectiveAddress(Expression ea)
 {
     BinaryExpression bin = new BinaryExpression(
         Operator.IAdd,
         PrimitiveType.CreateWord(ea.DataType.Size),
         ea,
         Constant.Create(PrimitiveType.CreateWord(ea.DataType.Size), 0));
     return bin;
 }
开发者ID:killbug2004,项目名称:reko,代码行数:20,代码来源:ExpressionNormalizer.cs


示例15: VpAddZero

        public void VpAddZero()
        {
            Identifier r = Reg32("r");
            Identifier s = Reg32("s");

            var sub = new BinaryExpression(Operator.ISub, PrimitiveType.Word32, new MemoryAccess(MemoryIdentifier.GlobalMemory, r, PrimitiveType.Word32), Constant.Word32(0));
            var vp = new ExpressionSimplifier(new SsaEvaluationContext(arch, ssaIds));
            var exp = sub.Accept(vp);
            Assert.AreEqual("Mem0[r:word32]", exp.ToString());
        }
开发者ID:nemerle,项目名称:reko,代码行数:10,代码来源:ValuePropagationTests.cs


示例16: Match

		public bool Match(Identifier id)
		{
            this.id = id;
            bin = ctx.GetValue(id) as BinaryExpression;
			if (bin == null)
				return false;
            if (ctx.IsUsedInPhi(id))
                return false;
			return (bin.Left is Identifier) && (bin.Right is Constant);
		}
开发者ID:gitter-badger,项目名称:reko,代码行数:10,代码来源:IdBinIdc_Rule.cs


示例17: Match

		public bool Match(BinaryExpression binExp)
		{
			idLeft = binExp.Left as Identifier;
			if (idLeft == null)
				return false;
			idRight = binExp.Right as Identifier;
			if (idRight == null)
				return false;
			return (idLeft == idRight && binExp.Operator == Operator.IAdd);
		}
开发者ID:gitter-badger,项目名称:reko,代码行数:10,代码来源:AddTwoIdsRule.cs


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


示例19: PrintResolvedBinaryExpression

 private void PrintResolvedBinaryExpression(BinaryExpression node, int indent)
 {
     AppendLine(indent, "Type = " + node.Type);
     AppendLine(indent, "CommonType = " + node.CommonType);
     AppendLine(indent, "ExpressionType = " + node.ExpressionType);
     AppendLine(indent, "Left =");
     PrintNode(node.Left, indent + 1);
     AppendLine(indent, "Right =");
     PrintNode(node.Right, indent + 1);
 }
开发者ID:parsnips,项目名称:Expressions,代码行数:10,代码来源:ExpressionPrinter.cs


示例20: SumExpression

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="listExpression"></param>
        /// <param name="condition"></param>
        /// <param name="expression"></param>
        /// <param name="root">the root element for which this expression should be parsed</param>
        public SumExpression(ModelElement root, Expression listExpression, Expression condition, Expression expression)
            : base(root, listExpression, condition, expression)
        {
            AccumulatorVariable = (Variables.Variable)Generated.acceptor.getFactory().createVariable();
            AccumulatorVariable.Enclosing = this;
            AccumulatorVariable.Name = "RESULT";
            Utils.ISubDeclaratorUtils.AppendNamable(this, AccumulatorVariable);

            Accumulator = new BinaryExpression(root, expression, BinaryExpression.OPERATOR.ADD, new UnaryExpression(root, new Term(root, new Designator(root, "RESULT"))));
            Accumulator.Enclosing = this;
        }
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:18,代码来源:SumExpression.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# BinaryExpressionSyntax类代码示例发布时间:2022-05-24
下一篇:
C# BinaryBitmap类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap