// $Id: DelocalizedStringImmed.java,v 1.2 1999/12/07 06:34:58 golem Exp $

package IR2;

public class DelocalizedStringImmed implements DelocalizedRValue {
  private String value;
  private int location;

  public DelocalizedStringImmed(String v) {
    value = v;
    location = -1;
  }

  /* DelocalizedRValue */
  // The proxy is a "real" variable to use instead of this "imaginary" one.
  //protected DelocalizedRValue proxy = null;
  //public DelocalizedRValue rproxy() {
  //  return proxy != null ? proxy.rproxy() : this;
  //}

  // Currently we're lame about proxying string addresses as
  // DelocalizedImmedExprs, because we don't know where the address
  // is until after the proxying stage is over (I think).
  public DelocalizedRValue rproxy() { return this; }

  public void load_into_reg(Codegen c, DelocalizedRegister r) {
    if (location == -1)
      location = c.allocate_string(value);
    c.generate_load_address(r, location);
  }

}
