+2008-02-19 Martin Baulig <martin@ximian.com>
+
+ * class.cs
+ (IMethodData.EmitExtraSymbolInfo): New interface method.
+ (MethodData.Emit): Call method.EmitExtraSymbolInfo().
+ (MethodOrOperator.EmitExtraSymbolInfo): Implement this new
+ interface method here as an empty public virtual method.
+
+ * anonymous.cs
+ (AnonymousMethodMethod.ctor): Added `string real_name' argument.
+ (AnonymousMethodMethod.EmitExtraSymbolInfo): Override and call
+ CodeGen.SymbolWriter.SetRealMethodName().
+
+2008-02-18 Martin Baulig <martin@ximian.com>
+
+ * anonymous.cs
+ (ScopeInfo.EmitType): Override this and emit debugging
+ information for captured variables.
+ (RootScopeInfo.EmitType): Override this and emit symbol
+ information for a captured `this'.
+
+2008-02-15 Martin Baulig <martin@ximian.com>
+
+ * iterators.cs: Emit debugging info.
+
+ * codegen.cs
+ (EmitContext.Flags): Add `OmitDebuggingInfo'.
+ (EmitContext.OmitDebuggingInfo): New public property.
+
+ * statement.cs
+ (While): Override Emit() and don't emit symbol info there; do it
+ inside DoEmit() instead.
+ (Block.Emit): Omit symbol information while emitting the scope
+ initializers; don't ec.Mark() the `EndLocation'. Fix the lexical
+ block logic.
+ (ExplicitBlock.IsIterator): Moved here from `ToplevelBlock'.
+ (ToplevelBlock.MakeIterator): Pass the `flags' to `ExplicitBlock's
+ .ctor to make `IsIterator' work.
+
2008-03-14 Martin Baulig <martin@ximian.com>
* symbolwriter.cs: Added the new symbol writer function from the
return var;
}
+ public override void EmitType ()
+ {
+ SymbolWriter.DefineAnonymousScope (ID);
+ foreach (CapturedLocal local in locals.Values)
+ local.EmitSymbolInfo ();
+
+ if (captured_params != null) {
+ foreach (CapturedParameter param in captured_params.Values)
+ param.EmitSymbolInfo ();
+ }
+
+ foreach (CapturedScope scope in CapturedScopes) {
+ scope.EmitSymbolInfo ();
+ }
+
+ base.EmitType ();
+ }
+
protected string MakeFieldName (string local_name)
{
return "<" + ID + ":" + local_name + ">";
return FieldInstance.FieldInfo;
}
+ public abstract void EmitSymbolInfo ();
+
public override void EmitInstance (EmitContext ec)
{
if ((ec.CurrentAnonymousMethod != null) &&
this.Idx = idx;
}
+ public override void EmitSymbolInfo ()
+ {
+ SymbolWriter.DefineCapturedParameter (
+ Scope.ID, Parameter.Name, Field.Name);
+ }
+
public override string ToString ()
{
return String.Format ("{0} ({1}:{2}:{3})", GetType (), Field,
this.Local = local;
}
+ public override void EmitSymbolInfo ()
+ {
+ SymbolWriter.DefineCapturedLocal (
+ Scope.ID, Local.Name, Field.Name);
+ }
+
public override string ToString ()
{
return String.Format ("{0} ({1}:{2})", GetType (), Field,
public CapturedThis (RootScopeInfo host)
: base (host, "<>THIS", host.ParentType)
{ }
+
+ public override void EmitSymbolInfo ()
+ {
+ SymbolWriter.DefineCapturedThis (Scope.ID, Field.Name);
+ }
}
protected class CapturedScope : CapturedVariable {
this.ChildScope = child;
}
+ public override void EmitSymbolInfo ()
+ {
+ SymbolWriter.DefineCapturedScope (Scope.ID, ChildScope.ID, Field.Name);
+ }
+
public bool DefineMembers ()
{
Type type = ChildScope.IsGeneric ?
Report.Debug (128, "RESOLVE THE INIT #1", this,
captured_scope, fe);
- } else
+ } else {
scope_instance = ec.ig.DeclareLocal (type);
+ if (!Scope.RootScope.IsIterator)
+ SymbolWriter.DefineScopeVariable (Scope.ID, scope_instance);
+ }
foreach (CapturedLocal local in Scope.locals.Values) {
FieldExpr fe = (FieldExpr) Expression.MemberLookup (
}
}
+ public override void EmitType ()
+ {
+ base.EmitType ();
+ if (THIS != null)
+ THIS.EmitSymbolInfo ();
+ }
+
protected class TheCtor : Statement
{
RootScopeInfo host;
{
public readonly AnonymousContainer AnonymousMethod;
public readonly ScopeInfo Scope;
+ public readonly string RealName;
public AnonymousMethodMethod (AnonymousContainer am, ScopeInfo scope,
GenericMethod generic, TypeExpr return_type,
- int mod, MemberName name, Parameters parameters)
+ int mod, string real_name, MemberName name,
+ Parameters parameters)
: base (scope != null ? scope : am.Host,
generic, return_type, mod | Modifiers.COMPILER_GENERATED, false, name, parameters, null)
{
this.AnonymousMethod = am;
this.Scope = scope;
+ this.RealName = real_name;
if (scope != null) {
scope.CheckMembersDefined ();
aec.MethodIsStatic = Scope == null;
return aec;
}
+
+ public override void EmitExtraSymbolInfo ()
+ {
+ SymbolWriter.SetRealMethodName (RealName);
+ }
}
}
#endif
member_name = new MemberName (name, Location);
+ string real_name = String.Format (
+ "{0}~{1}{2}", mc.GetSignatureForError (), GetSignatureForError (),
+ Parameters.GetSignatureForError ());
+
return new AnonymousMethodMethod (
this, scope, generic_method, new TypeExpression (ReturnType, Location),
- scope == null ? Modifiers.PRIVATE : Modifiers.INTERNAL, member_name, Parameters);
+ scope == null ? Modifiers.PRIVATE : Modifiers.INTERNAL,
+ real_name, member_name, Parameters);
}
public override Expression DoResolve (EmitContext ec)
}
}
+ public virtual void EmitExtraSymbolInfo ()
+ { }
+
#endregion
}
}
}
+ void IMethodData.EmitExtraSymbolInfo ()
+ { }
+
#endregion
}
bool IsExcluded ();
bool IsClsComplianceRequired ();
void SetMemberIsUsed ();
+ void EmitExtraSymbolInfo ();
}
//
if (GenericMethod != null)
GenericMethod.EmitAttributes ();
-
+
SourceMethod source = SourceMethod.Create (parent, MethodBuilder, method.Block);
//
else
ec.EmitTopBlock (method, block);
- if (source != null)
+ if (source != null) {
+ method.EmitExtraSymbolInfo ();
source.CloseMethod ();
+ }
}
void EmitDestructor (EmitContext ec, ToplevelBlock block)
get { throw new InvalidOperationException ("Unexpected attempt to get doc comment from " + this.GetType () + "."); }
}
+ void IMethodData.EmitExtraSymbolInfo ()
+ { }
}
//
InferReturnType = 1 << 9,
- InCompoundAssignment = 1 << 10
+ InCompoundAssignment = 1 << 10,
+
+ OmitDebuggingInfo = 1 << 11
}
Flags flags;
get { return current_flow_branching; }
}
+ public bool OmitDebuggingInfo {
+ get { return (flags & Flags.OmitDebuggingInfo) != 0; }
+ set {
+ if (value)
+ flags |= Flags.OmitDebuggingInfo;
+ else
+ flags &= ~Flags.OmitDebuggingInfo;
+ }
+ }
+
// <summary>
// Starts a new code branching. This inherits the state of all local
// variables and parameters from the current branching.
/// </summary>
public void Mark (Location loc, bool check_file)
{
- if (!SymbolWriter.HasSymbolWriter || loc.IsNull)
+ if (!SymbolWriter.HasSymbolWriter || OmitDebuggingInfo || loc.IsNull)
return;
if (check_file && (CurrentFile != loc.File))
resume_points.Add (entry_point);
entry_point.Define (ig);
+ SymbolWriter.StartIteratorBody (ec.ig);
+
original_block.Emit (ec);
+ SymbolWriter.EndIteratorBody (ec.ig);
+
EmitYieldBreak (ig);
+ SymbolWriter.StartIteratorDispatcher (ec.ig);
+
ig.MarkLabel (dispatcher);
Label [] labels = new Label [resume_points.Count];
ig.Emit (OpCodes.Ldfld, IteratorHost.PC.FieldBuilder);
ig.Emit (OpCodes.Switch, labels);
+ SymbolWriter.EndIteratorDispatcher (ec.ig);
+
Label end = ig.DefineLabel ();
+ SymbolWriter.StartIteratorDispatcher (ec.ig);
+
ig.MarkLabel (move_next_error);
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Stloc, retval);
ig.Emit (OpCodes.Stloc, retval);
ig.Emit (OpCodes.Leave, end);
+ SymbolWriter.EndIteratorDispatcher (ec.ig);
+
ig.BeginFaultBlock ();
ig.Emit (OpCodes.Ldarg_0);
{
Report.Debug (128, "CREATE METHOD HOST", this, IteratorHost);
+ MemberCore mc = ec.ResolveContext as MemberCore;
+
IteratorHost.CaptureScopes ();
return new AnonymousMethodMethod (
this, RootScope, null, TypeManager.system_boolean_expr,
- Modifiers.PUBLIC, new MemberName ("MoveNext", Location),
+ Modifiers.PUBLIC, mc.GetSignatureForError (),
+ new MemberName ("MoveNext", Location),
Parameters.EmptyReadOnlyParameters);
}
Statement.Emit (ec);
ig.MarkLabel (ec.LoopBegin);
+ ec.Mark (loc, true);
expr.EmitBranchable (ec, while_loop, true);
ec.LoopEnd = old_end;
}
+ public override void Emit (EmitContext ec)
+ {
+ DoEmit (ec);
+ }
+
protected override void CloneTo (CloneContext clonectx, Statement t)
{
While target = (While) t;
public void EmitSymbolInfo (EmitContext ec, string name)
{
if (builder != null)
- ec.DefineLocalVariable (name, builder);
+ ec.DefineLocalVariable (Name, builder);
}
public bool IsThisAssigned (EmitContext ec)
ec.CurrentBlock = this;
bool emit_debug_info = SymbolWriter.HasSymbolWriter;
- bool is_lexical_block = this == Explicit && Parent != null;
+ bool is_lexical_block = (this == Explicit) && (Parent != null) &&
+ ((flags & Flags.IsIterator) == 0);
+
+ bool omit_debug_info = ec.OmitDebuggingInfo;
if (emit_debug_info) {
if (is_lexical_block)
ec.BeginScope ();
}
- ec.Mark (StartLocation, true);
- if (scope_init != null)
+
+ if ((scope_init != null) || (scope_initializers != null))
+ SymbolWriter.OpenCompilerGeneratedBlock (ec.ig);
+
+ if (scope_init != null) {
+ ec.OmitDebuggingInfo = true;
scope_init.EmitStatement (ec);
+ ec.OmitDebuggingInfo = omit_debug_info;
+ }
if (scope_initializers != null) {
+ ec.OmitDebuggingInfo = true;
foreach (StatementExpression s in scope_initializers)
s.Emit (ec);
+ ec.OmitDebuggingInfo = omit_debug_info;
}
+ if ((scope_init != null) || (scope_initializers != null))
+ SymbolWriter.CloseCompilerGeneratedBlock (ec.ig);
+
+ ec.Mark (StartLocation, true);
DoEmit (ec);
- ec.Mark (EndLocation, true);
if (emit_debug_info) {
+ EmitSymbolInfo (ec);
+
if (is_lexical_block)
ec.EndScope ();
+ }
- if (variables != null) {
- foreach (DictionaryEntry de in variables) {
- string name = (string) de.Key;
- LocalInfo vi = (LocalInfo) de.Value;
+ ec.CurrentBlock = prev_block;
+ }
- vi.EmitSymbolInfo (ec, name);
- }
+ protected virtual void EmitSymbolInfo (EmitContext ec)
+ {
+ if (variables != null) {
+ foreach (DictionaryEntry de in variables) {
+ string name = (string) de.Key;
+ LocalInfo vi = (LocalInfo) de.Value;
+
+ vi.EmitSymbolInfo (ec, name);
}
}
-
- ec.CurrentBlock = prev_block;
}
public override string ToString ()
this.Explicit = this;
}
+ public bool IsIterator {
+ get { return (flags & Flags.IsIterator) != 0; }
+ }
+
HybridDictionary known_variables;
// <summary>
set { flags |= Flags.HasVarargs; }
}
- public bool IsIterator {
- get { return (flags & Flags.IsIterator) != 0; }
- }
-
//
// The parameters for the block.
//
parameters.ResolveVariable (this);
}
+ protected override void EmitSymbolInfo (EmitContext ec)
+ {
+ if ((AnonymousContainer != null) && (AnonymousContainer.Scope != null))
+ SymbolWriter.DefineScopeVariable (AnonymousContainer.Scope.ID);
+
+ base.EmitSymbolInfo (ec);
+ }
+
public void MakeIterator (Iterator iterator)
{
flags |= Flags.IsIterator;
- Block block = new ExplicitBlock (this, StartLocation, EndLocation);
+ Block block = new ExplicitBlock (this, flags, StartLocation, EndLocation);
foreach (Statement stmt in statements)
block.AddStatement (stmt);
statements.Clear ();