KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > frontend > ExtensionInfo


1 package polyglot.frontend;
2
3 import polyglot.ast.*;
4 import polyglot.types.*;
5 import polyglot.util.*;
6 import java.io.*;
7 import java.util.*;
8 import polyglot.main.Options;
9
10 /**
11  * <code>ExtensionInfo</code> is the main interface for defining language
12  * extensions. The frontend will load the <code>ExtensionInfo</code>
13  * specified on the command-line. It defines the type system, AST node
14  * factory, parser, and other parameters of a language extension.
15  */

16 public interface ExtensionInfo {
17     /** The name of the compiler for usage messages */
18     String JavaDoc compilerName();
19
20     /** Report the version of the extension. */
21     polyglot.main.Version version();
22
23     /**
24      * Return an Options object, which will be given the command line to parse.
25      */

26     Options getOptions();
27
28     /**
29      * Return a Stats object to accumulate and report statistics.
30      */

31     Stats getStats();
32
33     /**
34      * Initialize the extension with a particular compiler. This must
35      * be called after the compiler is initialized, but before the compiler
36      * starts work.
37      */

38     void initCompiler(polyglot.frontend.Compiler compiler);
39
40     Compiler JavaDoc compiler();
41
42     /** The extensions that source files are expected to have.
43      * Defaults to the array defaultFileExtensions. */

44     String JavaDoc[] fileExtensions();
45
46     /** The default extensions that source files are expected to have.
47      * Defaults to an array containing defaultFileExtension */

48     String JavaDoc[] defaultFileExtensions();
49
50     /** The default extension that source files are expected to have. */
51     String JavaDoc defaultFileExtension();
52
53     /** Produce a type system for this language extension. */
54     TypeSystem typeSystem();
55
56     /** Produce a node factory for this language extension. */
57     NodeFactory nodeFactory();
58
59     /** Produce a source factory for this language extension. */
60     SourceLoader sourceLoader();
61
62     /**
63      * Adds a dependency from the current job to the given Source.
64      */

65     void addDependencyToCurrentJob(Source s);
66     
67     /**
68      * Produce a job for the given source. A new job will be created if
69      * needed. If the <code>Source source</code> has already been processed,
70      * and its job discarded to release resources, then <code>null</code>
71      * will be returned.
72      */

73     SourceJob addJob(Source source);
74
75     /**
76      * Produce a job for a given source using the given AST.
77      * A new job will be created if
78      * needed. If the <code>Source source</code> has already been processed,
79      * and its job discarded to release resources, then <code>null</code>
80      * will be returned.
81      */

82     SourceJob addJob(Source source, Node ast);
83
84     /**
85      * Spawn a new job. All passes between the pass <code>begin</code>
86      * and <code>end</code> inclusive will be performed immediately on
87      * the AST <code>ast</code>.
88      *
89      * @param c the context that the AST occurs in
90      * @param ast the AST the new Job is for.
91      * @param outerJob the <code>Job</code> that spawned this job.
92      * @param begin the first pass to perform for this job.
93      * @param end the last pass to perform for this job.
94      * @return the new job. The caller can check the result with
95      * <code>j.status()</code> and get the ast with <code>j.ast()</code>.
96      */

97     Job spawnJob(Context c, Node ast, Job outerJob, Pass.ID begin, Pass.ID end);
98
99     /** Run all jobs to completion. */
100     boolean runToCompletion();
101
102     /** Run the given job up to a given pass. */
103     boolean runToPass(Job job, Pass.ID goal) throws CyclicDependencyException;
104
105     /** Run the given job to completion. */
106     boolean runAllPasses(Job job);
107
108     /** Read a source file and compile up to the current job's barrier. */
109     boolean readSource(FileSource source);
110
111     /**
112      * Produce a target factory for this language extension. The target
113      * factory is responsible for naming and opening output files given a
114      * package name and a class or source file name.
115      */

116     TargetFactory targetFactory();
117
118     /** Get a parser for this language extension. */
119     Parser parser(Reader reader, FileSource source, ErrorQueue eq);
120
121     /** Get the list of passes for a given source job. */
122     List passes(Job job);
123
124     /** Get the sublist of passes for a given job. */
125     List passes(Job job, Pass.ID begin, Pass.ID end);
126
127     /** Add a pass before an existing pass. */
128     void beforePass(List passes, Pass.ID oldPass, Pass newPass);
129
130     /** Add a list of passes before an existing pass. */
131     void beforePass(List passes, Pass.ID oldPass, List newPasses);
132
133     /** Add a pass after an existing pass. */
134     void afterPass(List passes, Pass.ID oldPass, Pass newPass);
135
136     /** Add a list of passes after an existing pass. */
137     void afterPass(List passes, Pass.ID oldPass, List newPasses);
138
139     /** Replace an existing pass with a new pass. */
140     void replacePass(List passes, Pass.ID oldPass, Pass newPass);
141
142     /** Replace an existing pass with a list of new passes. */
143     void replacePass(List passes, Pass.ID oldPass, List newPasses);
144
145     /** Remove a pass. The removed pass cannot be a barrier. */
146     void removePass(List passes, Pass.ID oldPass);
147 }
148
Popular Tags