示例#1
0
        //!!! code review
        protected void FinishCompare(CodeGen cg)
        {
            BinaryExpr bright = (BinaryExpr)right;

            Slot valTmp = cg.GetLocalTmp(typeof(object));
            Slot retTmp = cg.GetLocalTmp(typeof(object));

            bright.left.Emit(cg);
            cg.Emit(OpCodes.Dup);
            valTmp.EmitSet(cg);

            cg.EmitCall(op.target.Method);
            cg.Emit(OpCodes.Dup);
            retTmp.EmitSet(cg);
            cg.EmitTestTrue();

            Label end = cg.DefineLabel();

            cg.Emit(OpCodes.Brfalse, end);

            valTmp.EmitGet(cg);

            if (IsComparision(bright.right))
            {
                bright.FinishCompare(cg);
            }
            else
            {
                bright.right.Emit(cg);
                cg.EmitCall(bright.op.target.Method);
            }

            retTmp.EmitSet(cg);
            cg.MarkLabel(end);
            retTmp.EmitGet(cg);
        }
 public virtual void PostWalk(BinaryExpr node)
 {
 }
示例#3
0
        public static bool IsComparision(Expr e)
        {
            BinaryExpr be = e as BinaryExpr;

            return(be != null && be.IsComparision());
        }
 // BinaryExpr
 public virtual bool Walk(BinaryExpr node)
 {
     return(false);
 }