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

📄 fields.c

📁 Nucleus_2_kvm_Hello 是kvm移植到Nucleus系统的源代码。。。好东西啊
💻 C
📖 第 1 页 / 共 3 页
字号:
/*========================================================================= * Debugging and printing operations *=======================================================================*/#if INCLUDEDEBUGCODE/*========================================================================= * FUNCTION:      printField() * TYPE:          public instance-level operation * OVERVIEW:      Print the contents of the given runtime field structure *                for debugging purposes. * INTERFACE: *   parameters:  pointer to a field object *   returns:     <nothing> *=======================================================================*/static void printField(FIELD thisField) {    START_TEMPORARY_ROOTS        DECLARE_TEMPORARY_ROOT(char *, className,                                getClassName((CLASS)(thisField->ofClass)));        DECLARE_TEMPORARY_ROOT(char *, fieldSignature,                                getFieldSignature(thisField));        /* Note that getFieldSignature may also allocate */        fprintf(stdout,"Field %s%s%s'%s.%s%s'\n",                 ((thisField->accessFlags & ACC_STATIC) ? "static " : ""),                ((thisField->accessFlags & ACC_FINAL)  ? "final "  : ""),                ((thisField->accessFlags & ACC_NATIVE) ? "native " : ""),                 className, fieldName(thisField), fieldSignature);        fprintf(stdout,"Access flags....: %lx\n", thisField->accessFlags);    END_TEMPORARY_ROOTS}/*========================================================================= * FUNCTION:      printFieldTable() * TYPE:          public instance-level operation * OVERVIEW:      Print the contents of the given field table *                for debugging purposes. * INTERFACE: *   parameters:  pointer to a field table *   returns:     <nothing> *=======================================================================*/void printFieldTable(FIELDTABLE fieldTable) {    FOR_EACH_FIELD(thisField, fieldTable)         printField(thisField);    END_FOR_EACH_FIELD;}/*========================================================================= * FUNCTION:      printMethod() * TYPE:          public instance-level operation * OVERVIEW:      Print the contents of the given runtime method structure *                for debugging purposes. * INTERFACE: *   parameters:  pointer to a method object *   returns:     <nothing> *=======================================================================*/static void printMethod(METHOD thisMethod) {   START_TEMPORARY_ROOTS       char *className = getClassName((CLASS)(thisMethod->ofClass));       fprintf(stdout,"Method %s%s%s'%s.%s%s'\n",                ((thisMethod->accessFlags & ACC_STATIC) ? "static " : ""),               ((thisMethod->accessFlags & ACC_FINAL)  ? "final "  : ""),               ((thisMethod->accessFlags & ACC_NATIVE) ? "native " : ""),                className, methodName(thisMethod), getMethodSignature(thisMethod));       fprintf(stdout,"Access flags....: %lx\n", (long)thisMethod->accessFlags);       fprintf(stdout,"Code pointer....: %lx\n", (long)thisMethod->u.java.code);       fprintf(stdout,"Frame size......: %d\n", thisMethod->frameSize);       fprintf(stdout,"Argument count..: %d\n", thisMethod->argCount);       fprintf(stdout,"Maximum stack...: %d\n", thisMethod->u.java.maxStack);       if (thisMethod->u.java.handlers) {           printExceptionHandlerTable(thisMethod->u.java.handlers);       }       fprintf(stdout,"\n");   END_TEMPORARY_ROOTS}/*========================================================================= * FUNCTION:      printMethodTable() * TYPE:          public instance-level operation * OVERVIEW:      Print the contents of the given method table *                for debugging purposes. * INTERFACE: *   parameters:  pointer to a method table *   returns:     <nothing> *=======================================================================*/void printMethodTable(METHODTABLE methodTable) {    FOR_EACH_METHOD(thisMethod, methodTable)         printMethod(thisMethod);     END_FOR_EACH_METHOD}/*========================================================================= * FUNCTION:      printMethodName() * TYPE:          debugging function * OVERVIEW:      Prints the method name, class, and signature * INTERFACE: *   parameters:  pointer to a method object *   returns:     <nothing> * * NOTE:          This function is intended to be GC friendly. *                It performs no memory allocation. *=======================================================================*/voidprintMethodName(METHOD thisMethod, LOGFILEPTR file){    char buffer[512];    char *p = buffer;    unsigned short nameKey = thisMethod->nameTypeKey.nt.nameKey;    unsigned short typeKey = thisMethod->nameTypeKey.nt.typeKey;    p = getClassName_inBuffer((CLASS)(thisMethod->ofClass), p);    *p++ = ' ';    strcpy(p, change_Key_to_Name(nameKey, NULL));    p += strlen(p);    change_Key_to_MethodSignature_inBuffer(typeKey, p);    if (thisMethod->accessFlags & ACC_STATIC) {         fprintf(stdout,"static ");    }    if (thisMethod->accessFlags & ACC_NATIVE) {         fprintf(stdout,"native ");    }    if (file == NULL) {         /* So it's easy to use this function from a debugger */        file = stdout;    }    fprintf(file, "%s\n", buffer);}/*========================================================================= * FUNCTION:      printFieldName() * TYPE:          debugging function * OVERVIEW:      Prints the field name, class, and signature * INTERFACE: *   parameters:  pointer to a field *   returns:     <nothing> * * NOTE:          This function is intended to be GC friendly. *                It performs no memory allocation. *=======================================================================*/void printFieldName(FIELD thisField,  LOGFILEPTR file){    char buffer[512];    char *p = buffer;    unsigned short nameKey = thisField->nameTypeKey.nt.nameKey;    unsigned short typeKey = thisField->nameTypeKey.nt.typeKey;    p = getClassName_inBuffer((CLASS)(thisField->ofClass), p);    *p++ = ' ';    strcpy(p, change_Key_to_Name(nameKey, NULL));    p += strlen(p);    change_Key_to_FieldSignature_inBuffer(typeKey, p);    if (file == NULL) {         /* So it's easy to use this function from a debugger */        file = stdout;    }    fprintf(file, "%s\n", buffer);}#endif /* INCLUDEDEBUGCODE *//*========================================================================= * Internal operations on signatures *=======================================================================*//*========================================================================= * FUNCTION:      change_Key_to_FieldSignature() *                change_Key_to_FieldSignature_inBuffer() * * TYPE:          public instance-level operation on runtime classes * OVERVIEW:      Converts a FieldType key to its actual signature * * INTERFACE: *   parameters:  key:           An existing FieldType key *                resultBuffer:  Where to put the result * *   returns:     getClassName() returns a pointer to the result *                getClassName_inBuffer() returns a pointer to the NULL *                     at the end of the result.  The result is in the *                     passed buffer. *  * DANGER:  change_Key_to_FieldSignature_inBuffer() doesn't return what you *          expect. * *=======================================================================*/char *change_Key_to_FieldSignature(FieldTypeKey key) {     char *endBuffer = change_Key_to_FieldSignature_inBuffer(key, str_buffer);    int length = endBuffer - str_buffer;    char *result = mallocBytes(length + 1);    memcpy(result, str_buffer, length);    result[length] = 0;    return result;}char*                   /* returns end of buffer */change_Key_to_FieldSignature_inBuffer(FieldTypeKey key, char *resultBuffer) {     char *p          = resultBuffer;    int depth        = key >> FIELD_KEY_ARRAY_SHIFT;    FieldTypeKey baseClassKey = key & 0x1FFF;    if (depth == MAX_FIELD_KEY_ARRAY_DEPTH) {         /* just use whatever the real classname is */        return getClassName_inBuffer(change_Key_to_CLASS(key), resultBuffer);    }    if (depth > 0) {         memset(p, '[', depth);        p += depth;    }    if (baseClassKey <= 255) {         *p++ = (char)baseClassKey;    } else {         *p++ = 'L';        p = getClassName_inBuffer(change_Key_to_CLASS(baseClassKey), p);        *p++ = ';';    }     *p = '\0';    return p;}        /*========================================================================= * FUNCTION:      change_Key_to_MethodSignature() *                change_Key_to_MethodSignature_inBuffer() * * TYPE:          public instance-level operation on runtime classes * OVERVIEW:      Converts a MethodType key to its actual signature * * INTERFACE: *   parameters:  key:         An existing MethodType key *                resultBuffer:  Where to put the result * *   returns:     getClassName() returns a pointer to the result *                getClassName_inBuffer() returns a pointer to the NULL *                     at the end of the result.  The result is in the *                     passed buffer. *  * DANGER:  change_Key_to_MethodSignature_inBuffer() doesn't return what you *          expect. * * DANGER:  change_Key_to_MethodSignature() allocates a byte array, and marks *          this array as a temporary root.  This function should only be *          called inside START_TEMPORARY_ROOTS ... END_TEMPORARY_ROOTS * * NOTE: The algorithm for converting a method signature to a key is * explained in the documentation below for change_MethodSignature_to_Key() *=======================================================================*/char *change_Key_to_MethodSignature(MethodTypeKey key) {     char *endBuffer = change_Key_to_MethodSignature_inBuffer(key, str_buffer);    int length = endBuffer - str_buffer;    char *result = mallocBytes(length + 1);    memcpy(result, str_buffer, length);    result[length] = 0;    return result;}char*                           /* returns end of string */change_Key_to_MethodSignature_inBuffer(MethodTypeKey key, char *resultBuffer) {    int  codedSignatureLength;    unsigned char *codedSignature =         (unsigned char *)change_Key_to_Name(key, &codedSignatureLength);    unsigned char *from = codedSignature; /* for parsing the codedSignature */    char *to = resultBuffer;    /* for writing to the result */    int  argCount = *from++;    /* the first byte is the arg count */    *to++ = '(';                /* message signatures start with '(' */    /* Parse the coded signature one argument at a time, and put the      * resulting signature into the result.  "from" and "to" are updated.      */    while (--argCount >= 0) {         change_Key_to_MethodSignatureInternal(&from, &to);    }    /* Now output the closing ')' */    *to++ = ')';    /* And the return type */    change_Key_to_MethodSignatureInternal(&from, &to);

⌨️ 快捷键说明

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