001 /* Copyright 2000, 2001, Compaq Computer Corporation */
002
003 package escjava.translate;
004
005 import java.io.*;
006 import java.util.Enumeration;
007 import javafe.ast.*;
008 import javafe.util.*;
009 import escjava.ast.*;
010 import escjava.ast.TagConstants;
011
012
013 public class LabelInfoToString {
014
015 /** set of <code>String</code>, each one of which has the format
016 * filename:line:col and has been interned.
017 **/
018
019 private static Set annotationLocations = new Set();
020 private static Set theMark = new Set();
021
022 public static void reset() {
023 annotationLocations.clear();
024 theMark.clear();
025 }
026
027 public static void mark() {
028 theMark = annotationLocations;
029 annotationLocations = new Set();
030 }
031
032 public static void resetToMark() {
033 annotationLocations = new Set(theMark.elements());
034 }
035
036 public static String get() {
037 StringBuffer sb = new StringBuffer();
038 for (Enumeration annotations = annotationLocations.elements();
039 annotations.hasMoreElements(); ) {
040 String location = (String)annotations.nextElement();
041 sb.append(' ');
042 sb.append(location);
043 }
044 return sb.toString();
045 }
046
047 public static void recordAnnotationAssumption(int locPragmaDecl) {
048 if (escjava.Main.options().printAssumers && locPragmaDecl != Location.NULL) {
049 String location = Location.toFileName(locPragmaDecl) + ':' +
050 Location.toLineNumber(locPragmaDecl) + ':' +
051 Location.toColumn(locPragmaDecl);
052 annotationLocations.add(location.intern());
053 }
054 }
055 }