needs gmcs
[mono.git] / mono / tests / metadata-verifier / gen-md-tests.c
index c95db5d8d0c5800cb169f267552470129dba7149..1eefbb31959c13250d6042a81b6c9898e9b32ce3 100644 (file)
@@ -71,12 +71,14 @@ function_call:
        fun_name '(' arg_list ')'
 
 fun_name:
+       read.byte |
        read.ushort |
        read.uint |
        translate.rva |
        translate.rva.ind |
        stream-header |
-       table-row
+       table-row |
+       blob.i
 
 arg_list:
        expression |
@@ -392,10 +394,19 @@ lookup_var (test_entry_t *entry, const char *name)
 static guint32
 call_func (test_entry_t *entry, const char *name, GSList *args)
 {
+       if (!strcmp ("read.byte", name)) {
+               guint32 offset;
+               if (g_slist_length (args) != 1) {
+                       printf ("Invalid number of args to read.ushort %d\n", g_slist_length (args));
+                       exit (INVALID_ARG_COUNT);
+               }
+               offset = expression_eval (args->data, entry);
+               return READ_VAR (guint8, entry->data + offset);
+       }
        if (!strcmp ("read.ushort", name)) {
                guint32 offset;
                if (g_slist_length (args) != 1) {
-                       printf ("Invalid number of args to read.ushort %d\b", g_slist_length (args));
+                       printf ("Invalid number of args to read.ushort %d\n", g_slist_length (args));
                        exit (INVALID_ARG_COUNT);
                }
                offset = expression_eval (args->data, entry);
@@ -404,7 +415,7 @@ call_func (test_entry_t *entry, const char *name, GSList *args)
        if (!strcmp ("read.uint", name)) {
                guint32 offset;
                if (g_slist_length (args) != 1) {
-                       printf ("Invalid number of args to read.uint %d\b", g_slist_length (args));
+                       printf ("Invalid number of args to read.uint %d\n", g_slist_length (args));
                        exit (INVALID_ARG_COUNT);
                }
                offset = expression_eval (args->data, entry);
@@ -413,7 +424,7 @@ call_func (test_entry_t *entry, const char *name, GSList *args)
        if (!strcmp ("translate.rva", name)) {
                guint32 rva;
                if (g_slist_length (args) != 1) {
-                       printf ("Invalid number of args to translate.rva %d\b", g_slist_length (args));
+                       printf ("Invalid number of args to translate.rva %d\n", g_slist_length (args));
                        exit (INVALID_ARG_COUNT);
                }
                rva = expression_eval (args->data, entry);
@@ -422,7 +433,7 @@ call_func (test_entry_t *entry, const char *name, GSList *args)
        if (!strcmp ("translate.rva.ind", name)) {
                guint32 rva;
                if (g_slist_length (args) != 1) {
-                       printf ("Invalid number of args to translate.rva.ind %d\b", g_slist_length (args));
+                       printf ("Invalid number of args to translate.rva.ind %d\n", g_slist_length (args));
                        exit (INVALID_ARG_COUNT);
                }
                rva = expression_eval (args->data, entry);
@@ -432,7 +443,7 @@ call_func (test_entry_t *entry, const char *name, GSList *args)
        if (!strcmp ("stream-header", name)) {
                guint32 idx;
                if (g_slist_length (args) != 1) {
-                       printf ("Invalid number of args to stream-header %d\b", g_slist_length (args));
+                       printf ("Invalid number of args to stream-header %d\n", g_slist_length (args));
                        exit (INVALID_ARG_COUNT);
                }
                idx = expression_eval (args->data, entry);
@@ -443,7 +454,7 @@ call_func (test_entry_t *entry, const char *name, GSList *args)
                guint32 table, row;
                const MonoTableInfo *info;
                if (g_slist_length (args) != 2) {
-                       printf ("Invalid number of args to table-row %d\b", g_slist_length (args));
+                       printf ("Invalid number of args to table-row %d\n", g_slist_length (args));
                        exit (INVALID_ARG_COUNT);
                }
                table = expression_eval (args->data, entry);
@@ -452,6 +463,18 @@ call_func (test_entry_t *entry, const char *name, GSList *args)
                data = info->base + row * info->row_size;
                return data - entry->test_set->assembly_data;
        }
+       if (!strcmp ("blob.i", name)) {
+               guint32 offset, base;
+               MonoStreamHeader blob = entry->test_set->image->heap_blob;
+               if (g_slist_length (args) != 1) {
+                       printf ("Invalid number of args to blob %d\n", g_slist_length (args));
+                       exit (INVALID_ARG_COUNT);
+               }
+               base = blob.data - entry->test_set->image->raw_data;
+               offset = expression_eval (args->data, entry);
+               offset = READ_VAR (guint16, entry->data + offset);
+               return base + offset;
+       }
 
        printf ("Unknown function %s\n", name);
        exit (INVALID_FUNCTION_NAME);