KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ext > jl > ast > Term_c


1 package polyglot.ext.jl.ast;
2
3 import polyglot.ast.*;
4 import polyglot.types.*;
5 import polyglot.visit.*;
6 import polyglot.util.*;
7
8 import java.util.*;
9
10 /**
11  * A <code>Term</code> represents any Java expression or statement on which
12  * dataflow can be performed.
13  */

14 public abstract class Term_c extends Node_c implements Term
15 {
16     public Term_c(Position pos) {
17     super(pos);
18     }
19     
20     protected boolean reachable;
21
22     /**
23      * Return the first (sub)term performed when evaluating this
24      * term.
25      */

26     public abstract Term entry();
27
28     /**
29      * Visit this term in evaluation order.
30      */

31     public abstract List acceptCFG(CFGBuilder v, List succs);
32
33     /**
34      * Return true if this term is eachable. This attribute is not
35      * guaranteed correct until after the reachability pass
36      *
37      * @see polyglot.visit.ReachChecker
38      */

39     public boolean reachable() {
40         return reachable;
41     }
42
43     /**
44      * Set the reachability of this term.
45      */

46     public Term reachable(boolean reachability) {
47         if (this.reachable == reachability) {
48             return this;
49         }
50         
51         Term_c t = (Term_c) copy();
52         t.reachable = reachability;
53         return t;
54     }
55
56     /** Utility function to get the first entry of a list, or else alt. */
57     public static Term listEntry(List l, Term alt) {
58         Term c = (Term) CollectionUtil.firstOrElse(l, alt);
59         if (c != alt) return c.entry();
60         return alt;
61     }
62     
63     protected SubtypeSet exceptions;
64     
65     public SubtypeSet exceptions() {
66         return exceptions;
67     }
68     
69     public Term exceptions(SubtypeSet exceptions) {
70         Term_c n = (Term_c) copy();
71         n.exceptions = new SubtypeSet(exceptions);
72         return n;
73     }
74     
75     public Node exceptionCheck(ExceptionChecker ec) throws SemanticException {
76         Term t = (Term) super.exceptionCheck(ec);
77         //System.out.println("exceptions for " + t + " = " + ec.throwsSet());
78
return t.exceptions(ec.throwsSet());
79     }
80 }
81
Popular Tags