This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: Use enum for opcode in verifier
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 25 Nov 2001 12:49:08 -0700
- Subject: Patch: FYI: Use enum for opcode in verifier
- Reply-to: tromey at redhat dot com
I'm checking this in. This changes the verifier to use an enum for
the switch types. It cleans up the code a little bit.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* verify.cc (_Jv_BytecodeVerifier::branch_prepass): Use
java_opcode as type for switch.
[op_wide]: Likewise.
(_Jv_BytecodeVerifier::verify_instructions_0): Likewise.
[op_invokevirtual]: Likewise.
* include/java-insns.h (java_opcode): Give enum a name.
Index: verify.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/verify.cc,v
retrieving revision 1.16
diff -u -r1.16 verify.cc
--- verify.cc 2001/11/20 05:16:17 1.16
+++ verify.cc 2001/11/25 19:46:15
@@ -1221,7 +1221,7 @@
last_was_jsr = false;
start_PC = PC;
- unsigned char opcode = bytecode[PC++];
+ java_opcode opcode = (java_opcode) bytecode[PC++];
switch (opcode)
{
case op_nop:
@@ -1472,9 +1472,9 @@
case op_wide:
{
- opcode = get_byte ();
+ opcode = (java_opcode) get_byte ();
get_short ();
- if (opcode == (unsigned char) op_iinc)
+ if (opcode == op_iinc)
get_short ();
}
break;
@@ -1777,7 +1777,7 @@
}
start_PC = PC;
- unsigned char opcode = bytecode[PC++];
+ java_opcode opcode = (java_opcode) bytecode[PC++];
switch (opcode)
{
case op_nop:
@@ -2377,11 +2377,11 @@
_Jv_Utf8Const *method_name, *method_signature;
type class_type
= check_method_constant (get_ushort (),
- opcode == (unsigned char) op_invokeinterface,
+ opcode == op_invokeinterface,
&method_name,
&method_signature);
int arg_count = _Jv_count_arguments (method_signature);
- if (opcode == (unsigned char) op_invokeinterface)
+ if (opcode == op_invokeinterface)
{
int nargs = get_byte ();
if (nargs == 0)
@@ -2399,7 +2399,7 @@
if (_Jv_equalUtf8Consts (method_name, gcj::init_name))
{
is_init = true;
- if (opcode != (unsigned char) op_invokespecial)
+ if (opcode != op_invokespecial)
verify_fail ("can't invoke <init>", start_PC);
}
else if (method_name->data[0] == '<')
@@ -2412,7 +2412,7 @@
for (int i = arg_count - 1; i >= 0; --i)
pop_type (arg_types[i]);
- if (opcode != (unsigned char) op_invokestatic)
+ if (opcode != op_invokestatic)
{
type t = class_type;
if (is_init)
Index: include/java-insns.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/java-insns.h,v
retrieving revision 1.5
diff -u -r1.5 java-insns.h
--- include/java-insns.h 2000/03/07 19:55:25 1.5
+++ include/java-insns.h 2001/11/25 19:46:15
@@ -1,6 +1,6 @@
// java-insns.h - Instruction encodings. This is -*- c++ -*-
-/* Copyright (C) 1999 Free Software Foundation
+/* Copyright (C) 1999, 2001 Free Software Foundation
This file is part of libgcj.
@@ -11,7 +11,7 @@
#ifndef __JAVA_INSNS_H__
#define __JAVA_INSNS_H__
-enum
+enum java_opcode
{
op_nop = 0x00,
op_aconst_null = 0x01,