[arm64] Fix finally abort
[mono.git] / mcs / class / dlr / Runtime / Microsoft.Scripting.Core / Ast / SymbolDocumentInfo.cs
1 /* ****************************************************************************
2  *
3  * Copyright (c) Microsoft Corporation. 
4  *
5  * This source code is subject to terms and conditions of the Apache License, Version 2.0. 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  Apache License, Version 2.0, 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 Apache License, Version 2.0.
10  *
11  * You must not remove this notice, or any other, from this software.
12  *
13  *
14  * ***************************************************************************/
15
16 using System;
17 using System.Dynamic.Utils;
18
19 #if !FEATURE_CORE_DLR
20 namespace Microsoft.Scripting.Ast {
21 #else
22 namespace System.Linq.Expressions {
23 #endif
24     /// <summary>
25     /// Stores information needed to emit debugging symbol information for a
26     /// source file, in particular the file name and unique language identifier.
27     /// </summary>
28     public class SymbolDocumentInfo {
29         private readonly string _fileName;
30
31         internal SymbolDocumentInfo(string fileName) {
32             ContractUtils.RequiresNotNull(fileName, "fileName");
33             _fileName = fileName;
34         }
35
36         /// <summary>
37         /// The source file name.
38         /// </summary>
39         public string FileName {
40             get { return _fileName; }
41         }
42
43         /// <summary>
44         /// Returns the language's unique identifier, if any.
45         /// </summary>
46         public virtual Guid Language {
47             get { return Guid.Empty; }
48         }
49
50         /// <summary>
51         /// Returns the language vendor's unique identifier, if any.
52         /// </summary>
53         public virtual Guid LanguageVendor {
54             get { return Guid.Empty; }
55         }
56
57         /// <summary>
58         /// Returns the document type's unique identifier, if any.
59         /// Defaults to the guid for a text file.
60         /// </summary>
61         public virtual Guid DocumentType {
62             get { return Compiler.SymbolGuids.DocumentType_Text; }
63         }
64     }
65
66     internal sealed class SymbolDocumentWithGuids : SymbolDocumentInfo {
67         private readonly Guid _language;
68         private readonly Guid _vendor;
69         private readonly Guid _documentType;
70
71         internal SymbolDocumentWithGuids(string fileName, ref Guid language)
72             : base(fileName) {
73             _language = language;
74             _documentType = Compiler.SymbolGuids.DocumentType_Text;
75         }
76
77         internal SymbolDocumentWithGuids(string fileName, ref Guid language, ref Guid vendor)
78             : base(fileName) {
79             _language = language;
80             _vendor = vendor;
81             _documentType = Compiler.SymbolGuids.DocumentType_Text;
82         }
83
84         internal SymbolDocumentWithGuids(string fileName, ref Guid language, ref Guid vendor, ref Guid documentType)
85             : base(fileName) {
86             _language = language;
87             _vendor = vendor;
88             _documentType = documentType;
89         }
90
91         public override Guid Language {
92             get { return _language; }
93         }
94
95         public override Guid LanguageVendor {
96             get { return _vendor; }
97         }
98
99         public override Guid DocumentType {
100             get { return _documentType; }
101         }
102     }
103
104     public partial class Expression {
105         /// <summary>
106         /// Creates an instance of <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" />.
107         /// </summary>
108         /// <param name="fileName">A <see cref="T:System.String" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> equal to.</param>
109         /// <returns>A <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" /> that has the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> property set to the specified value.</returns>
110         public static SymbolDocumentInfo SymbolDocument(string fileName) {
111             return new SymbolDocumentInfo(fileName);
112         }
113
114         /// <summary>
115         /// Creates an instance of <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" />.
116         /// </summary>
117         /// <param name="fileName">A <see cref="T:System.String" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> equal to.</param>
118         /// <param name="language">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" /> equal to.</param>
119         /// <returns>A <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" /> that has the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> 
120         /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" /> properties set to the specified value.</returns>
121         public static SymbolDocumentInfo SymbolDocument(string fileName, Guid language) {
122             return new SymbolDocumentWithGuids(fileName, ref language);
123         }
124
125         /// <summary>
126         /// Creates an instance of <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" />.
127         /// </summary>
128         /// <param name="fileName">A <see cref="T:System.String" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> equal to.</param>
129         /// <param name="language">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" /> equal to.</param>
130         /// <param name="languageVendor">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.LanguageVendor" /> equal to.</param>
131         /// <returns>A <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" /> that has the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> 
132         /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" /> 
133         /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.LanguageVendor" /> properties set to the specified value.</returns>
134         public static SymbolDocumentInfo SymbolDocument(string fileName, Guid language, Guid languageVendor) {
135             return new SymbolDocumentWithGuids(fileName, ref language, ref languageVendor);
136         }
137
138         /// <summary>
139         /// Creates an instance of <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" />.
140         /// </summary>
141         /// <param name="fileName">A <see cref="T:System.String" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> equal to.</param>
142         /// <param name="language">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" /> equal to.</param>
143         /// <param name="languageVendor">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.LanguageVendor" /> equal to.</param>
144         /// <param name="documentType">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.DocumentType" /> equal to.</param>
145         /// <returns>A <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" /> that has the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> 
146         /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" /> 
147         /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.LanguageVendor" /> 
148         /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.DocumentType" /> properties set to the specified value.</returns>
149         public static SymbolDocumentInfo SymbolDocument(string fileName, Guid language, Guid languageVendor, Guid documentType) {
150             return new SymbolDocumentWithGuids(fileName, ref language, ref languageVendor, ref documentType);
151         }
152     }
153 }