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.regalloc;
014
015/**
016 * A basic interval contained in a CompoundInterval.
017 */
018class MappedBasicInterval extends BasicInterval {
019  final CompoundInterval container;
020
021  MappedBasicInterval(BasicInterval b, CompoundInterval c) {
022    super(b.begin, b.end);
023    this.container = c;
024  }
025
026  MappedBasicInterval(int begin, int end, CompoundInterval c) {
027    super(begin, end);
028    this.container = c;
029  }
030
031  @Override
032  public boolean equals(Object o) {
033    if (super.equals(o)) {
034      MappedBasicInterval i = (MappedBasicInterval) o;
035      return container == i.container;
036    } else {
037      return false;
038    }
039  }
040
041  // Note that it is not necessary to overwrite hashCode() because
042  // it need only be the case that equal objects have equal hash codes
043  // which is already handled by BasicInterval.
044
045  @Override
046  public String toString() {
047    return "<" + container.getRegister() + ">:" + super.toString();
048  }
049
050}