View Javadoc

1   // jq_Primitive.java, created Mon Feb  5 23:23:20 2001 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.Class;
5   
6   import joeq.UTF.Utf8;
7   
8   /*
9    * @author  John Whaley <jwhaley@alum.mit.edu>
10   * @version $Id: jq_Primitive.java 1931 2004-09-22 22:17:47Z joewhaley $
11   */
12  public class jq_Primitive extends jq_Type implements jq_ClassFileConstants {
13  
14      public final boolean isClassType() { return false; }
15      public final boolean isArrayType() { return false; }
16      public final boolean isPrimitiveType() { return true; }
17      public final boolean isAddressType() { return false; }
18      public final String getName() { return name; }
19      public final String shortName() { return name; }
20      public final String getJDKDesc() { return desc.toString(); }
21      public final int getReferenceSize() { return size; }
22      public final ClassLoader getClassLoader() { return PrimordialClassLoader.loader; }
23      public final boolean isIntLike() {
24          return this == jq_Primitive.INT || this == jq_Primitive.BOOLEAN || this == jq_Primitive.BYTE ||
25                 this == jq_Primitive.CHAR || this == jq_Primitive.SHORT;
26      }
27      
28      public final boolean isLoaded() { return true; }
29      public final boolean isVerified() { return true; }
30      public final boolean isPrepared() { return true; }
31      public final boolean isSFInitialized() { return true; }
32      public final boolean isCompiled() { return true; }
33      public final boolean isClsInitRunning() { return true; }
34      public final boolean isClsInitialized() { return true; }
35      
36      public final void load() { }
37      public final void verify() { }
38      public final void prepare() { }
39      public final void sf_initialize() { }
40      public final void compile() { }
41      public final void cls_initialize() { }
42      
43      public final boolean isFinal() { return true; }
44      
45      public final int getDepth() { return -1; }
46      public final boolean isInstance(Object o) { return false; }
47      
48      public void accept(jq_TypeVisitor tv) {
49          tv.visitPrimitive(this);
50          super.accept(tv);
51      }
52      
53      private final String name;
54      private final int size;
55      
56      /*** Creates new jq_Primitive */
57      private jq_Primitive(Utf8 desc, String name, int size) {
58          super(desc, PrimordialClassLoader.loader);
59          this.name = name;
60          this.size = size;
61          this.display = new jq_Type[DISPLAY_SIZE+2];
62          this.display[2] = this;
63          this.s_s_array = null;
64          this.s_s_array_length = 0;
65      }
66      // ONLY to be called by PrimordialClassLoader!
67      public static jq_Primitive newPrimitive(Utf8 desc, String name, int size) {
68          return new jq_Primitive(desc, name, size);
69      }
70  
71      public static final jq_Primitive BYTE   = (jq_Primitive)PrimordialClassLoader.loader.getOrCreateBSType(Utf8.BYTE_DESC);
72      public static final jq_Primitive CHAR   = (jq_Primitive)PrimordialClassLoader.loader.getOrCreateBSType(Utf8.CHAR_DESC);
73      public static final jq_Primitive DOUBLE = (jq_Primitive)PrimordialClassLoader.loader.getOrCreateBSType(Utf8.DOUBLE_DESC);
74      public static final jq_Primitive FLOAT  = (jq_Primitive)PrimordialClassLoader.loader.getOrCreateBSType(Utf8.FLOAT_DESC);
75      public static final jq_Primitive INT    = (jq_Primitive)PrimordialClassLoader.loader.getOrCreateBSType(Utf8.INT_DESC);
76      public static final jq_Primitive LONG   = (jq_Primitive)PrimordialClassLoader.loader.getOrCreateBSType(Utf8.LONG_DESC);
77      public static final jq_Primitive SHORT  = (jq_Primitive)PrimordialClassLoader.loader.getOrCreateBSType(Utf8.SHORT_DESC);
78      public static final jq_Primitive BOOLEAN = (jq_Primitive)PrimordialClassLoader.loader.getOrCreateBSType(Utf8.BOOLEAN_DESC);
79      public static final jq_Primitive VOID   = (jq_Primitive)PrimordialClassLoader.loader.getOrCreateBSType(Utf8.VOID_DESC);
80      
81      public static final jq_Class _class = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljoeq/Class/jq_Primitive;");
82  }