Browse Source

Add missing documentation to Annotations.cs.

pull/1464/head
Siegfried Pammer 6 years ago
parent
commit
d9fba190ce
  1. 38
      ICSharpCode.Decompiler/CSharp/Annotations.cs

38
ICSharpCode.Decompiler/CSharp/Annotations.cs

@ -99,19 +99,25 @@ namespace ICSharpCode.Decompiler.CSharp @@ -99,19 +99,25 @@ namespace ICSharpCode.Decompiler.CSharp
}
/// <summary>
/// Retrieves the symbol associated with this AstNode, or null if no symbol is associated with the node.
/// Retrieves the <see cref="ISymbol"/> associated with this AstNode, or null if no symbol is associated with the node.
/// </summary>
public static ISymbol GetSymbol(this AstNode node)
{
var rr = node.Annotation<ResolveResult>();
return rr != null ? rr.GetSymbol() : null;
}
/// <summary>
/// Retrieves the <see cref="ResolveResult"/> associated with this <see cref="AstNode"/>, or <see cref="ErrorResolveResult.UnknownError"/> if no resolve result is associated with the node.
/// </summary>
public static ResolveResult GetResolveResult(this AstNode node)
{
return node.Annotation<ResolveResult>() ?? ErrorResolveResult.UnknownError;
}
/// <summary>
/// Retrieves the <see cref="ILVariable"/> associated with this <see cref="IdentifierExpression"/>, or <c>null</c> if no variable is associated with this identifier.
/// </summary>
public static ILVariable GetILVariable(this IdentifierExpression expr)
{
var rr = expr.Annotation<ResolveResult>() as ILVariableResolveResult;
@ -120,7 +126,10 @@ namespace ICSharpCode.Decompiler.CSharp @@ -120,7 +126,10 @@ namespace ICSharpCode.Decompiler.CSharp
else
return null;
}
/// <summary>
/// Retrieves the <see cref="ILVariable"/> associated with this <see cref="VariableInitializer"/>, or <c>null</c> if no variable is associated with this initializer.
/// </summary>
public static ILVariable GetILVariable(this VariableInitializer vi)
{
var rr = vi.Annotation<ResolveResult>() as ILVariableResolveResult;
@ -130,6 +139,9 @@ namespace ICSharpCode.Decompiler.CSharp @@ -130,6 +139,9 @@ namespace ICSharpCode.Decompiler.CSharp
return null;
}
/// <summary>
/// Retrieves the <see cref="ILVariable"/> associated with this <see cref="ForeachStatement"/>, or <c>null</c> if no variable is associated with this foreach statement.
/// </summary>
public static ILVariable GetILVariable(this ForeachStatement loop)
{
var rr = loop.Annotation<ResolveResult>() as ILVariableResolveResult;
@ -139,18 +151,27 @@ namespace ICSharpCode.Decompiler.CSharp @@ -139,18 +151,27 @@ namespace ICSharpCode.Decompiler.CSharp
return null;
}
/// <summary>
/// Adds an <see cref="ILVariable"/> to this initializer.
/// </summary>
public static VariableInitializer WithILVariable(this VariableInitializer vi, ILVariable v)
{
vi.AddAnnotation(new ILVariableResolveResult(v, v.Type));
return vi;
}
/// <summary>
/// Adds an <see cref="ILVariable"/> to this foreach statement.
/// </summary>
public static ForeachStatement WithILVariable(this ForeachStatement loop, ILVariable v)
{
loop.AddAnnotation(new ILVariableResolveResult(v, v.Type));
return loop;
}
/// <summary>
/// Copies all annotations from <paramref name="other"/> to <paramref name="node"/>.
/// </summary>
public static T CopyAnnotationsFrom<T>(this T node, AstNode other) where T : AstNode
{
foreach (object annotation in other.Annotations) {
@ -159,6 +180,9 @@ namespace ICSharpCode.Decompiler.CSharp @@ -159,6 +180,9 @@ namespace ICSharpCode.Decompiler.CSharp
return node;
}
/// <summary>
/// Copies all <see cref="ILInstruction"/> annotations from <paramref name="other"/> to <paramref name="node"/>.
/// </summary>
public static T CopyInstructionsFrom<T>(this T node, AstNode other) where T : AstNode
{
foreach (object annotation in other.Annotations.OfType<ILInstruction>()) {
@ -168,6 +192,9 @@ namespace ICSharpCode.Decompiler.CSharp @@ -168,6 +192,9 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
/// <summary>
/// Represents a reference to a local variable.
/// </summary>
public class ILVariableResolveResult : ResolveResult
{
public readonly ILVariable Variable;
@ -183,6 +210,9 @@ namespace ICSharpCode.Decompiler.CSharp @@ -183,6 +210,9 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
/// <summary>
/// Annotates a <see cref="ForeachStatement"/> with the instructions for the GetEnumerator, MoveNext and get_Current calls.
/// </summary>
public class ForeachAnnotation
{
public readonly ILInstruction GetEnumeratorCall;

Loading…
Cancel
Save