Removed return value from descriptor_params_from_paramtypes.
[cacao.git] / src / vm / method.cpp
index 4a166020146d006377d38f33694cbeffd02b347e..7adb88a84afd9ae03b874905e23e7f930a7868f4 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/method.cpp - method functions
 
-   Copyright (C) 1996-2005, 2006, 2007, 2008
+   Copyright (C) 1996-2011
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
@@ -127,6 +127,19 @@ void method_init(void)
           } line_number_table[line_number_table_length];
    }
 
+   LocalVariableTable_attribute {
+       u2 attribute_name_index;
+       u4 attribute_length;
+       u2 local_variable_table_length;
+       {
+           u2 start_pc;
+           u2 length;
+           u2 name_index;
+           u2 descriptor_index;
+           u2 index;
+       } local_variable_table[local_variable_table_length];
+   }
+
 *******************************************************************************/
 
 bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool)
@@ -433,7 +446,48 @@ bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool)
                                        if (!stackmap_load_attribute_stackmaptable(cb, m))
                                                return false;
                                }
-#endif
+# if defined(ENABLE_JVMTI)
+                               else if (code_attribute_name == utf_LocalVariableTable) {
+                                       /* LocalVariableTable */
+
+                                       if (m->localvars != NULL) {
+                                               exceptions_throw_classformaterror(c, "Multiple LocalVariableTable attributes");
+                                               return false;
+                                       }
+
+                                       if (!suck_check_classbuffer_size(cb, 4 + 2))
+                                               return false;
+
+                                       // Attribute length.
+                                       (void) suck_u4(cb);
+
+                                       m->localvarcount = suck_u2(cb);
+
+                                       if (!suck_check_classbuffer_size(cb, 10 * m->localvarcount))
+                                               return false;
+
+                                       m->localvars = MNEW(localvarinfo, m->localvarcount);
+
+                                       for (l = 0; l < m->localvarcount; l++) {
+                                               m->localvars[l].start_pc = suck_u2(cb);
+                                               m->localvars[l].length   = suck_u2(cb);
+
+                                               uint16_t name_index = suck_u2(cb);
+                                               if (!(m->localvars[l].name = (utf*) class_getconstant(c, name_index, CONSTANT_Utf8)))
+                                                       return false;
+
+                                               uint16_t descriptor_index = suck_u2(cb);
+                                               if (!(m->localvars[l].descriptor = (utf*) class_getconstant(c, descriptor_index, CONSTANT_Utf8)))
+                                                       return false;
+
+                                               m->localvars[l].index = suck_u2(cb);
+
+                                               // XXX Check if index is in range.
+                                               // XXX Check if index already taken.
+                                       }
+                               }
+# endif /* defined(ENABLE_JVMTI) */
+#endif /* defined(ENABLE_JAVASE) */
                                else {
                                        /* unknown code attribute */
 
@@ -479,7 +533,7 @@ bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool)
                                return false;
                }
 
-#if defined(ENABLE_ANNOTATIONS)
+# if defined(ENABLE_ANNOTATIONS)
                else if (attribute_name == utf_RuntimeVisibleAnnotations) {
                        /* RuntimeVisibleAnnotations */
                        if (!annotation_load_method_attribute_runtimevisibleannotations(cb, m))
@@ -505,7 +559,7 @@ bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool)
                        if (!annotation_load_method_attribute_annotationdefault(cb, m))
                                return false;
                }
-#endif
+# endif
 #endif
                else {
                        /* unknown attribute */
@@ -559,6 +613,9 @@ void method_free(methodinfo *m)
                        CompilerStub::remove(m->stubroutine);
                }
        }
+
+       if (m->breakpoints)
+               delete m->breakpoints;
 }
 
 
@@ -665,7 +722,7 @@ methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m)
        m........the method of which the parameters should be counted
 
    RETURN VALUE:
-       The parameter count or -1 on error.
+       The parameter count.
 
 *******************************************************************************/
 
@@ -678,11 +735,8 @@ int32_t method_get_parametercount(methodinfo *m)
        
        /* is the descriptor fully parsed? */
 
-       if (md->params == NULL) {
-               if (!descriptor_params_from_paramtypes(md, m->flags)) {
-                       return -1;
-               }
-       }
+       if (md->params == NULL)
+               descriptor_params_from_paramtypes(md, m->flags);
 
        paramcount = md->paramcount;
 
@@ -718,8 +772,7 @@ java_handle_objectarray_t *method_get_parametertypearray(methodinfo *m)
        /* is the descriptor fully parsed? */
 
        if (m->parseddesc->params == NULL)
-               if (!descriptor_params_from_paramtypes(md, m->flags))
-                       return NULL;
+               descriptor_params_from_paramtypes(md, m->flags);
 
        paramtypes = md->paramtypes;
        paramcount = md->paramcount;