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.dfsolver;
014
015import java.util.HashMap;
016
017/**
018 * Represents the solution to a system of Data Flow equations.
019 * Namely, a function mapping Objects to DF_LatticeCells
020 */
021public class DF_Solution extends HashMap<Object, DF_LatticeCell> {
022  /** Support for serialization */
023  static final long serialVersionUID = -335649266901802532L;
024
025  /**
026   * Return a string representation of the dataflow solution
027   * @return a string representation of the dataflow solution
028   */
029  @Override
030  public String toString() {
031    StringBuilder result = new StringBuilder();
032    for (DF_LatticeCell cell : values()) {
033      result.append(cell);
034      result.append("\n");
035    }
036    return result.toString();
037  }
038
039  /**
040   * Return the lattice cell corresponding to an object
041   * @param k the object to look up
042   * @return its lattice cell
043   */
044  public Object lookup(Object k) {
045    return get(k);
046  }
047}