View Javadoc

1   // jq_Initializer.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   //friend jq_ClassLoader;
7   
8   import joeq.UTF.Utf8;
9   import jwutil.util.Assert;
10  
11  /*
12   * @author  John Whaley <jwhaley@alum.mit.edu>
13   * @version $Id: jq_Initializer.java 1931 2004-09-22 22:17:47Z joewhaley $
14   */
15  public final class jq_Initializer extends jq_InstanceMethod {
16  
17      // clazz, name, desc are inherited
18      
19      private jq_Initializer(jq_Class clazz, jq_NameAndDesc nd) {
20          super(clazz, nd);
21      }
22      // ONLY TO BE CALLED BY jq_ClassLoader!!!
23      static jq_Initializer newInitializer(jq_Class clazz, jq_NameAndDesc nd) {
24          Assert._assert(nd.getName() == Utf8.get("<init>"));
25          return new jq_Initializer(clazz, nd);
26      }
27      protected final void parseMethodSignature() {
28          Utf8.MethodDescriptorIterator i = nd.getDesc().getParamDescriptors();
29          // count them up
30          int num = 1, words = 1;
31          while (i.hasNext()) { i.nextUtf8(); ++num; }
32          // get them for real
33          param_types = new jq_Type[num];
34          param_types[0] = clazz;
35          i = nd.getDesc().getParamDescriptors();
36          for (int j=1; j<num; ++j) {
37              Utf8 pd = i.nextUtf8();
38              param_types[j] = PrimordialClassLoader.getOrCreateType(clazz.getClassLoader(), pd);
39              ++words;
40              if ((param_types[j] == jq_Primitive.LONG) ||
41                  (param_types[j] == jq_Primitive.DOUBLE)) ++words;
42          }
43          param_words = words;
44          return_type = jq_Primitive.VOID;
45      }
46  
47      public final jq_InstanceMethod resolve1() {
48          this.clazz.load();
49          if (this.state >= STATE_LOADED) return this;
50          throw new NoSuchMethodError(this.toString());
51      }
52      
53      public final boolean isInitializer() { return true; }
54  
55      public final void accept(jq_MethodVisitor mv) {
56          mv.visitInitializer(this);
57          super.accept(mv);
58      }
59      
60      public static final jq_Class _class;
61      static {
62          _class = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljoeq/Class/jq_Initializer;");
63      }
64  }