001    /*
002     *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003     *
004     *  This file is licensed to You under the Eclipse Public License (EPL);
005     *  You may not use this file except in compliance with the License. You
006     *  may obtain a copy of the License at
007     *
008     *      http://www.opensource.org/licenses/eclipse-1.0.php
009     *
010     *  See the COPYRIGHT.txt file distributed with this work for information
011     *  regarding copyright ownership.
012     */
013    package org.jikesrvm.compilers.opt.ir.operand;
014    
015    import org.jikesrvm.classloader.TypeReference;
016    
017    /**
018     * This operand represents a "true" guard.
019     * Eg non-nullness of the result of an allocation or
020     * boundcheck eliminate via analysis of the loop induction variables.
021     *
022     * @see Operand
023     */
024    public final class TrueGuardOperand extends ConstantOperand {
025    
026      /**
027       * Return the {@link TypeReference} of the value represented by the operand.
028       *
029       * @return TypeReference.VALIDATION_TYPE
030       */
031      public TypeReference getType() {
032        return TypeReference.VALIDATION_TYPE;
033      }
034    
035      /**
036       * Return a new operand that is semantically equivalent to <code>this</code>.
037       *
038       * @return a copy of <code>this</code>
039       */
040      public Operand copy() {
041        return new TrueGuardOperand();
042      }
043    
044      /**
045       * Are two operands semantically equivalent?
046       *
047       * @param op other operand
048       * @return   <code>true</code> if <code>this</code> and <code>op</code>
049       *           are semantically equivalent or <code>false</code>
050       *           if they are not.
051       */
052      public boolean similar(Operand op) {
053        return op instanceof TrueGuardOperand;
054      }
055    
056      /**
057       * Returns the string representation of this operand.
058       *
059       * @return a string representation of this operand.
060       */
061      public String toString() {
062        return "<TRUEGUARD>";
063      }
064    }