KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > frontend > SourceJob


1 package polyglot.frontend;
2
3 import polyglot.ast.*;
4
5 import java.util.*;
6
7 /**
8  * A <code>SourceJob</code> encapsulates work done by the compiler on behalf of
9  * one source file. It includes all information carried between phases
10  * of the compiler.
11  */

12 public class SourceJob extends Job
13 {
14     /**
15      * The <code>Source</code> that this <code>Job</code> is for.
16      */

17     protected Source source;
18
19     /**
20      * Set of <code>Source</code>s that this SourceJob depends upon.
21      * This will include, but is not limited to, the other Sources that
22      * this SourceJob caused to load.
23      */

24     protected Set dependencies;
25
26     /**
27      * Set of <code>Source</code>s that depend on this job.
28      */

29     protected Set dependents;
30
31     /**
32      * Constructor
33      */

34     public SourceJob(ExtensionInfo lang,
35                      JobExt ext,
36                      Source source,
37                      Node ast) {
38         super(lang, ext, ast);
39
40         this.source = source;
41         this.dependencies = new HashSet();
42         this.dependents = new HashSet();
43
44     }
45
46     public Set dependencies() {
47         return dependencies;
48     }
49     
50     public Set dependents() {
51         return dependents;
52     }
53
54     public void addDependent(Source s) {
55         if (s != this.source()) {
56             dependents.add(s);
57         }
58     }
59
60     public void addDependency(Source s) {
61         if (s != this.source()) {
62             dependencies.add(s);
63         }
64     }
65
66     /**
67      * The initial list of passes is just the list that the language extension
68      * provides us with.
69      */

70     public List getPasses() {
71         return lang.passes(this);
72     }
73
74     public Source source() {
75         return source;
76     }
77
78     public SourceJob sourceJob() {
79     return this;
80     }
81
82     public String JavaDoc toString() {
83         return source.toString() + " (" +
84             (completed() ? "done"
85                     : ((isRunning() ? "running "
86                                     : "before ") + nextPass())) + ")";
87     }
88 }
89
Popular Tags