本文整理汇总了C#中AstNode.Annotation方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.Annotation方法的具体用法?C# AstNode.Annotation怎么用?C# AstNode.Annotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode.Annotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartNode
public override void StartNode(AstNode node)
{
base.StartNode(node);
if (node.Annotation<MethodDebugSymbols>() != null) {
symbolsStack.Push(node.Annotation<MethodDebugSymbols>());
}
}
示例2: EndNode
public override void EndNode(AstNode node)
{
base.EndNode(node);
if (node is EntityDeclaration && node.Annotation<MemberReference>() != null) {
MemberLocations[XmlDocKeyProvider.GetKey(node.Annotation<MemberReference>())] = node.StartLocation;
}
// code mappings
var ranges = node.Annotation<List<ILRange>>();
if (symbolsStack.Count > 0 && ranges != null && ranges.Count > 0) {
symbolsStack.Peek().SequencePoints.Add(
new SequencePoint() {
ILRanges = ILRange.OrderAndJoin(ranges).ToArray(),
StartLocation = node.StartLocation,
EndLocation = node.EndLocation
});
}
if (node.Annotation<MethodDebugSymbols>() != null) {
var symbols = symbolsStack.Pop();
symbols.SequencePoints = symbols.SequencePoints.OrderBy(s => s.ILOffset).ToList();
symbols.StartLocation = node.StartLocation;
symbols.EndLocation = node.EndLocation;
DebugSymbols[XmlDocKeyProvider.GetKey(symbols.CecilMethod)] = symbols;
}
}
示例3: StartNode
public void StartNode(AstNode node) {
nodeStack.Push(node);
MethodDebugInfoBuilder mapping = node.Annotation<MethodDebugInfoBuilder>();
if (mapping != null) {
parentMethodDebugInfoBuilder.Push(currentMethodDebugInfoBuilder);
currentMethodDebugInfoBuilder = mapping;
}
// For ctor/cctor field initializers
var mms = node.Annotation<List<Tuple<MethodDebugInfoBuilder, List<BinSpan>>>>();
if (mms != null) {
Debug.Assert(multiMappings == null);
multiMappings = mms;
}
}
示例4: EndNode
public override void EndNode(AstNode node)
{
if (nodeStack.Pop() != node)
throw new InvalidOperationException();
var startLocation = startLocations.Pop();
// code mappings
var ranges = node.Annotation<List<ILRange>>();
if (symbolsStack.Count > 0 && ranges != null && ranges.Count > 0) {
// Ignore the newline which was printed at the end of the statement
TextLocation endLocation = (node is Statement) ? (lastEndOfLine ?? output.Location) : output.Location;
symbolsStack.Peek().SequencePoints.Add(
new SequencePoint() {
ILRanges = ILRange.OrderAndJoin(ranges).ToArray(),
StartLocation = startLocation,
EndLocation = endLocation
});
}
if (node.Annotation<MethodDebugSymbols>() != null) {
symbolsStack.Peek().EndLocation = output.Location;
output.AddDebugSymbols(symbolsStack.Pop());
}
}
示例5: EndNode
public void EndNode(AstNode node) {
if (nodeStack.Pop() != node)
throw new InvalidOperationException();
if (node.Annotation<MethodDebugInfoBuilder>() != null) {
output.AddDebugInfo(currentMethodDebugInfoBuilder.Create());
currentMethodDebugInfoBuilder = parentMethodDebugInfoBuilder.Pop();
}
var mms = node.Annotation<List<Tuple<MethodDebugInfoBuilder, List<BinSpan>>>>();
if (mms != null) {
Debug.Assert(mms == multiMappings);
if (mms == multiMappings) {
foreach (var mm in mms)
output.AddDebugInfo(mm.Item1.Create());
multiMappings = null;
}
}
}
示例6: GetInstruction
public Instruction GetInstruction(AstNode node) {
var range = node.Annotation<List<ILRange>>();
if (range != null && range.Count > 0) {
return _instructions.First(i => i.Offset == range[0].From);
}
return null;
}
示例7: TryGetOpCode
public bool TryGetOpCode(AstNode node, OpCode[] opCodes, out Instruction instruction) {
List<ILRange> ilRanges = node.Annotation<List<ILRange>>();
instruction = null;
foreach (var opCode in opCodes) {
if (TryGetInstruction(ilRanges, opCode, out instruction)) {
return true;
}
}
return false;
}
示例8: StartNode
public void StartNode(AstNode node)
{
// var ranges = node.Annotation<List<ILRange>>();
// if (ranges != null && ranges.Count > 0)
// {
// // find the ancestor that has method mapping as annotation
// if (node.Ancestors != null && node.Ancestors.Count() > 0)
// {
// var n = node.Ancestors.FirstOrDefault(a => a.Annotation<MemberMapping>() != null);
// if (n != null) {
// MemberMapping mapping = n.Annotation<MemberMapping>();
//
// // add all ranges
// foreach (var range in ranges) {
// mapping.MemberCodeMappings.Add(new SourceCodeMapping {
// ILInstructionOffset = range,
// SourceCodeLine = output.CurrentLine,
// MemberMapping = mapping
// });
// }
// }
// }
// }
nodeStack.Push(node);
MemberMapping mapping = node.Annotation<MemberMapping>();
if (mapping != null) {
parentMemberMappings.Push(currentMemberMapping);
currentMemberMapping = mapping;
}
// For ctor/cctor field initializers
var mms = node.Annotation<List<Tuple<MemberMapping, List<ILRange>>>>();
if (mms != null) {
Debug.Assert(multiMappings == null);
multiMappings = mms;
}
}
示例9: Run
public void Run(AstNode node) {
if (node is EntityDeclaration) {
IMemberRef mr = node.Annotation<IMemberRef>();
if (mr != null && mr.Module != null) {
var xmldoc = XmlDocLoader.LoadDocumentation(mr.Module);
if (xmldoc != null) {
string doc = xmldoc.GetDocumentation(XmlDocKeyProvider.GetKey(mr, stringBuilder));
if (!string.IsNullOrEmpty(doc)) {
InsertXmlDocumentation(node, doc);
}
}
}
if (!(node is TypeDeclaration))
return; // don't recurse into attributed nodes, except for type definitions
}
foreach (AstNode child in node.Children)
Run(child);
}
示例10: EndNode
public void EndNode(AstNode node) {
if (nodeStack.Pop() != node)
throw new InvalidOperationException();
if (node.Annotation<MemberMapping>() != null) {
output.AddDebugSymbols(currentMemberMapping);
currentMemberMapping = parentMemberMappings.Pop();
}
var mms = node.Annotation<List<Tuple<MemberMapping, List<ILRange>>>>();
if (mms != null) {
Debug.Assert(mms == multiMappings);
if (mms == multiMappings) {
foreach (var mm in mms)
output.AddDebugSymbols(mm.Item1);
multiMappings = null;
}
}
}
示例11: Run
public static void Run(AstNode node)
{
if (node is AttributedNode) {
MemberReference mr = node.Annotation<MemberReference>();
if (mr != null && mr.Module != null) {
var xmldoc = XmlDocLoader.LoadDocumentation(mr.Module);
if (xmldoc != null) {
string doc = xmldoc.GetDocumentation(XmlDocKeyProvider.GetKey(mr));
if (doc != null) {
InsertXmlDocumentation(node, new StringReader(doc));
}
}
}
if (!(node is TypeDeclaration))
return; // don't recurse into attributed nodes, except for type definitions
}
foreach (AstNode child in node.Children)
Run(child);
}
示例12: TryGetInstruction
public bool TryGetInstruction(AstNode node, OpCode opCode, out Instruction instruction) {
List<ILRange> ilRanges = node.Annotation<List<ILRange>>();
return TryGetInstruction(ilRanges, opCode, out instruction);
}
示例13: StartNode
public void StartNode(AstNode node)
{
// code mappings
var ranges = node.Annotation<List<ILRange>>();
if (ranges != null && ranges.Count > 0) {
// find the ancestor that has method mapping as annotation
if (node.Parent != null)
{
var n = node.Ancestors.FirstOrDefault(a => a.Annotation<MemberMapping>() != null);
if (n != null) {
MemberMapping mapping = n.Annotation<MemberMapping>();
// add all ranges
foreach (var range in ranges) {
mapping.MemberCodeMappings.Add(new SourceCodeMapping {
ILInstructionOffset = range,
SourceCodeLine = output.CurrentLine,
MemberMapping = mapping
});
}
}
}
}
// definitions of types and their members
Predicate<AstNode> predicate = n => n is AttributedNode;
if (predicate(node)) {
var n = node as AttributedNode;
int c = 0;
if (n != null)
c = n.Attributes.Count;
node.AddAnnotation(Tuple.Create(output.CurrentLine + c, output.CurrentColumn));
}
nodeStack.Push(node);
}
示例14: StartNode
public void StartNode(AstNode node)
{
var ranges = node.Annotation<List<ILRange>>();
if (ranges != null && ranges.Count > 0)
{
// find the ancestor that has method mapping as annotation
if (node.Ancestors != null && node.Ancestors.Count() > 0)
{
var n = node.Ancestors.FirstOrDefault(a => a.Annotation<MemberMapping>() != null);
if (n != null) {
MemberMapping mapping = n.Annotation<MemberMapping>();
// add all ranges
foreach (var range in ranges) {
mapping.MemberCodeMappings.Add(new SourceCodeMapping {
ILInstructionOffset = range,
SourceCodeLine = output.CurrentLine,
MemberMapping = mapping
});
}
}
}
}
nodeStack.Push(node);
}
示例15: EndNode
public void EndNode(AstNode node)
{
if (nodeStack.Pop() != node)
throw new InvalidOperationException();
var startLocation = startLocations.Pop();
// code mappings
if (currentMemberMapping != null) {
var ranges = node.Annotation<List<ILRange>>();
if (ranges != null && ranges.Count > 0) {
// add all ranges
foreach (var range in ranges) {
currentMemberMapping.MemberCodeMappings.Add(
new SourceCodeMapping {
ILInstructionOffset = range,
StartLocation = startLocation,
EndLocation = output.Location,
MemberMapping = currentMemberMapping
});
}
}
}
if (node.Annotation<MemberMapping>() != null) {
output.AddDebuggerMemberMapping(currentMemberMapping);
currentMemberMapping = parentMemberMappings.Pop();
}
}