jdk/make/tools/GenerateCharacter/check_class.c.template
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 1090 c5805b1672a6
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/* This file was generated AUTOMATICALLY from a template file Wed Jun 17 10:43:47 PDT 1998 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/*-
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *      code for verifying the date in a ClassClass structure for internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *      consistency.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include <ctype.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "oobj.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "interpreter.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "bool.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "utf.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "tree.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "sys_api.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
extern bool_t verify_class_codes(ClassClass *cb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
static bool_t verify_constant_pool(ClassClass *cb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
static bool_t is_legal_fieldname(ClassClass *cb, char *name, int type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
static bool_t is_legal_method_signature(ClassClass *cb, char *name, char *signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
static bool_t is_legal_field_signature(ClassClass *cb, char *name, char *signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
static char *skip_over_fieldname(char *name, bool_t slash_okay);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
static char *skip_over_field_signature(char *name, bool_t void_okay);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
static void CCerror (ClassClass *cb, char *format, ...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
/* Argument for is_legal_fieldname */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
enum { LegalClass, LegalField, LegalMethod };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
bool_t
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
VerifyClass(ClassClass *cb)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    bool_t result = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    struct methodblock *mb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    struct fieldblock *fb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    if (CCIs(cb, Verified)) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
	return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    if (!verify_constant_pool(cb)) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /* Make sure all the method names and signatures are okay */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    for (i = cbMethodsCount(cb), mb = cbMethods(cb); --i >= 0; mb++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
	char *name = mb->fb.name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
	char *signature = mb->fb.signature;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
	if (! (is_legal_fieldname(cb, name, LegalMethod)  &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
	       is_legal_method_signature(cb, name, signature)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
	    result = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /* Make sure all the field names and signatures are okay */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    for (i = cbFieldsCount(cb), fb = cbFields(cb); --i >= 0; fb++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
	if (!  (is_legal_fieldname(cb, fb->name, LegalField) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
		is_legal_field_signature(cb, fb->name, fb->signature))) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
	    result = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /* Make sure we are not overriding any final methods or classes*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    if (cbIsInterface(cb)) { 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
	struct methodblock *mb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
	if ((cbSuperclass(cb) == NULL) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
	    (cbSuperclass(cb) != classJavaLangObject)) { 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
	    CCerror(cb, "Interface %s has bad superclass", cbName(cb));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
	    result = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
	for (i = cbMethodsCount(cb), mb = cbMethods(cb); --i >= 0; mb++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
	    if (mb->fb.access & ACC_STATIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
		if (mb->fb.name[0] != '<') { 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
		    /* Only internal methods can be static */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
		    CCerror(cb, "Illegal static method %s in interface %s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
			    mb->fb.name, cbName(cb));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
		    result = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
		}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    } else if (cbSuperclass(cb)) { 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
	ClassClass *super_cb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
	unsigned bitvector_size = (unsigned)(cbMethodTableSize(cb) + 31) >> 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
	long *bitvector = sysCalloc(bitvector_size, sizeof(long));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
	for (super_cb = cbSuperclass(cb); ; super_cb = cbSuperclass(super_cb)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
	    if (cbAccess(super_cb) & ACC_FINAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
		CCerror(cb, "Class %s is subclass of final class %s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
			cbName(cb), cbName(super_cb));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
		result = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
	    mb = cbMethods(super_cb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
	    for (i = cbMethodsCount(super_cb); --i >= 0; mb++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
		if (mb->fb.access & ACC_FINAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
		    unsigned offset = mb->fb.u.offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
		    bitvector[offset >> 5] |= (1 << (offset & 0x1F));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
		}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
	    if (cbSuperclass(super_cb) == NULL) break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
	for (i = cbMethodsCount(cb), mb = cbMethods(cb); --i >= 0; mb++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
	    unsigned offset = mb->fb.u.offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
	    if ((offset > 0) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
		   && bitvector[offset >> 5] & (1 << (offset & 0x1F))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
		CCerror(cb, "Class %s overrides final method %s.%s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
			cbName(cb), mb->fb.name, mb->fb.signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
		result = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
	sysFree(bitvector);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    } else if (cb != classJavaLangObject) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
	CCerror(cb, "Class %s does not have superclass", cbName(cb));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
	result = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
	
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    if (result)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
	result = verify_class_codes(cb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    if (result) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
	CCSet(cb, Verified);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
static bool_t
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
verify_constant_pool(ClassClass *cb)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    union cp_item_type *cp = cbConstantPool(cb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    long cp_count = cbConstantPoolCount(cb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    unsigned char *type_table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    int i, type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    const int utf8_resolved = (CONSTANT_Utf8 | CONSTANT_POOL_ENTRY_RESOLVED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    if (cp_count == 0) /* Primitive classes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    type_table = cp[CONSTANT_POOL_TYPE_TABLE_INDEX].type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    /* Let's make two quick passes over the constant pool. The first one 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * checks that everything is of the right type.            */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    for (i = 1; i < cp_count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
	switch(type = type_table[i]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
	    case CONSTANT_String:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
	    case CONSTANT_Class: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
		int index = cp[i].i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
		if (   (index < 1) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
		       || (index >= cp_count)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
		       || (type_table[index] != utf8_resolved)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
		    CCerror(cb, "Bad index in constant pool #%d", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
		    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
		}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
		break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
		
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
	    case CONSTANT_String | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
		/* This can only happen if a string is the "initial" value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
		 * some final static String.  We assume that the checking has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
		 * already been done.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
		 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
		break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
	    case CONSTANT_Fieldref:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
	    case CONSTANT_Methodref:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
	    case CONSTANT_InterfaceMethodref: 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
	    case CONSTANT_NameAndType: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
		unsigned index = (unsigned)(cp[i].i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
		int key1 = index >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
		int key2 = index & 0xFFFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
		if (key1 < 1 || key1 >= cp_count 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
		      || key2 < 1 || key2 >= cp_count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
		    CCerror(cb, "Bad index in constant pool #%d", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
		    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
		}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
		if (type == CONSTANT_NameAndType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
		    if (   (type_table[key1] != utf8_resolved) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
			|| (type_table[key2] != utf8_resolved)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
			CCerror(cb, "Bad index in constant pool.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
			return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
		    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
		} else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
		    if (     ((type_table[key1] & CONSTANT_POOL_ENTRY_TYPEMASK) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
			        != CONSTANT_Class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
			  || ((type_table[key2] != CONSTANT_NameAndType))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
			CCerror(cb, "Bad index in constant pool #%d", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
			return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
		    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
		}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
		break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
		
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
	    case CONSTANT_Fieldref | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
	    case CONSTANT_Methodref | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
	    case CONSTANT_InterfaceMethodref | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
	    case CONSTANT_NameAndType | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
	        CCerror(cb, "Improperly resolved constant pool #%d", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
	        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
	    case CONSTANT_Class | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
	    case CONSTANT_Utf8 | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
	    case CONSTANT_Integer | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
	    case CONSTANT_Float | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
		break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
	    case CONSTANT_Long | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
	    case CONSTANT_Double | CONSTANT_POOL_ENTRY_RESOLVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
		if ((i + 1 >= cp_count) || 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
		    (type_table[i + 1] != CONSTANT_POOL_ENTRY_RESOLVED)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
		    CCerror(cb, "Improper constant pool long/double #%d", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
		    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
		} else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
		    i++;	
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
		    break;	    
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
		}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
	    case CONSTANT_Integer:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
	    case CONSTANT_Float:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
	    case CONSTANT_Long:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
	    case CONSTANT_Double:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
	    case CONSTANT_Utf8:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
	        CCerror(cb, "Improperly unresolved constant pool #%d", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
	        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
	    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
	        CCerror(cb, "Illegal constant pool type at #%d", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
	        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    for (i = 1; i < cp_count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
	switch(type = type_table[i]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
	    case CONSTANT_Class: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
		int index = cp[i].i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
		if (!is_legal_fieldname(cb, cp[index].cp, LegalClass)) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
		    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
		break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
	      
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
	    case CONSTANT_Fieldref:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
	    case CONSTANT_Methodref:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
	    case CONSTANT_InterfaceMethodref: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
		unsigned index = (unsigned)(cp[i].i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
		int name_type_index = index & 0xFFFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
		int name_type_key = cp[name_type_index].i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
		int name_index = name_type_key >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
		int signature_index = name_type_key & 0xFFFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
		char *name = cp[name_index].cp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
		char *signature = cp[signature_index].cp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
		if (type == CONSTANT_Fieldref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
		    if (! (is_legal_fieldname(cb, name, LegalField) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
			   is_legal_field_signature(cb, name, signature)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
		        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
		} else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
		    if (! (is_legal_fieldname(cb, name, LegalMethod) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
			   is_legal_method_signature(cb, name, signature)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
		        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
		}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
		break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
	    
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
/* Return true if the entire second argument consists of a legal fieldname 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
 * (or classname, if the third argument is LegalClass). 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
static bool_t 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
is_legal_fieldname(ClassClass *cb, char *name, int type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    bool_t result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    if (name[0] == '<') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
	result = (type == LegalMethod) && 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
	         ((strcmp(name, "<init>") == 0) || 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
		  (strcmp(name, "<clinit>") == 0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
	char *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
	if (type == LegalClass && name[0] == SIGNATURE_ARRAY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
	    p = skip_over_field_signature(name, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
	} else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
	    p = skip_over_fieldname(name, type == LegalClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
	result = (p != 0 && p[0] == '\0');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    if (!result) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
	char *thing =    (type == LegalField) ? "Field" 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
	               : (type == LegalMethod) ? "Method" : "Class";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
			 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
	CCerror(cb, "Illegal %s name \"%s\"", thing, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
	return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
/* Return true if the entire string consists of a legal field signature */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
static bool_t 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
is_legal_field_signature(ClassClass *cb, char *fieldname, char *signature) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    char *p = skip_over_field_signature(signature, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    if (p != 0 && p[0] == '\0') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
	return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
	CCerror(cb, "Field \"%s\" has illegal signature \"%s\"", 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
	       fieldname, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
	return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
static bool_t 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
is_legal_method_signature(ClassClass *cb, char *methodname, char *signature)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    char *p = signature;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    char *next_p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    /* The first character must be a '(' */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    if (*p++ == SIGNATURE_FUNC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
	/* Skip over however many legal field signatures there are */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
	while ((next_p = skip_over_field_signature(p, FALSE)) != 0) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
	    p = next_p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
	/* The first non-signature thing better be a ')' */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
	if (*p++ == SIGNATURE_ENDFUNC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
	    if (methodname[0] == '<') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
		/* All internal methods must return void */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
		if ((p[0] == SIGNATURE_VOID) && (p[1] == '\0'))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
		    return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
	    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
		/* Now, we better just have a return value. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
		next_p =  skip_over_field_signature(p, TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
		if (next_p && next_p[0] == '\0')
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
		    return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    CCerror(cb, "Method \"%s\" has illegal signature \"%s\"", 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
	   methodname, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
	
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
  $$Tables
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
 * This code mirrors Character.isJavaIdentifierStart.  It determines whether
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
 * the specified character is a legal start of a Java identifier as per JLS.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
 * The parameter ch is the character to be tested; return 1 if the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
 * character is a letter, 0 otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
#define isJavaIdentifierStart(ch) ($$Lookup(ch) & $$maskIsJavaIdentifierStart)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
 * This code mirrors Character.isJavaIdentifierPart.  It determines whether
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
 * the specified character is a legal part of a Java identifier as per JLS.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
 * 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
 * The parameter ch is the character to be tested; return 1 if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
 * character is a digit, 0 otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
 */  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
#define isJavaIdentifierPart(ch) ($$Lookup(ch) & $$maskIsJavaIdentifierPart)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
/* Take pointer to a string.  Skip over the longest part of the string that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
 * could be taken as a fieldname.  Allow '/' if slash_okay is TRUE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
 * Return a pointer to just past the fieldname.  Return NULL if no fieldname
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
 * at all was found, or in the case of slash_okay being true, we saw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
 * consecutive slashes (meaning we were looking for a qualified path but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
 * found something that was badly-formed). 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
static char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
skip_over_fieldname(char *name, bool_t slash_okay)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    bool_t first;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    char *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    unicode last_ch = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    for (p = name, first = TRUE; ; first = FALSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
	char *old_p = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
	unicode ch = next_utf2unicode(&p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
	if (isJavaIdentifierStart(ch) || (!first && isJavaIdentifierPart(ch)) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
	      || (slash_okay && ch == '/' && !first)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
	      || ch == '_' || ch == '$') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
	    if (ch == '/' && last_ch == '/') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
		return 0;	/* Don't permit consecutive slashes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
	    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
		last_ch = ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
	} else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
	    return first ? 0 : old_p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
/* Take pointer to a string.  Skip over the longest part of the string that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
 * could be taken as a field signature.  Allow "void" if void_okay.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
 * Return a pointer to just past the signature.  Return NULL if no legal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
 * signature is found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
static char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
skip_over_field_signature(char *name, bool_t void_okay)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    for (;;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
	switch (name[0]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            case SIGNATURE_VOID:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
		if (!void_okay) return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
		/* FALL THROUGH */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            case SIGNATURE_BOOLEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            case SIGNATURE_BYTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            case SIGNATURE_CHAR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            case SIGNATURE_SHORT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            case SIGNATURE_INT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            case SIGNATURE_FLOAT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            case SIGNATURE_LONG:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            case SIGNATURE_DOUBLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
		return name + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
	    case SIGNATURE_CLASS: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
		/* Skip over the classname, if one is there. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
		char *p = skip_over_fieldname(name + 1, TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
		/* The next character better be a semicolon. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
		if (p && p[0] == ';') 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
		    return p + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
		return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
	    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
	    
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
	    case SIGNATURE_ARRAY: 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
		/* The rest of what's there better be a legal signature.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
		name++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
		void_okay = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
		break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
	    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
		return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
static void 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
CCerror (ClassClass *cb, char *format, ...)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    if (verbose) { 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
	va_list args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
	jio_fprintf(stderr, "VERIFIER CLASS ERROR %s:\n", cbName(cb));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
	va_start(args, format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
	    jio_vfprintf(stderr, format, args);        
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
	va_end(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
	jio_fprintf(stderr, "\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
/* For use from outside the file.  Determine if the specified name is legal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
 * UTF name for a classname.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
 * Note that this routine expects the internal form of qualified classes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
 * the dots should have been replaced by slashes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
bool_t IsLegalClassname(char *name, bool_t allowArrayClass) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
{ 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    char *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    if (name[0] == SIGNATURE_ARRAY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
	if (!allowArrayClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
	    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
	} else { 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
	    /* Everything that's left better be a field signature */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
	    p = skip_over_field_signature(name, FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
	}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
	/* skip over the fieldname.  Slashes are okay */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
	p = skip_over_fieldname(name, TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    return (p != 0 && p[0] == '\0');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
}