2002-04-23 Patrik Torstensson <patrik.torstensson@labs2.com>
[mono.git] / mono / metadata / typedef.c
1 /*
2  * typedef.c: Handling of TypeDefs. 
3  *
4  * Author:
5  *   Miguel de Icaza (miguel@ximian.com)
6  *
7  * (C) 2001 Ximian, Inc.
8  */
9 #include <config.h>
10 #include <mono/metadata/typedef.h>
11
12 /**
13  * mono_typedef_decode:
14  * @image: image to decode from
15  * @tidx: typedef number
16  *
17  * Decodes the TypeDef whose index is @tidx in @image
18  */
19 void
20 mono_typedef_decode (MonoImage *image, guint32 tidx, MonoTypedef *ret)
21 {
22         MonoMetadata *m = &image->metadata;
23         MonoTableInfo *tt = m->tables [MONO_TABLE_TYPEDEF];
24         int next_is_valid;
25         guint32 cols_next [MONO_TYPEDEF_SIZE];
26         guint last;
27         
28         g_assert (typedef_token < tt->rows);
29         
30         mono_metadata_decode_row (tt, typedef_idx, &ret->cols, CSIZE (ret->cols));
31
32         /*
33          * Get the field and method range
34          */
35         ret->field.first = ret->cols [MONO_TYPEREF_FIELD_LIST] - 1;
36         ret->method.first = ret->cols [MONO_TYPEDEF_METHOD_LIST] - 1;
37         
38         if (tt->rows > typedef_idx + 1){
39                 mono_metadata_decode_row (tt, typedef_idx + 1, cols_next, CSIZE (cols_next));
40                 ret->field.last = cols_next [MONO_TYPEREF_FIELD_LIST] - 1;
41                 ret->method.last = cols_next [MONO_TYPEREF_FIELD_LIST] - 1;
42         } else {
43                 ret->field.last = m->tables [MONO_TABLE_FIELD].rows;
44                 ret->field.method = m->tables [MONO_TABLE_METHOD].rows;
45         }
46
47         /*
48          * Get the method range
49          */
50         ref
51         
52 }
53
54