New tests.
[mono.git] / mono / metadata / method-builder.c
index 18410dd757a008f624ed4ea8fbfec5941d384fb0..247c749bdedad87bad1932fc978dea8bb7f81eb9 100644 (file)
@@ -4,8 +4,8 @@
  * Author:
  *   Paolo Molaro (lupus@ximian.com)
  *
- * (C) 2002 Ximian, Inc.  http://www.ximian.com
- *
+ * Copyright 2002-2003 Ximian, Inc (http://www.ximian.com)
+ * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
  */
 
 #include "config.h"
@@ -139,15 +139,16 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
 
        image = mb->method->klass->image;
 
-       mono_loader_lock ();
+       mono_loader_lock (); /*FIXME I think this lock can go.*/
        if (mb->dynamic) {
                method = mb->method;
+               mw = (MonoMethodWrapper*)method;
 
                method->name = mb->name;
                method->dynamic = TRUE;
 
-               ((MonoMethodNormal *)method)->header = header = (MonoMethodHeader *) 
-                       g_malloc0 (sizeof (MonoMethodHeader) + mb->locals * sizeof (MonoType *));
+               mw->header = header = (MonoMethodHeader *) 
+                       g_malloc0 (MONO_SIZEOF_METHOD_HEADER + mb->locals * sizeof (MonoType *));
 
                header->code = mb->code;
 
@@ -159,14 +160,15 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
 
                method = mono_image_alloc0 (image, sizeof (MonoMethodWrapper));
                memcpy (method, mb->method, sizeof (MonoMethodWrapper));
+               mw = (MonoMethodWrapper*) method;
 
                if (mb->no_dup_name)
                        method->name = mb->name;
                else
                        method->name = mono_image_strdup (image, mb->name);
 
-               ((MonoMethodNormal *)method)->header = header = (MonoMethodHeader *) 
-                       mono_image_alloc0 (image, sizeof (MonoMethodHeader) + mb->locals * sizeof (MonoType *));
+               mw->header = header = (MonoMethodHeader *) 
+                       mono_image_alloc0 (image, MONO_SIZEOF_METHOD_HEADER + mb->locals * sizeof (MonoType *));
 
                header->code = mono_image_alloc (image, mb->pos);
                memcpy ((char*)header->code, mb->code, mb->pos);
@@ -187,7 +189,11 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
        header->num_locals = mb->locals;
        header->init_locals = TRUE;
 
-       mw = (MonoMethodWrapper*) mb->method;
+       header->num_clauses = mb->num_clauses;
+       header->clauses = mb->clauses;
+
+       method->skip_visibility = mb->skip_visibility;
+
        i = g_list_length (mw->method_data);
        if (i) {
                GList *tmp;
@@ -205,7 +211,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
                }
                g_list_free (l);
 
-               ((MonoMethodWrapper*)method)->method_data = data;
+               mw->method_data = data;
        }
        /*{
                static int total_code = 0;
@@ -518,3 +524,10 @@ mono_mb_emit_add_to_local (MonoMethodBuilder *mb, guint16 local, gint32 incr)
        mono_mb_emit_byte (mb, CEE_ADD);
        mono_mb_emit_stloc (mb, local); 
 }
+
+void
+mono_mb_set_clauses (MonoMethodBuilder *mb, int num_clauses, MonoExceptionClause *clauses)
+{
+       mb->num_clauses = num_clauses;
+       mb->clauses = clauses;
+}