//
// The order is important: this setups the CaptureContext tree hierarchy.
//
+ if (container == null) {
+ Report.Error (1706, l, "Anonymous methods are not allowed in attribute declaration");
+ return;
+ }
container.SetHaveAnonymousMethods (l, this);
block.SetHaveAnonymousMethods (l, this);
}
protected AnonymousContainer (Parameters parameters, ToplevelBlock container,
- Location l)
+ Location l):
+ this (parameters, container, new ToplevelBlock (container, parameters, l), l)
{
- Parameters = parameters;
- Block = new ToplevelBlock (container, Parameters, l);
- loc = l;
-
- //
- // The order is important: this setups the CaptureContext tree hierarchy.
- //
- container.SetHaveAnonymousMethods (loc, this);
- Block.SetHaveAnonymousMethods (loc, this);
}
public override Expression DoResolve (EmitContext ec)
return null;
}
+ public override string ExprClassName {
+ get {
+ return "anonymous method";
+ }
+ }
+
public MethodBuilder GetMethodBuilder ()
{
return method.MethodData.MethodBuilder;
Console.WriteLine ("NeedThis=" + NeedThis);
foreach (LocalInfo li in locals){
Pad ();
- Console.WriteLine ("var {0}", li.Name);
+ Console.WriteLine ("var {0}", MakeFieldName (li.Name));
}
foreach (ScopeInfo si in children)
return String.Format ("<>AnonHelp<{0}>", id);
}
+ private string MakeFieldName (string local_name)
+ {
+ return "<" + id + ":" + local_name + ">";
+ }
+
public void EmitScopeType (EmitContext ec)
{
// EmitDebug ();
foreach (LocalInfo info in locals)
info.FieldBuilder = ScopeTypeBuilder.DefineField (
- info.Name, info.VariableType, FieldAttributes.Assembly);
+ MakeFieldName (info.Name), info.VariableType, FieldAttributes.Assembly);
if (HostsParameters){
Hashtable captured_parameters = CaptureContext.captured_parameters;
AdjustMethodScope (am, topmost);
}
- public void CaptureThis (AnonymousContainer am)
+ public void CaptureThis ()
{
CaptureContext parent = ParentCaptureContext;
- if (parent != null) {
- parent.CaptureThis (am);
- return;
- }
+ if (parent != null)
+ parent.CaptureThis ();
referenced_this = true;
-
- if (topmost == null){
- //
- // Create one ScopeInfo, if there are none.
- //
- topmost = new ScopeInfo (this, toplevel_owner);
- scopes [toplevel_owner.ID] = topmost;
- }
-
- AdjustMethodScope (am, topmost);
}
public bool HaveCapturedVariables {