KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > frontend > OutputPass


1 package polyglot.frontend;
2
3 import polyglot.ast.*;
4 import polyglot.frontend.*;
5 import polyglot.types.*;
6 import polyglot.util.*;
7 import polyglot.visit.*;
8 import polyglot.types.Package;
9
10 import java.io.*;
11 import java.util.*;
12
13 /** An output pass generates output code from the processed AST. */
14 public class OutputPass extends AbstractPass
15 {
16     protected Job job;
17     protected Translator translator;
18
19     /**
20      * Create a Translator. The output of the visitor is a collection of files
21      * whose names are added to the collection <code>outputFiles</code>.
22      */

23     public OutputPass(Pass.ID id, Job job, Translator translator) {
24     super(id);
25         this.job = job;
26         this.translator = translator;
27     }
28
29     public boolean run() {
30         Node ast = job.ast();
31
32         if (ast == null) {
33             throw new InternalCompilerError("AST is null");
34         }
35
36         return translator.translate(ast);
37     }
38 }
39
Popular Tags