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; 016import org.vmmagic.unboxed.Offset; 017 018/** 019 * Represents a constant string operand. 020 * 021 * @see Operand 022 */ 023public final class StringConstantOperand extends ObjectConstantOperand { 024 025 /** 026 * Construct a new string constant operand 027 * 028 * @param v the string constant 029 * @param i JTOC offset of the string constant 030 */ 031 public StringConstantOperand(String v, Offset i) { 032 super(v, i); 033 } 034 035 @Override 036 public Operand copy() { 037 return new StringConstantOperand((String) value, offset); 038 } 039 040 /** 041 * @return {@link TypeReference#JavaLangString} 042 */ 043 @Override 044 public TypeReference getType() { 045 return TypeReference.JavaLangString; 046 } 047 048 /** 049 * Returns the string representation of this operand. 050 * 051 * @return a string representation of this operand. 052 */ 053 @Override 054 public String toString() { 055 return "string \"" + value + "\""; 056 } 057}