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 */
013package org.jikesrvm.compilers.opt.ir.operand;
014
015import org.jikesrvm.classloader.TypeReference;
016
017/**
018 * This operand represents the {@code null} constant.
019 *
020 * @see Operand
021 */
022public final class NullConstantOperand extends ConstantOperand {
023
024  @Override
025  public Operand copy() {
026    return new NullConstantOperand();
027  }
028
029  /**
030   * @return TypeReference.NULL_TYPE
031   */
032  @Override
033  public TypeReference getType() {
034    return TypeReference.NULL_TYPE;
035  }
036
037  /**
038   * @return <code>true</code>
039   */
040  @Override
041  public boolean isRef() {
042    return true;
043  }
044
045  /**
046   * @return <code>true</code>
047   */
048  @Override
049  public boolean isDefinitelyNull() {
050    return true;
051  }
052
053  @Override
054  public boolean similar(Operand op) {
055    return op instanceof NullConstantOperand;
056  }
057
058  /**
059   * Returns the string representation of this operand.
060   *
061   * @return a string representation of this operand.
062   */
063  @Override
064  public String toString() {
065    return "<null>";
066  }
067}