verify.cc (type::to_array): New method.
authorTom Tromey <tromey@redhat.com>
Mon, 19 Nov 2001 07:08:36 +0000 (07:08 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Mon, 19 Nov 2001 07:08:36 +0000 (07:08 +0000)
* verify.cc (type::to_array): New method.
(_Jv_BytecodeVerifier::verify_instructions_0) [op_anewarray]:
Construct new array type.

From-SVN: r47165

libjava/ChangeLog
libjava/verify.cc

index 39670efbf7bb01901946933c9ab9fdc3a54f3e8b..af02f3ecf6d557b51e6a244a9cb48db111d83cdf 100644 (file)
@@ -1,5 +1,9 @@
 2001-11-18  Tom Tromey  <tromey@redhat.com>
 
+       * verify.cc (type::to_array): New method.
+       (_Jv_BytecodeVerifier::verify_instructions_0) [op_anewarray]:
+       Construct new array type.
+
        * verify.cc (_Jv_BytecodeVerifier::branch_prepass) [op_sipush]:
        Skip a short, not a byte.
        [op_newarray]: Skip a byte, not a short.
index 423edaa1609b41878a998129c919477730a160a6..8c290a38d2850c4d38c319eeaee1df65abb36b38 100644 (file)
@@ -491,6 +491,23 @@ private:
       return type (k);
     }
 
+    // Return the array type corresponding to an initialized
+    // reference.  We could expand this to work for other kinds of
+    // types, but currently we don't need to.
+    type to_array ()
+    {
+      // Resolving isn't ideal, because it might force us to load
+      // another class, but it's easy.  FIXME?
+      if (key == unresolved_reference_type)
+       resolve ();
+
+      if (key == reference_type)
+       return type (_Jv_GetArrayClass (data.klass,
+                                       data.klass->getClassLoader ()));
+      else
+       verify_fail ("internal error in type::to_array()");
+    }
+
     bool isreference () const
     {
       return key >= reference_type;
@@ -2426,7 +2443,7 @@ private:
            break;
          case op_anewarray:
            pop_type (int_type);
-           push_type (check_class_constant (get_ushort ()));
+           push_type (check_class_constant (get_ushort ()).to_array ());
            break;
          case op_arraylength:
            {