KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ext > jl > ast > AmbReceiver_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 /**
9  * An <code>AmbReceiver</code> is an ambiguous AST node composed of
10  * dot-separated list of identifiers that must resolve to a receiver.
11  */

12 public class AmbReceiver_c extends AmbPrefix_c implements AmbReceiver
13 {
14     protected Type type;
15
16     public AmbReceiver_c(Position pos, Prefix prefix, String JavaDoc name) {
17     super(pos, prefix, name);
18     }
19
20     public Type type() {
21             return this.type;
22     }
23
24     public AmbReceiver type(Type type) {
25             AmbReceiver_c n = (AmbReceiver_c) copy();
26             n.type = type;
27             return n;
28     }
29
30     public Node buildTypes(TypeBuilder tb) throws SemanticException {
31         return type(tb.typeSystem().unknownType(position()));
32     }
33
34     /** Disambiguate the receiver. */
35     public Node disambiguate(AmbiguityRemover ar) throws SemanticException {
36     Node n = super.disambiguate(ar);
37
38     if (n instanceof Receiver) {
39         return n;
40     }
41
42     throw new SemanticException("Could not find type, field, or " +
43         "local variable \"" +
44             (prefix == null ? name : prefix.toString() + "." + name) +
45             "\".", position());
46     }
47 }
48
Popular Tags