KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ext > pao > types > PaoParsedClassType_c


1 package polyglot.ext.pao.types;
2
3 import polyglot.ext.jl.types.ParsedClassType_c;
4 import polyglot.frontend.Source;
5 import polyglot.types.LazyClassInitializer;
6 import polyglot.types.Type;
7 import polyglot.types.TypeSystem;
8
9 /**
10  * A PAO class type. This class overrides the method
11  * {@link #isCastValidImpl(Type) isCastValidImpl(Type)} to allow casting from
12  * <code>Object</code> to primitives.
13  */

14 public class PaoParsedClassType_c extends ParsedClassType_c {
15     protected PaoParsedClassType_c() {
16         super();
17     }
18
19     public PaoParsedClassType_c(TypeSystem ts, LazyClassInitializer init,
20             Source fromSource) {
21         super(ts, init, fromSource);
22     }
23
24     /**
25      * Returns <code>true</code> if normal casting rules permit this cast, or
26      * if this <code>ClassType</code> is <code>Object</code> and the
27      * <code>toType</code> is a primitive.
28      *
29      * @see polyglot.ext.jl.types.ClassType_c#isCastValidImpl(Type)
30      */

31     public boolean isCastValidImpl(Type toType) {
32         return toType.isPrimitive() && ts.equals(this, ts.Object())
33                 || super.isCastValidImpl(toType);
34     }
35 }
Popular Tags