Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.facebook.presto.byteCode.expression;
 
 
 import java.util.List;
 
 import static com.facebook.presto.byteCode.OpCode.DCMPG;
 import static com.facebook.presto.byteCode.OpCode.DCMPL;
 import static com.facebook.presto.byteCode.OpCode.FCMPG;
 import static com.facebook.presto.byteCode.OpCode.FCMPL;
 import static com.facebook.presto.byteCode.OpCode.IFEQ;
 import static com.facebook.presto.byteCode.OpCode.IFGE;
 import static com.facebook.presto.byteCode.OpCode.IFGT;
 import static com.facebook.presto.byteCode.OpCode.IFLE;
 import static com.facebook.presto.byteCode.OpCode.IFLT;
 import static com.facebook.presto.byteCode.OpCode.IFNE;
 import static com.facebook.presto.byteCode.OpCode.IF_ACMPEQ;
 import static com.facebook.presto.byteCode.OpCode.IF_ACMPNE;
 import static com.facebook.presto.byteCode.OpCode.IF_ICMPEQ;
 import static com.facebook.presto.byteCode.OpCode.IF_ICMPGE;
 import static com.facebook.presto.byteCode.OpCode.IF_ICMPGT;
 import static com.facebook.presto.byteCode.OpCode.IF_ICMPLE;
 import static com.facebook.presto.byteCode.OpCode.IF_ICMPLT;
 import static com.facebook.presto.byteCode.OpCode.IF_ICMPNE;
 import static com.facebook.presto.byteCode.OpCode.LCMP;
 import static com.facebook.presto.byteCode.ParameterizedType.type;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 
         extends ByteCodeExpression
 {
     {
         checkArgumentTypes(leftright);
 
         OpCode comparisonInstruction;
         OpCode noMatchJumpInstruction;
 
         Class<?> type = left.getType().getPrimitiveType();
         if (type == int.class) {
             comparisonInstruction = null;
             noMatchJumpInstruction = ;
         }
         else if (type == long.class) {
             comparisonInstruction = ;
             noMatchJumpInstruction = ;
         }
         else if (type == float.class) {
             comparisonInstruction = ;
             noMatchJumpInstruction = ;
         }
         else if (type == double.class) {
             comparisonInstruction = ;
             noMatchJumpInstruction = ;
         }
         else {
             throw new IllegalArgumentException("Less than does not support " + type);
         }
 
         return new ComparisonByteCodeExpression("<"comparisonInstructionnoMatchJumpInstructionleftright);
     }
 
     {
         checkArgumentTypes(leftright);
 
         OpCode comparisonInstruction;
         OpCode noMatchJumpInstruction;
 
         Class<?> type = left.getType().getPrimitiveType();
         if (type == int.class) {
             comparisonInstruction = null;
             noMatchJumpInstruction = ;
         }
         else if (type == long.class) {
             comparisonInstruction = ;
             noMatchJumpInstruction = ;
         }
         else if (type == float.class) {
             comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == double.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else {
            throw new IllegalArgumentException("Less than does not support " + type);
        }
        return new ComparisonByteCodeExpression(">"comparisonInstructionnoMatchJumpInstructionleftright);
    }
    {
        checkArgumentTypes(leftright);
        OpCode comparisonInstruction;
        OpCode noMatchJumpInstruction;
        Class<?> type = left.getType().getPrimitiveType();
        if (type == int.class) {
            comparisonInstruction = null;
            noMatchJumpInstruction = ;
        }
        else if (type == long.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == float.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == double.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else {
            throw new IllegalArgumentException("Less than does not support " + type);
        }
        return new ComparisonByteCodeExpression("<="comparisonInstructionnoMatchJumpInstructionleftright);
    }
    {
        checkArgumentTypes(leftright);
        OpCode comparisonInstruction;
        OpCode noMatchJumpInstruction;
        Class<?> type = left.getType().getPrimitiveType();
        if (type == int.class) {
            comparisonInstruction = null;
            noMatchJumpInstruction = ;
        }
        else if (type == long.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == float.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == double.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else {
            throw new IllegalArgumentException("Less than does not support " + type);
        }
        return new ComparisonByteCodeExpression(">="comparisonInstructionnoMatchJumpInstructionleftright);
    }
    {
        checkNotNull(left"left is null");
        checkNotNull(right"right is null");
        checkArgument(left.getType().equals(right.getType()), "left and right must be the same type");
        OpCode comparisonInstruction;
        OpCode noMatchJumpInstruction;
        Class<?> type = left.getType().getPrimitiveType();
        if (type == int.class) {
            comparisonInstruction = null;
            noMatchJumpInstruction = ;
        }
        else if (type == long.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == float.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == double.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == null) {
            comparisonInstruction = null;
            noMatchJumpInstruction = ;
        }
        else {
            throw new IllegalArgumentException("Less than does not support " + type);
        }
        return new ComparisonByteCodeExpression("=="comparisonInstructionnoMatchJumpInstructionleftright);
    }
    {
        checkNotNull(left"left is null");
        checkNotNull(right"right is null");
        checkArgument(left.getType().equals(right.getType()), "left and right must be the same type");
        OpCode comparisonInstruction;
        OpCode noMatchJumpInstruction;
        Class<?> type = left.getType().getPrimitiveType();
        if (type == int.class) {
            comparisonInstruction = null;
            noMatchJumpInstruction = ;
        }
        else if (type == long.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == float.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == double.class) {
            comparisonInstruction = ;
            noMatchJumpInstruction = ;
        }
        else if (type == null) {
            comparisonInstruction = null;
            noMatchJumpInstruction = ;
        }
        else {
            throw new IllegalArgumentException("Less than does not support " + type);
        }
        return new ComparisonByteCodeExpression("!="comparisonInstructionnoMatchJumpInstructionleftright);
    }
    private static void checkArgumentTypes(ByteCodeExpression leftByteCodeExpression right)
    {
        Class<?> leftType = getPrimitiveType(left"left");
        Class<?> rightType = getPrimitiveType(right"right");
        checkArgument(leftType == rightType"left and right must be the same type");
    }
    private static Class<?> getPrimitiveType(ByteCodeExpression expressionString name)
    {
        checkNotNull(expressionname + " is null");
        Class<?> leftType = expression.getType().getPrimitiveType();
        checkArgument(leftType != nullname + " is not a primitive");
        checkArgument(leftType != void.classname + " is void");
        return leftType;
    }
    private final String infixSymbol;
    private OpCode comparisonInstruction;
    private final ByteCodeExpression left;
    private final ByteCodeExpression right;
            String infixSymbol,
            OpCode comparisonInstruction,
            OpCode noMatchJumpInstruction,
            ByteCodeExpression left,
            ByteCodeExpression right)
    {
        super(type(boolean.class));
        this. = infixSymbol;
        this. = comparisonInstruction;
        this. = noMatchJumpInstruction;
        this. = left;
        this. = right;
    }
    @Override
    public ByteCodeNode getByteCode()
    {
        Block block = new Block(null)
                .append()
                .append();
        if ( != null) {
            block.append();
        }
        LabelNode noMatch = new LabelNode("no_match");
        LabelNode end = new LabelNode("end");
        return block
                .append(new JumpInstruction(noMatch))
                .push(true)
                .gotoLabel(end)
                .append(noMatch)
                .push(false)
                .append(end);
    }
    @Override
    public List<ByteCodeNodegetChildNodes()
    {
        return ImmutableList.<ByteCodeNode>of();
    }
    @Override
    protected String formatOneLine()
    {
        return "(" +  + " " +  + " " +  + ")";
    }
New to GrepCode? Check out our FAQ X