using System.Reflection.Emit;
using System.Text;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
/// <summary>
/// Holds Delegates
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,
: 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;
}
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;
}
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;
}
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 (" (");
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 (", ");
}
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;
}
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);
}
delegate_instance_expr = e;
- delegate_method = ((MethodGroupExpr) invoke_method).Methods [0];
+ delegate_method = ((MethodGroupExpr) invoke_method).Methods [0];
eclass = ExprClass.Value;
return this;