⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hashtable.h

📁 This is a java virtual machine implement in c
💻 H
字号:
/*0001*//*
/*0002./ * Copyright (c) 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
/*0003./ * 
/*0004./ * This software is the confidential and proprietary information of Sun
/*0005./ * Microsystems, Inc. ("Confidential Information").  You shall not
/*0006./ * disclose such Confidential Information and shall use it only in
/*0007./ * accordance with the terms of the license agreement you entered into
/*0008./ * with Sun.
/*0009./ * 
/*0010./ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
/*0011./ * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
/*0012./ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
/*0013./ * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
/*0014./ * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
/*0015./ * THIS SOFTWARE OR ITS DERIVATIVES.
/*0016./ * 
/*0017./ */
/*0018*/
/*0019*//*=========================================================================
/*0020./ * KVM 
/*0021./ *=========================================================================
/*0022./ * SYSTEM:    KVM
/*0023./ * SUBSYSTEM: Internal hashtables
/*0024./ * FILE:      hashtable.h
/*0025./ * OVERVIEW:  This file defines the structures for maintaining 
/*0026./ *            hashtables inside the KVM.  Hashtable data structures
/*0027./ *            are used internally by the KVM for maintaining:
/*0028./ *            1) classes (ClassTable)
/*0029./ *            2) strings (InternStringTable)
/*0030./ *            3) UTF8 strings (UTFStringTable)
/*0031./ * AUTHOR:    Frank Yellin
/*0032./ *=======================================================================*/
/*0033*/
/*0034*//*=========================================================================
/*0035./ * Include files
/*0036./ *=======================================================================*/
/*0037*/
/*0038*/#include <stddef.h>
/*0039*/
/*0040*//*=========================================================================
/*0041./ * Definitions and declarations
/*0042./ *=======================================================================*/
/*0043*/
/*0044*//* The sizes of the various hash tables */
/*0045*/
/*0046*/#define UTF_TABLE_SIZE 256
/*0047*/#define CLASS_TABLE_SIZE 32
/*0048*/#define INTERN_TABLE_SIZE 32
/*0049*/
/*0050*//* The declaration of a hashtable.  We make the buckets fairly
/*0051./ * generic.
/*0052./ */
/*0053*/typedef struct HashTable {
/*0054*/    long bucketCount;     /* Number of buckets */
/*0055*/    long count;           /* Number of total items in the table */
/*0056*/    cell *bucket[1];     /* Array of entries */
/*0057*/} *HASHTABLE;
/*0058*/
/*0059*//* The declaration of one bucket that holds unique instances of UTF strings
/*0060./ */
/*0061*/typedef struct UTF_Hash_Entry { 
/*0062*/    struct UTF_Hash_Entry *next; /* The next bucket */
/*0063*/        unsigned short length;
/*0064*/        unsigned short key;
/*0065*/        char string[1];          /* The characters of the string */
/*0066*/} *UTF_HASH_ENTRY, *UString;
/*0067*/
/*0068*//*=========================================================================
/*0069./ * Size macros
/*0070./ *=======================================================================*/
/*0071*/
/*0072*//* A hashtable with n buckets */
/*0073*/#define SIZEOF_HASHTABLE(n)     (StructSizeInCells(HashTable) + (n - 1))
/*0074*/
/*0075*//* A UTF_HASH_ENTRY that can hold a string of length n.  Note that
/*0076./ * this >>does<< include the NULL character, since we've already saved
/*0077./ * space for one character */
/*0078*/ 
/*0079*/#define SIZEOF_UTF_HASH_ENTRY(n) \
/*0080*/    ByteSizeToCellSize(offsetof(struct UTF_Hash_Entry, string) + n + 1)
/*0081*/
/*0082*//*=========================================================================
/*0083./ * Global variables
/*0084./ *=======================================================================*/
/*0085*/
/*0086*//* Hashtable containing all the Java strings in the system */
/*0087*/extern HASHTABLE InternStringTable;
/*0088*/
/*0089*//* Hashtable containing all the utf C strings in the system */
/*0090*/extern HASHTABLE UTFStringTable;
/*0091*/
/*0092*//* Hashtable containing all the classes in the system */
/*0093*/extern HASHTABLE ClassTable;
/*0094*/
/*0095*//*=========================================================================
/*0096./ * Hashtable creation and deletion
/*0097./ *=======================================================================*/
/*0098*/
/*0099*//* Create a new hash table */
/*0100*/void createHashTable(HASHTABLE *tablePtr, int bucketCount);
/*0101*/
/*0102*//* Called at startup to initialize the hashtables */
/*0103*/void InitializeHashtables(void);
/*0104*/void FinalizeHashtables(void);
/*0105*/
/*0106*/#if ROMIZING
/*0107*/void finalizeROMHashTable(HASHTABLE, int offset);
/*0108*/#endif
/*0109*/
/*0110*//*=========================================================================
/*0111./ * Functions
/*0112./ *=======================================================================*/
/*0113*/
/*0114*//* Convert a const char* to a UString, or a UString to a const char */
/*0115*/UString getUString(const char *string);
/*0116*/UString getUStringX(CONST_CHAR_HANDLE nameH, int offset, int length);
/*0117*/
/*0118*/#define UStringInfo(str) str->string
/*0119*/
/*0120*//* Get a unique String for a given char array */
/*0121*/INTERNED_STRING_INSTANCE internString(const char *string, int length);
/*0122*/
/*0123*//* Convert utf8 to unicode */
/*0124*/short utf2unicode(const char **utf);
/*0125*/
/*0131*//* Determine the actual number of characters in a utf8 string */
/*0132*/unsigned int utfStringLength(const char *utfstring, int length);
/*0133*/
/*0134*//* Conversion between keys and names */
/*0135*/NameKey change_Name_to_Key(CONST_CHAR_HANDLE, int offset, int length);
/*0136*/char *change_Key_to_Name(NameKey, int *length);
/*0137*/
/*0138*//* Conversion between classes and names */
/*0139*/CLASS change_Name_to_CLASS(UString package, UString base);
/*0140*/CLASS change_Key_to_CLASS(FieldTypeKey);
/*0141*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -