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