Skip to content
Permalink
Browse files

Add missing documentation to Annotations.cs.

  • Loading branch information...
siegfriedpammer committed Mar 11, 2019
1 parent d83f6e6 commit d9fba190ce465d8deb9a3c743bf23dff75e2d5f8
Showing with 34 additions and 4 deletions.
  1. +34 −4 ICSharpCode.Decompiler/CSharp/Annotations.cs
@@ -99,19 +99,25 @@ internal static TranslatedExpression WithRR(this ExpressionWithILInstruction exp
}

/// <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 @@ public static ILVariable GetILVariable(this IdentifierExpression expr)
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 @@ public static ILVariable GetILVariable(this VariableInitializer vi)
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 @@ public static ILVariable GetILVariable(this ForeachStatement loop)
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 @@ public static ForeachStatement WithILVariable(this ForeachStatement loop, ILVari
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 @@ public static ForeachStatement WithILVariable(this ForeachStatement loop, ILVari
}
}

/// <summary>
/// Represents a reference to a local variable.
/// </summary>
public class ILVariableResolveResult : ResolveResult
{
public readonly ILVariable Variable;
@@ -183,6 +210,9 @@ public ILVariableResolveResult(ILVariable v, IType type) : base(type)
}
}

/// <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;

0 comments on commit d9fba19

Please sign in to comment.
You can’t perform that action at this time.