2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / dlr / Runtime / Microsoft.Scripting.Core / Compiler / DebugInfoGenerator.cs
1 /* ****************************************************************************
2  *
3  * Copyright (c) Microsoft Corporation. 
4  *
5  * This source code is subject to terms and conditions of the Microsoft Public License. A 
6  * copy of the license can be found in the License.html file at the root of this distribution. If 
7  * you cannot locate the  Microsoft Public License, please send an email to 
8  * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
9  * by the terms of the Microsoft Public License.
10  *
11  * You must not remove this notice, or any other, from this software.
12  *
13  *
14  * ***************************************************************************/
15
16 #if CODEPLEX_40
17 using ILGenerator = System.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
18 #else
19 using ILGenerator = Microsoft.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
20 #endif
21
22 #if CODEPLEX_40
23 using System;
24 #else
25 using System; using Microsoft;
26 #endif
27 using System.Collections.Generic;
28 using System.Text;
29 using System.Reflection.Emit;
30 using System.Diagnostics;
31 using System.Diagnostics.SymbolStore;
32 using System.Reflection;
33 #if CODEPLEX_40
34 using System.Linq.Expressions;
35 #else
36 using Microsoft.Linq.Expressions;
37 #endif
38
39 #if CODEPLEX_40
40 namespace System.Runtime.CompilerServices {
41 #else
42 namespace Microsoft.Runtime.CompilerServices {
43 #endif
44     /// <summary>
45     /// Generates debug information for lambdas in an expression tree.
46     /// </summary>
47     public abstract class DebugInfoGenerator {
48         /// <summary>
49         /// Creates PDB symbol generator.
50         /// </summary>
51         /// <returns>PDB symbol generator.</returns>
52         public static DebugInfoGenerator CreatePdbGenerator() {
53             return new SymbolDocumentGenerator();
54         }
55
56         /// <summary>
57         /// Marks a sequence point.
58         /// </summary>
59         /// <param name="method">The lambda being generated.</param>
60         /// <param name="ilOffset">IL offset where to mark the sequence point.</param>
61         /// <param name="sequencePoint">Debug informaton corresponding to the sequence point.</param>
62         public abstract void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression sequencePoint);
63
64         internal virtual void MarkSequencePoint(LambdaExpression method, MethodBase methodBase, ILGenerator ilg, DebugInfoExpression sequencePoint) {
65             MarkSequencePoint(method, ilg.CurrentOffset, sequencePoint);
66         }
67
68         internal virtual void SetLocalName(LocalBuilder localBuilder, string name) {
69             // nop
70         }
71     }
72 }