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    import org.vmmagic.unboxed.Offset;
017    
018    /**
019     * Represents a constant class operand.
020     *
021     * @see Operand
022     */
023    public final class ClassConstantOperand extends ObjectConstantOperand {
024    
025      /**
026       * Construct a new class constant operand
027       *
028       * @param v the class constant
029       * @param i JTOC offset of the class constant
030       */
031      public ClassConstantOperand(Class<?> v, Offset i) {
032        super(v, i);
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 ClassConstantOperand((Class<?>) value, offset);
042      }
043    
044      /**
045       * Return the {@link TypeReference} of the value represented by the operand.
046       *
047       * @return TypeReference.JavaLangClass
048       */
049      public TypeReference getType() {
050        return TypeReference.JavaLangClass;
051      }
052    
053      /**
054       * Returns the string representation of this operand.
055       *
056       * @return a string representation of this operand.
057       */
058      public String toString() {
059        return "class \"" + value + "\"";
060      }
061    }