//
// The modifiers applied to the method, we aggregate them
//
- int method_modifiers = Modifiers.INTERNAL;
+ int method_modifiers = Modifiers.PRIVATE;
//
// During the resolve stage of the anonymous method body,
throw new Exception ("Type host is null");
if (current_type == type_host && ec.IsStatic){
- if (ec.IsStatic)
+ if (ec.IsStatic){
method_modifiers |= Modifiers.STATIC;
+ }
current_type = null;
}
method_modifiers, false, new MemberName ("<#AnonymousMethod>" + anonymous_method_count++),
Parameters, null, loc);
method.Block = Block;
-
//
// Swap the TypeBuilder while we define the method, then restore
invoke_mb = (MethodInfo) Delegate.GetInvokeMethod (ec, delegate_type, loc);
ParameterData invoke_pd = TypeManager.GetParameterData (invoke_mb);
- //
- // If implicit parameters are set, then we must check for out in the parameters
- // and flag it accordingly.
- //
- bool out_invalid_check = false;
-
if (Parameters == null){
int i, j;
- out_invalid_check = true;
//
// We provide a set of inaccessible parameters
for (int i = 0; i < amp.Count; i++){
Parameter.Modifier amp_mod = amp.ParameterModifier (i);
+
+ if ((amp_mod & (Parameter.Modifier.OUT | Parameter.Modifier.REF)) != 0){
+ if (!probe){
+ Error_ParameterMismatch (delegate_type);
+ Report.Error (1677, loc, "Parameter '{0}' should not be declared with the '{1}' keyword",
+ i+1, amp.ModifierDesc (i));
+ }
+ return null;
+ }
+
if (amp_mod != invoke_pd.ParameterModifier (i)){
if (!probe){
Report.Error (1676, loc,
}
return null;
}
-
- if (out_invalid_check && (invoke_pd.ParameterModifier (i) & Parameter.Modifier.OUT) != 0){
- if (!probe){
- Report.Error (1676, loc,"Parameter {0} must include the `out' modifier ", i+1);
- Error_ParameterMismatch (delegate_type);
- }
- return null;
- }
}
//
ec.TypeContainer, ec.DeclSpace, loc, null,
invoke_mb.ReturnType,
/* REVIEW */ (ec.InIterator ? Modifiers.METHOD_YIELDS : 0) |
- (ec.InUnsafe ? Modifiers.UNSAFE : 0),
+ (ec.InUnsafe ? Modifiers.UNSAFE : 0) |
+ (ec.IsStatic ? Modifiers.STATIC : 0),
/* No constructor */ false);
aec.CurrentAnonymousMethod = this;
ContainerAnonymousMethod = ec.CurrentAnonymousMethod;
ContainingBlock = ec.CurrentBlock;
-
+
if (aec.ResolveTopBlock (ec, Block, amp, loc, out unreachable))
return new AnonymousDelegate (this, delegate_type, loc).Resolve (ec);
return method.MethodData.MethodBuilder;
}
- public void EmitMethod (EmitContext ec)
+ public bool EmitMethod (EmitContext ec)
{
if (!CreateMethodHost (ec, invoke_mb.ReturnType))
- return;
+ return false;
MethodBuilder builder = GetMethodBuilder ();
ILGenerator ig = builder.GetILGenerator ();
// Adjust based on the computed state of the
// method from CreateMethodHost
- if ((method_modifiers & Modifiers.STATIC) != 0)
- aec.IsStatic = true;
+ aec.MethodIsStatic = (method_modifiers & Modifiers.STATIC) != 0;
aec.EmitMeta (Block, amp);
aec.EmitResolvedTopBlock (Block, unreachable);
+ return true;
}
public static void Error_AddressOfCapturedVar (string name, Location loc)
public override Expression DoResolve (EmitContext ec)
{
eclass = ExprClass.Value;
+
return this;
}
public override void Emit (EmitContext ec)
{
- am.EmitMethod (ec);
+ if (!am.EmitMethod (ec))
+ return;
//
// Now emit the delegate creation.
public void CloseTypes ()
{
- RootContext.RegisterHelperClass (ScopeTypeBuilder);
+ RootContext.RegisterCompilerGeneratedType (ScopeTypeBuilder);
foreach (ScopeInfo si in children)
si.CloseTypes ();
}