KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ext > jl > types > PlaceHolder_c


1 package polyglot.ext.jl.types;
2
3 import polyglot.types.*;
4 import polyglot.util.*;
5
6 /**
7  * A place holder type when serializing the Polylgot type information.
8  * When serializing the type information for some class <code>C</code>,
9  * Placeholders are used to prevent serializing the class type information
10  * for classes that <code>C</code> depends on.
11  */

12 public class PlaceHolder_c implements PlaceHolder
13 {
14     /**
15      * The name of the place holder.
16      */

17     String JavaDoc name;
18
19     /** Used for deserializing types. */
20     protected PlaceHolder_c() { }
21     
22     /** Creates a place holder type for the type. */
23     public PlaceHolder_c(Type t) {
24     if (t.isClass()) {
25             name = t.typeSystem().getTransformedClassName(t.toClass());
26         }
27     else {
28         throw new InternalCompilerError("Cannot serialize " + t + ".");
29     }
30     }
31
32     /** Restore the placeholder into a proper type. */
33     public TypeObject resolve(TypeSystem ts) {
34         try {
35             return ts.systemResolver().find(name);
36     } catch (SemanticException se) {
37         throw new InternalCompilerError(se);
38     }
39     }
40
41     public String JavaDoc translate(Resolver c) {
42     throw new InternalCompilerError("Cannot translate place holder type.");
43     }
44
45     public String JavaDoc toString() {
46     return "PlaceHolder(" + name + ")";
47     }
48 }
49
Popular Tags