ChangeLog: Updated ChangeLog.
[mono.git] / mcs / mbas / delegate.cs
index b155d2f8118c7a27ae4f1c04f64eda697cf1e134..aebe2a697d1142755130fc83421c5ad723cde55f 100644 (file)
@@ -15,7 +15,7 @@ using System.Reflection;
 using System.Reflection.Emit;
 using System.Text;
 
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
 
        /// <summary>
        ///   Holds Delegates
@@ -37,11 +37,11 @@ namespace Mono.CSharp {
                MethodBase delegate_method;
        
                const int AllowedModifiers =
-                       Modifiers.NEW |
+                       Modifiers.SHADOWS |
                        Modifiers.PUBLIC |
                        Modifiers.PROTECTED |
                        Modifiers.INTERNAL |
-                       Modifiers.UNSAFE |
+                   Modifiers.UNSAFE |
                        Modifiers.PRIVATE;
 
                public Delegate (TypeContainer parent, Expression type, int mod_flags,
@@ -50,9 +50,10 @@ namespace Mono.CSharp {
                        : base (parent, name, l)
                {
                        this.ReturnType = type;
+
                        ModFlags        = Modifiers.Check (AllowedModifiers, mod_flags,
                                                           IsTopLevel ? Modifiers.INTERNAL :
-                                                          Modifiers.PRIVATE, l);
+                                                          Modifiers.PUBLIC, l);
                        Parameters      = param_list;
                        OptAttributes   = attrs;
                }
@@ -150,7 +151,7 @@ namespace Mono.CSharp {
                                if (!container.AsAccessible (partype, ModFlags)) {
                                        Report.Error (59, Location,
                                                      "Inconsistent accessibility: parameter type `" +
-                                                     TypeManager.CSharpName (partype) + "` is less " +
+                                                     TypeManager.MonoBASIC_Name (partype) + "` is less " +
                                                      "accessible than delegate `" + Name + "'");
                                        return false;
                                }
@@ -163,7 +164,7 @@ namespace Mono.CSharp {
                        if (!container.AsAccessible (ret_type, ModFlags)) {
                                Report.Error (58, Location,
                                              "Inconsistent accessibility: return type `" +
-                                             TypeManager.CSharpName (ret_type) + "` is less " +
+                                             TypeManager.MonoBASIC_Name (ret_type) + "` is less " +
                                              "accessible than delegate `" + Name + "'");
                                return false;
                        }
@@ -437,7 +438,7 @@ namespace Mono.CSharp {
                
                public static string FullDelegateDesc (Type del_type, MethodBase mb, ParameterData pd)
                {
-                       StringBuilder sb = new StringBuilder (TypeManager.CSharpName (((MethodInfo) mb).ReturnType));
+                       StringBuilder sb = new StringBuilder (TypeManager.MonoBASIC_Name (((MethodInfo) mb).ReturnType));
                        
                        sb.Append (" " + del_type.ToString ());
                        sb.Append (" (");
@@ -447,7 +448,7 @@ namespace Mono.CSharp {
                        for (int i = length; i > 0; ) {
                                i--;
                                
-                               sb.Append (TypeManager.CSharpName (pd.ParameterType (length - i - 1)));
+                               sb.Append (TypeManager.MonoBASIC_Name (pd.ParameterType (length - i - 1)));
                                if (i != 0)
                                        sb.Append (", ");
                        }
@@ -572,7 +573,7 @@ namespace Mono.CSharp {
                                Expression.AllBindingFlags, loc);
 
                        if (invoke_method == null) {
-                               Report.Error (-200, loc, "Internal error ! COuld not find Invoke method!");
+                               Report.Error (-200, loc, "Internal error ! Could not find Invoke method!");
                                return null;
                        }
 
@@ -597,11 +598,26 @@ namespace Mono.CSharp {
                                        ParameterData param = Invocation.GetParameterData (dm);
                                        string delegate_desc = Delegate.FullDelegateDesc (type, dm, param);
 
-                                       Report.Error (123, loc, "Method '" + method_desc + "' does not " +
+                                       Report.Error (30408, loc, "Method '" + method_desc + "' does not " +
                                                      "match delegate '" + delegate_desc + "'");
 
                                        return null;
                                }
+
+                               //
+                               // Check safe/unsafe of the delegate
+                               //
+                               if (!ec.InUnsafe){
+                                       ParameterData param = Invocation.GetParameterData (delegate_method);
+                                       int count = param.Count;
+                                       
+                                       for (int i = 0; i < count; i++){
+                                               if (param.ParameterType (i).IsPointer){
+                                                       Expression.UnsafeError (loc);
+                                                       return null;
+                                               }
+                                       }
+                               }
                                                
                                if (mg.InstanceExpression != null)
                                        delegate_instance_expr = mg.InstanceExpression.Resolve (ec);
@@ -638,7 +654,7 @@ namespace Mono.CSharp {
                        }
                                
                        delegate_instance_expr = e;
-                       delegate_method        = ((MethodGroupExpr) invoke_method).Methods [0];
+                       delegate_method = ((MethodGroupExpr) invoke_method).Methods [0];
                        
                        eclass = ExprClass.Value;
                        return this;