KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > frontend > Pass


1 package polyglot.frontend;
2
3 import polyglot.util.Enum;
4
5 /** A <code>Pass</code> represents a compiler pass.
6  * A <code>Job</code> runs a series of passes over the AST.
7  * Each pass has an ID that is used to identify similar passes across
8  * several jobs. For example, most jobs contain a pass named PARSE
9  * that returns an AST for a source file and a pass TYPE_CHECK
10  * that performs type checking on the job's AST.
11  */

12 public interface Pass
13 {
14     /** Pass identifiers. These should be unique within a Job. */
15     public static class ID extends Enum JavaDoc {
16         public ID(String JavaDoc name) { super(name); }
17     }
18
19     /** Return the identifier for the pass.
20      * The identifier should be unique within the pass's Job.
21      */

22     public ID id();
23
24     /** Return a user-readable name for the pass. */
25     public String JavaDoc name();
26
27     /** Run the pass. */
28     public boolean run();
29
30     /** Reset the pass timers to 0. */
31     public void resetTimers();
32
33     /** Start/stop the pass timers. */
34     public void toggleTimers(boolean exclusive_only);
35
36     /** The total accumulated time in ms since the last timer reset
37       * that the pass was running, including spawned passes. */

38     public long inclusiveTime();
39
40     /** The total accumulated time in ms since the last timer reset
41       * that the pass was running, excluding spawned passes. */

42     public long exclusiveTime();
43
44     // Below are the IDs of all the passes of the base compiler,
45
// plus a few optional passes that extensions may use.
46

47     /** ID of the parser pass. See Parser. */
48     public static final ID PARSE = new ID("parse");
49
50     /** ID of the build-types pass. See TypeBuilder. */
51     public static final ID BUILD_TYPES = new ID("build-types");
52
53     /** ID of the barrier after build-types. */
54     public static final ID BUILD_TYPES_ALL = new ID("build-types-barrier");
55
56     /** ID of the clean-super pass. See AmbiguityRemover. */
57     public static final ID CLEAN_SUPER = new ID("clean-super");
58
59     /** ID of the barrier after clean-super. */
60     public static final ID CLEAN_SUPER_ALL = new ID("clean-super-barrier");
61
62     /** ID of the clean-sigs pass. See AmbiguityRemover. */
63     public static final ID CLEAN_SIGS = new ID("clean-sigs");
64
65     /** ID of the add-members pass. See AddMemberVisitor. */
66     public static final ID ADD_MEMBERS = new ID("add-members");
67
68     /** ID of the barrier after add-members. */
69     public static final ID ADD_MEMBERS_ALL = new ID("add-members-barrier");
70
71     /** ID of the disambiguate pass. See AmbiguityRemover. */
72     public static final ID DISAM = new ID("disam");
73
74     /** ID of the barrier after disam. */
75     public static final ID DISAM_ALL = new ID("disam-barrier");
76
77     /** ID of the type-check pass. See TypeChecker. */
78     public static final ID TYPE_CHECK = new ID("type-check");
79
80     /** ID of the set-expected-types pass. See AscriptionVisitor. */
81     public static final ID SET_EXPECTED_TYPES = new ID("set-expected-types");
82
83     /** ID of the exception-check pass. See ExceptionChecker. */
84     public static final ID EXC_CHECK = new ID("exc-check");
85
86     /** ID of the constant-fold pass. See ConstantFolder. */
87     public static final ID FOLD = new ID("fold");
88
89     /** ID of the initialization-check pass. See InitChecker. */
90     public static final ID INIT_CHECK = new ID("init-check");
91
92     /** ID of the constructor-check pass. See ConstructorChecker. */
93     public static final ID CONSTRUCTOR_CHECK = new ID("constructor-check");
94
95     /** ID of the forward-reference-check pass. See FwdReferenceChecker. */
96     public static final ID FWD_REF_CHECK = new ID("fwd-reference-check");
97
98     /** ID of the reachability-check pass. See ReachChecker. */
99     public static final ID REACH_CHECK = new ID("reach-check");
100
101     /** ID of the exit-check pass. See ExitChecker. */
102     public static final ID EXIT_CHECK = new ID("exit-check");
103
104     /** ID of the AST dumper pass. See DumpAST. */
105     public static final ID DUMP = new ID("dump");
106
107     /** ID of the barrier before output. */
108     public static final ID PRE_OUTPUT_ALL = new ID("pre-output-barrier");
109
110     /** ID of the class serialzation pass. See ClassSerializer. */
111     public static final ID SERIALIZE = new ID("serialization");
112
113     /** ID of the output pass. See OutputPass. */
114     public static final ID OUTPUT = new ID("output");
115
116     /** ID of the first barrier pass. */
117     public static final ID FIRST_BARRIER = BUILD_TYPES_ALL;
118 }
119
Popular Tags