PageRenderTime 72ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 4ms

/SpecSharp/System.Compiler/Nodes.cs

#
C# | 12405 lines | 11377 code | 111 blank | 917 comment | 3958 complexity | b111ae665abe1b7131c5e7543d4a30e7 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. //-----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. //
  5. //-----------------------------------------------------------------------------
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.Globalization;
  10. using System.Collections.Specialized;
  11. #if FxCop
  12. using AssemblyReferenceList = Microsoft.Cci.AssemblyReferenceCollection;
  13. using AttributeList = Microsoft.Cci.AttributeNodeCollection;
  14. using BlockList = Microsoft.Cci.BlockCollection;
  15. using ExpressionList = Microsoft.Cci.ExpressionCollection;
  16. using InstructionList = Microsoft.Cci.InstructionCollection;
  17. using Int32List = System.Collections.Generic.List<int>;
  18. using InterfaceList = Microsoft.Cci.InterfaceCollection;
  19. using MemberList = Microsoft.Cci.MemberCollection;
  20. using MethodList = Microsoft.Cci.MethodCollection;
  21. using ModuleReferenceList = Microsoft.Cci.ModuleReferenceCollection;
  22. using NamespaceList = Microsoft.Cci.NamespaceCollection;
  23. using ParameterList = Microsoft.Cci.ParameterCollection;
  24. using ResourceList = Microsoft.Cci.ResourceCollection;
  25. using SecurityAttributeList = Microsoft.Cci.SecurityAttributeCollection;
  26. using StatementList = Microsoft.Cci.StatementCollection;
  27. using TypeNodeList = Microsoft.Cci.TypeNodeCollection;
  28. using Win32ResourceList = Microsoft.Cci.Win32ResourceCollection;
  29. using Module = Microsoft.Cci.ModuleNode;
  30. using Class = Microsoft.Cci.ClassNode;
  31. using Interface = Microsoft.Cci.InterfaceNode;
  32. using Property = Microsoft.Cci.PropertyNode;
  33. using Event = Microsoft.Cci.EventNode;
  34. using Return = Microsoft.Cci.ReturnNode;
  35. using Throw = Microsoft.Cci.ThrowNode;
  36. #endif
  37. #if UseSingularityPDB
  38. using Microsoft.Singularity.PdbInfo;
  39. #endif
  40. #if CCINamespace
  41. using Cci = Microsoft.Cci;
  42. using Microsoft.Cci.Metadata;
  43. using Metadata = Microsoft.Cci.Metadata;
  44. #else
  45. using Cci = System.Compiler;
  46. using System.Compiler.Metadata;
  47. using Metadata = System.Compiler.Metadata;
  48. #endif
  49. using System.Diagnostics;
  50. using System.IO;
  51. using System.Text;
  52. #if !NoXml
  53. using System.Xml;
  54. #endif
  55. using BindingFlags = System.Reflection.BindingFlags;
  56. #if CCINamespace
  57. namespace Microsoft.Cci{
  58. #else
  59. namespace System.Compiler{
  60. #endif
  61. #if !FxCop
  62. /// <summary>
  63. /// This interface can be used to link an arbitrary source text provider into an IR tree via a DocumentText instance.
  64. /// </summary>
  65. public interface ISourceText{
  66. /// <summary>
  67. /// The number of characters in the source text.
  68. /// A "character" corresponds to a System.Char which is actually a Unicode UTF16 code point to be precise.
  69. /// </summary>
  70. int Length{get;}
  71. /// <summary>
  72. /// Retrieves a substring from this instance. The substring starts with the character at the specified index and has a specified length.
  73. /// </summary>
  74. string Substring(int startIndex, int length);
  75. /// <summary>
  76. /// Retrieves the character at the given position. The first character is at position zero.
  77. /// </summary>
  78. char this[int position]{get;}
  79. /// <summary>
  80. /// Indicates that the text has been fully scanned and futher references to the text are expected to be infrequent.
  81. /// The underlying object can now choose to clear cached information if it comes under resource pressure.
  82. /// </summary>
  83. void MakeCollectible();
  84. }
  85. public unsafe interface ISourceTextBuffer : ISourceText{
  86. /// <summary>
  87. /// Returns null unless the implementer is based on an ASCII buffer that stays alive as long at the implementer itself.
  88. /// An implementer that returns a non-null value is merely a wrapper to keep the buffer alive. No further methods will
  89. /// be called on the interface in this case.
  90. /// </summary>
  91. byte* Buffer{get;}
  92. }
  93. #endif
  94. #if !MinimalReader
  95. /// <summary>
  96. /// Use this after a source text has already been scanned and parsed. This allows the source text to get released
  97. /// if there is memory pressure, while still allowing portions of it to be retrieved on demand. This is useful when
  98. /// a large number of source files are read in, but only infrequent references are made to them.
  99. /// </summary>
  100. public sealed class CollectibleSourceText : ISourceText{
  101. private string/*!*/ filePath;
  102. private WeakReference/*!*/ fileContent;
  103. private int length;
  104. public CollectibleSourceText(string/*!*/ filePath, int length) {
  105. this.filePath = filePath;
  106. this.fileContent = new WeakReference(null);
  107. this.length = length;
  108. //^ base();
  109. }
  110. public CollectibleSourceText(string/*!*/ filePath, string fileContent) {
  111. this.filePath = filePath;
  112. this.fileContent = new WeakReference(fileContent);
  113. this.length = fileContent == null ? 0 : fileContent.Length;
  114. //^ base();
  115. }
  116. private string/*!*/ ReadFile() {
  117. string content = string.Empty;
  118. try {
  119. StreamReader sr = new StreamReader(filePath);
  120. content = sr.ReadToEnd();
  121. this.length = content.Length;
  122. sr.Close();
  123. }catch{}
  124. return content;
  125. }
  126. public string/*!*/ GetSourceText() {
  127. string source = (string)this.fileContent.Target;
  128. if (source != null) return source;
  129. source = this.ReadFile();
  130. this.fileContent.Target = source;
  131. return source;
  132. }
  133. int ISourceText.Length{get{return this.length;}}
  134. string ISourceText.Substring(int startIndex, int length){
  135. return this.GetSourceText().Substring(startIndex, length);
  136. }
  137. char ISourceText.this[int index]{
  138. get{
  139. return this.GetSourceText()[index];
  140. }
  141. }
  142. void ISourceText.MakeCollectible(){
  143. this.fileContent.Target = null;
  144. }
  145. }
  146. /// <summary>
  147. /// This class is used to wrap the string contents of a source file with an ISourceText interface. It is used while compiling
  148. /// a project the first time in order to obtain a symbol table. After that the StringSourceText instance is typically replaced with
  149. /// a CollectibleSourceText instance, so that the actual source text string can be collected. When a file is edited,
  150. /// and the editor does not provide its own ISourceText wrapper for its edit buffer, this class can be used to wrap a copy of the edit buffer.
  151. /// </summary>
  152. public sealed class StringSourceText : ISourceText{
  153. /// <summary>
  154. /// The wrapped string used to implement ISourceText. Use this value when unwrapping.
  155. /// </summary>
  156. public readonly string/*!*/ SourceText;
  157. /// <summary>
  158. /// True when the wrapped string is the contents of a file. Typically used to check if it safe to replace this
  159. /// StringSourceText instance with a CollectibleSourceText instance.
  160. /// </summary>
  161. public bool IsSameAsFileContents;
  162. public StringSourceText(string/*!*/ sourceText, bool isSameAsFileContents) {
  163. this.SourceText = sourceText;
  164. this.IsSameAsFileContents = isSameAsFileContents;
  165. //^ base();
  166. }
  167. int ISourceText.Length{get{return this.SourceText.Length;}}
  168. string ISourceText.Substring(int startIndex, int length){
  169. return this.SourceText.Substring(startIndex, length);
  170. }
  171. char ISourceText.this[int index]{
  172. get{
  173. return this.SourceText[index];
  174. }
  175. }
  176. void ISourceText.MakeCollectible(){
  177. }
  178. }
  179. #endif
  180. #if !FxCop
  181. /// <summary>
  182. /// This class provides a uniform interface to program sources provided in the form of Unicode strings,
  183. /// unsafe pointers to ascii buffers (as obtained from a memory mapped file, for instance) as well as
  184. /// arbitrary source text providers that implement the ISourceText interface.
  185. /// </summary>
  186. public sealed unsafe class DocumentText{
  187. /// <summary>
  188. /// If this is not null it is used to obtain 8-bit ASCII characters.
  189. /// </summary>
  190. public byte* AsciiStringPtr;
  191. /// <summary>
  192. /// If this is not null it represents a Unicode string encoded as UTF16.
  193. /// </summary>
  194. public string Source;
  195. /// <summary>
  196. /// If this is not null the object implement ISourceText provides some way to get at individual characters and substrings.
  197. /// </summary>
  198. public ISourceText TextProvider;
  199. /// <summary>
  200. /// The number of characters in the source document.
  201. /// A "character" corresponds to a System.Char which is actually a Unicode UTF16 code point to be precise.
  202. /// </summary>
  203. public int Length;
  204. public DocumentText(string source){
  205. if (source == null){Debug.Assert(false); return;}
  206. this.Source = source;
  207. this.Length = source.Length;
  208. }
  209. public DocumentText(ISourceText textProvider){
  210. if (textProvider == null){Debug.Assert(false); return;}
  211. this.TextProvider = textProvider;
  212. this.Length = textProvider.Length;
  213. }
  214. public unsafe DocumentText(ISourceTextBuffer textProvider){
  215. if (textProvider == null){Debug.Assert(false); return;}
  216. this.TextProvider = textProvider;
  217. this.AsciiStringPtr = textProvider.Buffer;
  218. this.Length = textProvider.Length;
  219. }
  220. /// <summary>
  221. /// Compare this.Substring(offset, length) for equality with str.
  222. /// Call this only if str.Length is known to be equal to length.
  223. /// </summary>
  224. public bool Equals(string str, int position, int length){ //TODO: (int position, int length, string str)
  225. if (str == null){Debug.Assert(false); return false;}
  226. if (str.Length != length){Debug.Assert(false); return false;}
  227. if (position < 0 || position+length > this.Length){Debug.Assert(false); return false;}
  228. unsafe{
  229. byte* p = this.AsciiStringPtr;
  230. if (p != null){
  231. for (int i = position, j = 0; j < length; i++, j++)
  232. if (((char)*(p+i)) != str[j]) return false;
  233. return true;
  234. }
  235. }
  236. string source = this.Source;
  237. if (source != null){
  238. for (int i = position, j = 0; j < length; i++, j++)
  239. if (source[i] != str[j]) return false;
  240. return true;
  241. }
  242. ISourceText myProvider = this.TextProvider;
  243. if (myProvider == null){Debug.Assert(false); return false;}
  244. for (int i = position, j = 0; j < length; i++, j++)
  245. if (myProvider[i] != str[j]) return false;
  246. return true;
  247. }
  248. /// <summary>
  249. /// Compares the substring of the specificied length starting at offset, with the substring in DocumentText starting at textOffset.
  250. /// </summary>
  251. /// <param name="offset">The index of the first character of the substring of this DocumentText.</param>
  252. /// <param name="text">The Document text with the substring being compared to.</param>
  253. /// <param name="textOffset">The index of the first character of the substring of the DocumentText being compared to.</param>
  254. /// <param name="length">The number of characters in the substring being compared.</param>
  255. /// <returns></returns>
  256. public bool Equals(int offset, DocumentText text, int textOffset, int length){ //TODO: (int position, int length, DocumentText text, int textPosition)
  257. if (offset < 0 || length < 0 || offset+length > this.Length){ Debug.Assert(false); return false;}
  258. if (textOffset < 0 || text == null || textOffset+length > text.Length){Debug.Assert(false); return false;}
  259. unsafe{
  260. byte* p = this.AsciiStringPtr;
  261. if (p != null){
  262. unsafe{
  263. byte* q = text.AsciiStringPtr;
  264. if (q != null){
  265. for (int i = offset, j = textOffset, n = offset+length; i < n; i++, j++)
  266. if (*(p+i) != *(q+j)) return false;
  267. return true;
  268. }
  269. }
  270. string textSource = text.Source;
  271. if (textSource != null){
  272. for (int i = offset, j = textOffset, n = offset+length; i < n; i++, j++)
  273. if (((char)*(p+i)) != textSource[j]) return false;
  274. return true;
  275. }
  276. ISourceText textProvider = text.TextProvider;
  277. if (textProvider == null){Debug.Assert(false); return false;}
  278. for (int i = offset, j = textOffset, n = offset+length; i < n; i++, j++)
  279. if (((char)*(p+i)) != textProvider[j]) return false;
  280. return true;
  281. }
  282. }
  283. string source = this.Source;
  284. if (source != null){
  285. unsafe{
  286. byte* q = text.AsciiStringPtr;
  287. if (q != null){
  288. for (int i = offset, j = textOffset, n = offset+length; i < n; i++, j++)
  289. if (source[i] != (char)*(q+j)) return false;
  290. return true;
  291. }
  292. }
  293. string textSource = text.Source;
  294. if (textSource != null){
  295. for (int i = offset, j = textOffset, n = offset+length; i < n; i++, j++)
  296. if (source[i] != textSource[j]) return false;
  297. return true;
  298. }
  299. ISourceText textProvider = text.TextProvider;
  300. if (textProvider == null){Debug.Assert(false); return false;}
  301. for (int i = offset, j = textOffset, n = offset+length; i < n; i++, j++)
  302. if (source[i] != textProvider[j]) return false;
  303. return true;
  304. }
  305. {
  306. ISourceText myProvider = this.TextProvider;
  307. if (myProvider == null){Debug.Assert(false); return false;}
  308. unsafe{
  309. byte* q = text.AsciiStringPtr;
  310. if (q != null){
  311. for (int i = offset, j = textOffset, n = offset+length; i < n; i++, j++)
  312. if (myProvider[i] != (char)*(q+j)) return false;
  313. return true;
  314. }
  315. }
  316. string textSource = text.Source;
  317. if (textSource != null){
  318. for (int i = offset, j = textOffset, n = offset+length; i < n; i++, j++)
  319. if (myProvider[i] != textSource[j]) return false;
  320. return true;
  321. }
  322. ISourceText textProvider = text.TextProvider;
  323. if (textProvider == null){Debug.Assert(false); return false;}
  324. for (int i = offset, j = textOffset, n = offset+length; i < n; i++, j++)
  325. if (myProvider[i] != textProvider[j]) return false;
  326. return true;
  327. }
  328. }
  329. /// <summary>
  330. /// Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.
  331. /// </summary>
  332. public string/*!*/ Substring(int position, int length){
  333. if (position < 0 || length < 0 || position+length > this.Length+1){Debug.Assert(false); return "";}
  334. if (position+length > this.Length) length = this.Length-position; //Allow virtual EOF character to be included in length
  335. if (this.AsciiStringPtr != null){
  336. unsafe{
  337. return new String((sbyte*)this.AsciiStringPtr, position, length, System.Text.Encoding.ASCII);
  338. }
  339. }else if (this.Source != null)
  340. return this.Source.Substring(position, length);
  341. else if (this.TextProvider != null)
  342. return this.TextProvider.Substring(position, length);
  343. else{
  344. Debug.Assert(false);
  345. return "";
  346. }
  347. }
  348. /// <summary>
  349. /// Retrieves the character at the given position. The first character is at position zero.
  350. /// </summary>
  351. public char this[int position]{
  352. get{
  353. if (position < 0 || position >= this.Length){Debug.Assert(false); return (char)0;}
  354. if (this.AsciiStringPtr != null){
  355. unsafe{
  356. unchecked{
  357. return (char) *(this.AsciiStringPtr+position);
  358. }
  359. }
  360. }else if (this.Source != null)
  361. return this.Source[position];
  362. else if (this.TextProvider != null)
  363. return this.TextProvider[position];
  364. else{
  365. Debug.Assert(false);
  366. return (char)0;
  367. }
  368. }
  369. }
  370. }
  371. /// <summary>
  372. /// A source document from which an Abstract Syntax Tree has been derived.
  373. /// </summary>
  374. public class Document{
  375. /// <summary>
  376. /// A Guid that identifies the kind of document to applications such as a debugger. Typically System.Diagnostics.SymbolStore.SymDocumentType.Text.
  377. /// </summary>
  378. public System.Guid DocumentType;
  379. /// <summary>
  380. /// A Guid that identifies the programming language used in the source document. Typically used by a debugger to locate language specific logic.
  381. /// </summary>
  382. public System.Guid Language;
  383. /// <summary>
  384. /// A Guid that identifies the compiler vendor programming language used in the source document. Typically used by a debugger to locate vendor specific logic.
  385. /// </summary>
  386. public System.Guid LanguageVendor;
  387. /// <summary>
  388. /// The line number corresponding to the first character in Text. Typically 1 but can be changed by C# preprocessor directives.
  389. /// </summary>
  390. public int LineNumber;
  391. /// <summary>
  392. /// Indicates that the document contains machine generated source code that should not show up in tools such as debuggers.
  393. /// Can be set by C# preprocessor directives.
  394. /// </summary>
  395. public bool Hidden;
  396. /// <summary>
  397. /// The name of the document. Typically a file name. Can be a full or relative file path, or a URI or some other kind of identifier.
  398. /// </summary>
  399. public string/*!*/ Name;
  400. /// <summary>
  401. /// Contains the source text.
  402. /// </summary>
  403. public DocumentText Text;
  404. public Document(){
  405. this.Name = "";
  406. //^ base();
  407. }
  408. public Document(string/*!*/ name, int lineNumber, string text, System.Guid documentType, System.Guid language, System.Guid languageVendor)
  409. :this(name, lineNumber, new DocumentText(text), documentType, language, languageVendor){
  410. }
  411. public Document(string/*!*/ name, int lineNumber, DocumentText text, System.Guid documentType, System.Guid language, System.Guid languageVendor) {
  412. this.DocumentType = documentType;
  413. this.Language = language;
  414. this.LanguageVendor = languageVendor;
  415. this.LineNumber = lineNumber;
  416. this.Name = name;
  417. this.Text = text;
  418. //^ base();
  419. }
  420. /// <summary>
  421. /// Maps the given zero based character position to the number of the source line containing the same character.
  422. /// Line number counting starts from the value of LineNumber.
  423. /// </summary>
  424. public virtual int GetLine(int position){
  425. int line = 0; int column = 0;
  426. this.GetPosition(position, out line, out column);
  427. return line+this.LineNumber;
  428. }
  429. /// <summary>
  430. /// Maps the given zero based character position in the entire text to the position of the same character in a source line.
  431. /// Counting within the source line starts at 1.
  432. /// </summary>
  433. public virtual int GetColumn(int position){
  434. int line = 0; int column = 0;
  435. this.GetPosition(position, out line, out column);
  436. return column+1;
  437. }
  438. /// <summary>
  439. /// Given a startLine, startColum, endLine and endColumn, this returns the corresponding startPos and endPos. In other words it
  440. /// converts a range expression in line and columns to a range expressed as a start and end character position.
  441. /// </summary>
  442. /// <param name="startLine">The number of the line containing the first character. The number of the first line equals this.LineNumber.</param>
  443. /// <param name="startColumn">The position of the first character relative to the start of the line. Counting from 1.</param>
  444. /// <param name="endLine">The number of the line contain the character that immediate follows the last character of the range.</param>
  445. /// <param name="endColumn">The position, in the last line, of the character that immediately follows the last character of the range.</param>
  446. /// <param name="startPos">The position in the entire text of the first character of the range, counting from 0.</param>
  447. /// <param name="endPos">The position in the entire text of the character following the last character of the range.</param>
  448. public virtual void GetOffsets(int startLine, int startColumn, int endLine, int endColumn, out int startPos, out int endPos){
  449. lock(this){
  450. if (this.lineOffsets == null) this.ComputeLineOffsets();
  451. //^ assert this.lineOffsets != null;
  452. startPos = this.lineOffsets[startLine-this.LineNumber]+startColumn-1;
  453. endPos = this.lineOffsets[endLine-this.LineNumber]+endColumn-1;
  454. }
  455. }
  456. /// <summary>
  457. /// Retrieves a substring from the text of this Document. The substring starts at a specified character position and has a specified length.
  458. /// </summary>
  459. public virtual string Substring(int position, int length){
  460. if (this.Text == null) return null;
  461. return this.Text.Substring(position, length);
  462. }
  463. /// <summary>
  464. /// Counts the number of end of line marker sequences in the given text.
  465. /// </summary>
  466. protected int GetLineCount(string/*!*/ text) {
  467. int n = text == null ? 0 : text.Length;
  468. int count = 0;
  469. for (int i = 0; i < n; i++){
  470. switch(text[i]){
  471. case '\r':
  472. if (i+1 < n && text[i+1] == '\n')
  473. i++;
  474. count++;
  475. break;
  476. case '\n':
  477. case (char)0x2028:
  478. case (char)0x2029:
  479. count++;
  480. break;
  481. }
  482. }
  483. return count;
  484. }
  485. /// <summary>An array of offsets, with offset at index i corresponding to the position of the first character of line i, (counting lines from 0).</summary>
  486. private int[] lineOffsets;
  487. /// <summary>The number of lines in Text.</summary>
  488. private int lines;
  489. /// <summary>
  490. /// Returns the index in this.lineOffsets array such that this.lineOffsets[index] is less than or equal to offset
  491. /// and offset is less than lineOffsets[index+1]
  492. /// </summary>
  493. private int Search(int offset){
  494. tryAgain:
  495. int[] lineOffsets = this.lineOffsets;
  496. int lines = this.lines;
  497. if (lineOffsets == null){Debug.Assert(false); return -1;}
  498. if (offset < 0){Debug.Assert(false); return -1;}
  499. int mid = 0;
  500. int low = 0;
  501. int high = lines-1;
  502. while (low < high){
  503. mid = (low+high)/2;
  504. if (lineOffsets[mid] <= offset){
  505. if (offset < lineOffsets[mid+1])
  506. return mid;
  507. else
  508. low = mid + 1;
  509. }else
  510. high = mid;
  511. }
  512. Debug.Assert(lines == this.lines);
  513. Debug.Assert(lineOffsets[low] <= offset);
  514. Debug.Assert(offset < lineOffsets[low+1]);
  515. if (lineOffsets != this.lineOffsets) goto tryAgain;
  516. return low;
  517. }
  518. /// <summary>
  519. /// Maps the given zero based character position in the entire text to a (line, column) pair corresponding to the same position.
  520. /// Counting within the source line starts at 0. Counting source lines start at 0.
  521. /// </summary>
  522. private void GetPosition(int offset, out int line, out int column){
  523. line = 0; column = 0;
  524. if (offset < 0 || this.Text == null || offset > this.Text.Length){Debug.Assert(false); return;}
  525. lock(this){
  526. if (this.lineOffsets == null) this.ComputeLineOffsets();
  527. if (this.lineOffsets == null){Debug.Assert(false); return;}
  528. int[] lineOffsets = this.lineOffsets;
  529. int index = this.Search(offset);
  530. Debug.Assert(lineOffsets == this.lineOffsets);
  531. if (index < 0 || index >= this.lineOffsets.Length){Debug.Assert(false); return;}
  532. Debug.Assert(this.lineOffsets[index] <= offset && offset < this.lineOffsets[index+1]);
  533. line = index;
  534. column = offset-this.lineOffsets[index];
  535. }
  536. }
  537. /// <summary>
  538. /// Adds the given offset to the this.lineOffsets table as the offset corresponding to the start of line this.lines+1.
  539. /// </summary>
  540. private void AddOffset(int offset){
  541. if (this.lineOffsets == null || this.lines < 0){Debug.Assert(false); return;}
  542. if (this.lines >= this.lineOffsets.Length){
  543. int n = this.lineOffsets.Length;
  544. if (n <= 0) n = 16;
  545. int[] newLineOffsets = new int[n*2];
  546. Array.Copy(this.lineOffsets, newLineOffsets, this.lineOffsets.Length);
  547. this.lineOffsets = newLineOffsets;
  548. }
  549. this.lineOffsets[this.lines++] = offset;
  550. }
  551. public virtual void InsertOrDeleteLines(int offset, int lineCount){
  552. if (lineCount == 0) return;
  553. if (offset < 0 || this.Text == null || offset > this.Text.Length){Debug.Assert(false); return;}
  554. lock(this){
  555. if (this.lineOffsets == null)
  556. if (this.lineOffsets == null) this.ComputeLineOffsets();
  557. if (lineCount < 0)
  558. this.DeleteLines(offset, -lineCount);
  559. else
  560. this.InsertLines(offset, lineCount);
  561. }
  562. }
  563. private void DeleteLines(int offset, int lineCount)
  564. //^ requires offset >= 0 && this.Text != null && offset < this.Text.Length && lineCount > 0 && this.lineOffsets != null;
  565. {
  566. Debug.Assert(offset >= 0 && this.Text != null && offset < this.Text.Length && lineCount > 0 && this.lineOffsets != null);
  567. int index = this.Search(offset);
  568. if (index < 0 || index >= this.lines){Debug.Assert(false); return;}
  569. for (int i = index+1; i+lineCount < this.lines; i++){
  570. this.lineOffsets[i] = this.lineOffsets[i+lineCount];
  571. }
  572. this.lines -= lineCount;
  573. if (this.lines <= index){Debug.Assert(false); this.lines = index+1;}
  574. }
  575. private void InsertLines(int offset, int lineCount)
  576. //^ requires offset >= 0 && this.Text != null && offset < this.Text.Length && lineCount > 0 && this.lineOffsets != null;
  577. {
  578. Debug.Assert(offset >= 0 && this.Text != null && offset < this.Text.Length && lineCount > 0 && this.lineOffsets != null);
  579. int index = this.Search(offset);
  580. if (index < 0 || index >= this.lines){Debug.Assert(false); return;}
  581. int n = this.lineOffsets[this.lines-1];
  582. for (int i = 0; i < lineCount; i++) this.AddOffset(++n);
  583. for (int i = lineCount; i > 0; i--){
  584. this.lineOffsets[index+i+1] = this.lineOffsets[index+1];
  585. }
  586. }
  587. /// <summary>
  588. /// Populates this.lineOffsets with an array of offsets, with offset at index i corresponding to the position of the first
  589. /// character of line i, (counting lines from 0).
  590. /// </summary>
  591. private void ComputeLineOffsets()
  592. //ensures this.lineOffsets != null;
  593. {
  594. if (this.Text == null){Debug.Assert(false); return;}
  595. int n = this.Text.Length;
  596. this.lineOffsets = new int[n/10+1];
  597. this.lines = 0;
  598. this.AddOffset(0);
  599. for (int i = 0; i < n; i++){
  600. switch(this.Text[i]){
  601. case '\r':
  602. if (i+1 < n && this.Text[i+1] == '\n')
  603. i++;
  604. this.AddOffset(i+1);
  605. break;
  606. case '\n':
  607. case (char)0x2028:
  608. case (char)0x2029:
  609. this.AddOffset(i+1);
  610. break;
  611. }
  612. }
  613. this.AddOffset(n+1);
  614. this.AddOffset(n+2);
  615. }
  616. /// <summary> Add one to this every time a Document instance gets a unique key.</summary>
  617. private static int uniqueKeyCounter;
  618. private int uniqueKey;
  619. /// <summary>
  620. /// An integer that uniquely distinguishes this document instance from every other document instance.
  621. /// This provides an efficient equality test to facilitate hashing.
  622. /// </summary>
  623. public int UniqueKey{
  624. get{
  625. if (this.uniqueKey == 0){
  626. TryAgain:
  627. int c = Document.uniqueKeyCounter;
  628. int cp1 = c == int.MaxValue ? 1 : c+1;
  629. if (System.Threading.Interlocked.CompareExchange(ref Document.uniqueKeyCounter, cp1, c) != c) goto TryAgain;
  630. this.uniqueKey = cp1;
  631. }
  632. return this.uniqueKey;
  633. }
  634. }
  635. }
  636. #endif
  637. #if !MinimalReader
  638. /// <summary>
  639. /// For creating source contexts that have just a filename, start line and column and end line and column.
  640. /// If a SourceContext has a DocumentWithPrecomputedLineNumbers as its Document, then it should have 0 as its StartPos
  641. /// and 1 as its EndPos because those are used here to decide what to return.
  642. /// </summary>
  643. public class DocumentWithPrecomputedLineNumbers : Document {
  644. private int startLine, startCol, endLine, endCol;
  645. public DocumentWithPrecomputedLineNumbers(string/*!*/ filename, int startLine, int startCol, int endLine, int endCol) {
  646. this.Name = filename;
  647. this.startLine = startLine;
  648. this.startCol = startCol;
  649. this.endLine = endLine;
  650. this.endCol = endCol;
  651. }
  652. public override int GetColumn (int offset) { return offset == 0 ? this.startCol : this.endCol; }
  653. public override int GetLine (int offset) { return offset == 0 ? this.startLine : this.endLine; }
  654. }
  655. #endif
  656. #if UseSingularityPDB
  657. internal class PdbDocument : Document {
  658. internal PdbDocument(PdbLines lines) {
  659. this.Name = lines.file.name;
  660. this.lines = lines;
  661. }
  662. PdbLines lines;
  663. public override int GetColumn(int position) {
  664. PdbLine line = this.lines.lines[position/2];
  665. if (position%2 == 0)
  666. return line.colBegin;
  667. else
  668. return line.colEnd;
  669. }
  670. public override int GetLine(int position) {
  671. PdbLine line = this.lines.lines[position/2];
  672. return (int)line.line;
  673. }
  674. }
  675. #elif !ROTOR
  676. internal class UnmanagedDocument: Document{
  677. internal UnmanagedDocument(IntPtr ptrToISymUnmanagedDocument){
  678. //^ base();
  679. ISymUnmanagedDocument idoc =
  680. (ISymUnmanagedDocument)System.Runtime.InteropServices.Marshal.GetTypedObjectForIUnknown(ptrToISymUnmanagedDocument, typeof(ISymUnmanagedDocument));
  681. if (idoc != null){
  682. try{
  683. #if !FxCop
  684. idoc.GetDocumentType(out this.DocumentType);
  685. idoc.GetLanguage(out this.Language);
  686. idoc.GetLanguageVendor(out this.LanguageVendor);
  687. #endif
  688. uint capacity = 1024;
  689. uint len = 0;
  690. char[] buffer = new char[capacity];
  691. while (capacity >= 1024){
  692. idoc.GetURL(capacity, out len, buffer);
  693. if (len < capacity) break;
  694. capacity += 1024;
  695. buffer = new char[capacity];
  696. }
  697. if (len > 0)
  698. this.Name = new String(buffer, 0, (int)len-1);
  699. }finally{
  700. System.Runtime.InteropServices.Marshal.ReleaseComObject(idoc);
  701. }
  702. }
  703. #if !FxCop
  704. this.LineNumber = -1;
  705. this.Text = null;
  706. #endif
  707. }
  708. private Int32List/*!*/ lineList = new Int32List();
  709. private Int32List/*!*/ columnList = new Int32List();
  710. #if !FxCop
  711. public override int GetLine(int offset){
  712. return this.lineList[offset];
  713. }
  714. public override int GetColumn(int offset){
  715. return this.columnList[offset];
  716. }
  717. public override void GetOffsets(int startLine, int startColumn, int endLine, int endColumn, out int startCol, out int endCol){
  718. int i = UnmanagedDocument.BinarySearch(this.lineList, startLine);
  719. Int32List columnList = this.columnList;
  720. startCol = 0;
  721. for (int j = i, n = columnList.Count; j < n; j++){
  722. if (columnList[j] >= startColumn){ startCol = j; break;}
  723. }
  724. endCol = 0;
  725. i = UnmanagedDocument.BinarySearch(this.lineList, endLine);
  726. for (int j = i, n = columnList.Count; j < n; j++){
  727. if (columnList[j] >= endColumn){ endCol = j; break;}
  728. }
  729. }
  730. private static int BinarySearch(Int32List/*!*/ list, int value){
  731. int mid = 0;
  732. int low = 0;
  733. int high = list.Count-1;
  734. while (low < high){
  735. mid = low + (high-low)/2;
  736. if (list[mid] <= value){
  737. if (list[mid+1] > value)
  738. return mid;
  739. else
  740. low = mid + 1;
  741. }else
  742. high = mid;
  743. }
  744. return low;
  745. }
  746. public override void InsertOrDeleteLines(int offset, int lineCount){
  747. Debug.Assert(false); //Caller should not be modifying an umanaged document
  748. }
  749. #endif
  750. internal int GetOffset(uint line, uint column){
  751. this.lineList.Add((int)line);
  752. this.columnList.Add((int)column);
  753. return this.lineList.Count-1;
  754. }
  755. }
  756. #endif // !ROTOR
  757. #if FxCop
  758. class Document{
  759. internal string Name;
  760. }
  761. public struct SourceContext{
  762. private string name;
  763. private int startLine;
  764. private int endLine;
  765. private int startColumn;
  766. private int endColumn;
  767. internal SourceContext(string name, uint startLine, uint endLine, uint startColumn, uint endColumn){
  768. this.name = name;
  769. checked {
  770. this.startLine = (int)startLine;
  771. this.endLine = (int)endLine;
  772. this.startColumn = (int)startColumn;
  773. this.endColumn = (int)endColumn;
  774. }
  775. }
  776. public string FileName{
  777. get{return this.name;}
  778. }
  779. public int StartLine{
  780. get{return this.startLine;}
  781. }
  782. public int EndLine{
  783. get{return this.endLine;}
  784. }
  785. public int StartColumn{
  786. get{return this.startColumn;}
  787. }
  788. public int EndColumn{
  789. get{return this.endColumn;}
  790. }
  791. }
  792. #else
  793. /// <summary>
  794. /// Records a location within a source document that corresponds to an Abstract Syntax Tree node.
  795. /// </summary>
  796. public struct SourceContext{
  797. /// <summary>The source document within which the AST node is located. Null if the node is not derived from a source document.</summary>
  798. public Document Document;
  799. /// <summary>
  800. /// The zero based index of the first character beyond the last character in the source document that corresponds to the AST node.
  801. /// </summary>
  802. public int EndPos;
  803. /// <summary>
  804. /// The zero based index of the first character in the source document that corresponds to the AST node.
  805. /// </summary>
  806. public int StartPos;
  807. public SourceContext(Document document)
  808. : this(document, 0, document == null ? 0 : (document.Text == null ? 0 : document.Text.Length)){
  809. }
  810. public SourceContext(Document document, int startPos, int endPos){
  811. this.Document = document;
  812. this.StartPos = startPos;
  813. this.EndPos = endPos;
  814. }
  815. public SourceContext(Document/*!*/ document,
  816. int startLine, int startColumn, int endLine, int endColumn){
  817. this.Document = document;
  818. this.Document.GetOffsets(startLine, startColumn, endLine, endColumn, out this.StartPos, out this.EndPos);
  819. }
  820. /// <summary>
  821. /// The number (counting from Document.LineNumber) of the line containing the first character in the source document that corresponds to the AST node.
  822. /// </summary>
  823. public int StartLine{
  824. get{
  825. if (this.Document == null) return 0;
  826. return this.Document.GetLine(this.StartPos);
  827. }
  828. }
  829. /// <summary>
  830. /// The number (counting from one) of the line column containing the first character in the source document that corresponds to the AST node.
  831. /// </summary>
  832. public int StartColumn{
  833. get{
  834. if (this.Document == null) return 0;
  835. return this.Document.GetColumn(this.StartPos);
  836. }
  837. }
  838. /// <summary>
  839. /// The number (counting from Document.LineNumber) of the line containing the first character beyond the last character in the source document that corresponds to the AST node.
  840. /// </summary>
  841. public int EndLine{
  842. get{
  843. #if UseSingularityPDB
  844. if (this.Document == null || (this.Document.Text == null && !(this.Document is PdbDocument))) return 0;
  845. #elif !ROTOR
  846. if (this.Document == null || (this.Document.Text == null && !(this.Document is UnmanagedDocument))) return 0;
  847. #else
  848. if (this.Document == null || this.Document.Text == null) return 0;
  849. #endif
  850. if (this.Document.Text != null && this.EndPos >= this.Document.Text.Length) this.EndPos = this.Document.Text.Length;
  851. return this.Document.GetLine(this.EndPos);
  852. }
  853. }
  854. /// <summary>
  855. /// The number (counting from one) of the line column containing first character beyond the last character in the source document that corresponds to the AST node.
  856. /// </summary>
  857. public int EndColumn{
  858. get{
  859. #if UseSingularityPDB
  860. if (this.Document == null || (this.Document.Text == null && !(this.Document is PdbDocument))) return 0;
  861. #elif !ROTOR
  862. if (this.Document == null || (this.Document.Text == null && !(this.Document is UnmanagedDocument))) return 0;
  863. #else
  864. if (this.Document == null || this.Document.Text == null) return 0;
  865. #endif
  866. if (this.Document.Text != null && this.EndPos >= this.Document.Text.Length) this.EndPos = this.Document.Text.Length;
  867. return this.Document.GetColumn(this.EndPos);
  868. }
  869. }
  870. /// <summary>
  871. /// Returns true if the line and column is greater than or equal the position of the first character
  872. /// and less than or equal to the position of the last character
  873. /// of the source document that corresponds to the AST node.
  874. /// </summary>
  875. /// <param name="line">A line number(counting from Document.LineNumber)</param>
  876. /// <param name="column">A column number (counting from one)</param>
  877. /// <returns></returns>
  878. public bool Encloses(int line, int column){
  879. if (line < this.StartLine || line > this.EndLine) return false;
  880. if (line == this.StartLine) return column >= this.StartColumn && (column <= this.EndColumn || line < this.EndLine);
  881. if (line == this.EndLine) return column <= this.EndColumn;
  882. return true;
  883. }
  884. public bool Encloses(SourceContext sourceContext){
  885. return this.StartPos <= sourceContext.StartPos && this.EndPos >= sourceContext.EndPos && this.EndPos > sourceContext.StartPos;
  886. }
  887. /// <summary>
  888. /// The substring of the source document that corresponds to the AST node.
  889. /// </summary>
  890. public string SourceText{
  891. get{
  892. if (this.Document == null) return null;
  893. return this.Document.Substring(this.StartPos, this.EndPos-this.StartPos);
  894. }
  895. }
  896. }
  897. #endif
  898. #if !MinimalReader
  899. public struct SourceChange{
  900. public SourceContext SourceContext;
  901. public string ChangedText;
  902. }
  903. /// <summary>
  904. /// Allows a compilation to output progress messages and to query if cancellation was requested.
  905. /// </summary>
  906. public class CompilerSite{
  907. public virtual void OutputMessage(string message){
  908. }
  909. public virtual bool ShouldCancel{
  910. get{
  911. return false;
  912. }
  913. }
  914. }
  915. #endif
  916. #if !NoWriter
  917. public enum PlatformType{notSpecified, v1, v11, v2, cli1}
  918. public class CompilerOptions: System.CodeDom.Compiler.CompilerParameters{
  919. public StringCollection AliasesForReferencedAssemblies;
  920. public ModuleKindFlags ModuleKind = ModuleKindFlags.ConsoleApplication;
  921. public bool EmitManifest = true;
  922. public StringList DefinedPreProcessorSymbols;
  923. public string XMLDocFileName;
  924. public string RecursiveWildcard;
  925. public StringList ReferencedModules;
  926. public string Win32Icon;
  927. #if !WHIDBEY
  928. private StringCollection embeddedResources = new StringCollection();
  929. public StringCollection EmbeddedResources{
  930. get{return this.embeddedResources;}
  931. }
  932. private StringCollection linkedResources = new StringCollection();
  933. public StringCollection LinkedResources{
  934. get{return this.linkedResources;}
  935. }
  936. #endif
  937. #if VS7
  938. private System.Security.Policy.Evidence evidence;
  939. public System.Security.Policy.Evidence Evidence{
  940. get{return this.evidence;}
  941. set{this.evidence = value;}
  942. }
  943. #endif
  944. public bool PDBOnly;
  945. public bool Optimize;
  946. public bool IncrementalCompile;
  947. public Int32List SuppressedWarnings;
  948. public bool CheckedArithmetic;
  949. public bool AllowUnsafeCode;
  950. public bool DisplayCommandLineHelp;
  951. public bool SuppressLogo;
  952. public long BaseAddress; //TODO: default value
  953. public string BugReportFileName;
  954. public object CodePage; //must be an int if not null
  955. public bool EncodeOutputInUTF8;
  956. public bool FullyQualifyPaths;
  957. public int FileAlignment;
  958. public bool NoStandardLibrary;
  959. public StringList AdditionalSearchPaths;
  960. public bool HeuristicReferenceResolution;
  961. public string RootNamespace;
  962. public bool CompileAndExecute;
  963. public object UserLocaleId; //must be an int if not null
  964. public string StandardLibraryLocation;
  965. public PlatformType TargetPlatform; //TODO: rename this to TargetRuntime
  966. #if !MinimalReader
  967. public ProcessorType TargetProcessor;
  968. #endif
  969. public string TargetPlatformLocation;
  970. public string AssemblyKeyFile;
  971. public string AssemblyKeyName;
  972. public bool DelaySign;
  973. public TargetInformation TargetInformation;
  974. public Int32List SpecificWarningsToTreatAsErrors;
  975. public Int32List SpecificWarningsNotToTreatAsErrors;
  976. public string OutputPath;
  977. public string ExplicitOutputExtension;
  978. public AppDomain TargetAppDomain;
  979. public bool MayLockFiles;
  980. public string ShadowedAssembly;
  981. public bool UseStandardConfigFile;
  982. #if !MinimalReader
  983. public CompilerSite Site;
  984. #endif
  985. #if ExtendedRuntime
  986. /// <summary>
  987. /// True if the source code for the assembly specify only contracts.
  988. /// </summary>
  989. public bool IsContractAssembly;
  990. /// <summary>
  991. /// Do not emit run-time checks for requires clauses of non-externally-accessible methods, assert statements, loop invariants, and ensures clauses.
  992. /// </summary>
  993. public bool DisableInternalChecks;
  994. /// <summary>
  995. /// Do not emit run-time checks for assume statements.
  996. /// </summary>
  997. public bool DisableAssumeChecks;
  998. /// <summary>
  999. /// Do not emit run-time checks for requires clauses of externally accessible methods.
  1000. /// Do not emit run-time checks that enforce checked exception policy.
  1001. /// </summary>
  1002. public bool DisableDefensiveChecks;
  1003. /// <summary>
  1004. /// Disable the guarded classes feature, which integrates run-time enforcement of object invariants, ownership, and safe concurrency.
  1005. /// </summary>
  1006. public bool DisableGuardedClassesChecks;
  1007. public bool DisableInternalContractsMetadata;
  1008. public bool DisablePublicContractsMetadata;
  1009. /// <summary>
  1010. /// Disable the runtime test against null on non-null typed parameters on public methods
  1011. /// </summary>
  1012. public bool DisableNullParameterValidation;
  1013. public virtual bool LoadDebugSymbolsForReferencedAssemblies {
  1014. get { return false; }
  1015. }
  1016. /// <summary>
  1017. /// If set, the compiler will only parse and then emit an xml file with detailed source contexts
  1018. /// about what is parsed.
  1019. /// </summary>
  1020. public bool EmitSourceContextsOnly = false;
  1021. #endif
  1022. public CompilerOptions(){
  1023. }
  1024. public CompilerOptions(CompilerOptions source){
  1025. if (source == null){Debug.Assert(false); return;}
  1026. this.AdditionalSearchPaths = source.AdditionalSearchPaths; //REVIEW: clone the list?
  1027. this.AliasesForReferencedAssemblies = source.AliasesForReferencedAssemblies;
  1028. this.AllowUnsafeCode = source.AllowUnsafeCode;
  1029. this.AssemblyKeyFile = source.AssemblyKeyFile;
  1030. this.AssemblyKeyName = source.AssemblyKeyName;
  1031. this.BaseAddress = source.BaseAddress;
  1032. this.BugReportFileName = source.BugReportFileName;
  1033. this.CheckedArithmetic = source.CheckedArithmetic;
  1034. this.CodePage = source.CodePage;
  1035. this.CompileAndExecute = source.CompileAndExecute;
  1036. this.CompilerOptions = source.CompilerOptions;
  1037. this.DefinedPreProcessorSymbols = source.DefinedPreProcessorSymbols;
  1038. this.DelaySign = source.DelaySign;
  1039. #if ExtendedRuntime
  1040. this.DisableAssumeChecks = source.DisableAssumeChecks;
  1041. this.DisableDefensiveChecks = source.DisableDefensiveChecks;
  1042. this.DisableGuardedClassesChecks = source.DisableGuardedClassesChecks;
  1043. this.DisableInternalChecks = source.DisableInternalChecks;
  1044. this.DisableInternalContractsMetadata = source.DisableInternalContractsMetadata;
  1045. this.DisablePublicContractsMetadata = source.DisablePublicContractsMetadata;
  1046. #endif
  1047. this.DisplayCommandLineHelp = source.DisplayCommandLineHelp;
  1048. if (source.EmbeddedResources != null)
  1049. foreach (string s in source.EmbeddedResources) this.EmbeddedResources.Add(s);
  1050. this.EmitManifest = source.EmitManifest;
  1051. this.EncodeOutputInUTF8 = source.EncodeOutputInUTF8;
  1052. this.Evidence = source.Evidence;
  1053. this.ExplicitOutputExtension = source.ExplicitOutputExtension;
  1054. this.FileAlignment = source.FileAlignment;
  1055. this.FullyQualifyPaths = source.FullyQualifyPaths;
  1056. this.GenerateExecutable = source.GenerateExecutable;
  1057. this.GenerateInMemory = source.GenerateInMemory;
  1058. this.HeuristicReferenceResolution = source.HeuristicReferenceResolution;
  1059. this.IncludeDebugInformation = source.IncludeDebugInformation;
  1060. this.IncrementalCompile = source.IncrementalCompile;
  1061. #if ExtendedRuntime
  1062. this.IsContractAssembly = source.IsContractAssembly;
  1063. #endif
  1064. if (source.LinkedResources != null)
  1065. foreach (string s in source.LinkedResources) this.LinkedResources.Add(s);
  1066. this.MainClass = source.MainClass;
  1067. this.MayLockFiles = source.MayLockFiles;
  1068. this.ModuleKind = source.ModuleKind;
  1069. this.NoStandardLibrary = source.NoStandardLibrary;
  1070. this.Optimize = source.Optimize;
  1071. this.OutputAssembly = source.OutputAssembly;
  1072. this.OutputPath = source.OutputPath;
  1073. this.PDBOnly = source.PDBOnly;
  1074. this.RecursiveWildcard = source.RecursiveWildcard;
  1075. if (source.ReferencedAssemblies != null)
  1076. foreach (string s in source.ReferencedAssemblies) this.ReferencedAssemblies.Add(s);
  1077. this.ReferencedModules = source.ReferencedModules;
  1078. this.RootNamespace = source.RootNamespace;
  1079. this.ShadowedAssembly = source.ShadowedAssembly;
  1080. this.SpecificWarningsToTreatAsErrors = source.SpecificWarningsToTreatAsErrors;
  1081. this.StandardLibraryLocation = source.StandardLibraryLocation;
  1082. this.SuppressLogo = source.SuppressLogo;
  1083. this.SuppressedWarnings = source.SuppressedWarnings;
  1084. this.TargetAppDomain = source.TargetAppDomain;
  1085. this.TargetInformation = source.TargetInformation;
  1086. this.TargetPlatform = source.TargetPlatform;
  1087. this.TargetPlatformLocation = source.TargetPlatformLocation;
  1088. this.TreatWarningsAsErrors = source.TreatWarningsAsErrors;
  1089. this.UserLocaleId = source.UserLocaleId;
  1090. this.UserToken = source.UserToken;
  1091. this.WarningLevel = source.WarningLevel;
  1092. this.Win32Icon = source.Win32Icon;
  1093. this.Win32Resource = source.Win32Resource;
  1094. this.XMLDocFileName = source.XMLDocFileName;
  1095. }
  1096. public virtual string GetOptionHelp(){
  1097. return null;
  1098. }
  1099. public virtual CompilerOptions Clone() {
  1100. return (CompilerOptions)this.MemberwiseClone();
  1101. }
  1102. }
  1103. #endif
  1104. public sealed class MarshallingInformation{
  1105. private string @class;
  1106. private string cookie;
  1107. private int elementSize;
  1108. private NativeType elementType;
  1109. private NativeType nativeType;
  1110. private int numberOfElements;
  1111. private int paramIndex;
  1112. private int size;
  1113. public MarshallingInformation Clone(){
  1114. return (MarshallingInformation)base.MemberwiseClone();
  1115. }
  1116. public string Class{
  1117. get{return this.@class;}
  1118. set{this.@class = value;}
  1119. }
  1120. public string Cookie{
  1121. get{return this.cookie;}
  1122. set{this.cookie = value;}
  1123. }
  1124. public int ElementSize{
  1125. get{return this.elementSize;}
  1126. set{this.elementSize = value;}
  1127. }
  1128. public NativeType ElementType{
  1129. get{return this.elementType;}
  1130. set{this.elementType = value;}
  1131. }
  1132. public NativeType NativeType{
  1133. get{return this.nativeType;}
  1134. set{this.nativeType = value;}
  1135. }
  1136. public int NumberOfElements{
  1137. get{return this.numberOfElements;}
  1138. set{this.numberOfElements = value;}
  1139. }
  1140. public int ParamIndex{
  1141. get{return this.paramIndex;}
  1142. set{this.paramIndex = value;}
  1143. }
  1144. public int Size{
  1145. get{return this.size;}
  1146. set{this.size = value;}
  1147. }
  1148. }
  1149. #if !NoWriter
  1150. public struct TargetInformation{
  1151. public string Company;
  1152. public string Configuration;
  1153. public string Copyright;
  1154. public string Culture;
  1155. public string Description;
  1156. public string Product;
  1157. public string ProductVersion;
  1158. public string Title;
  1159. public string Trademark;
  1160. public string Version;
  1161. }
  1162. #endif
  1163. public enum NativeType{
  1164. Bool = 0x2, // 4 byte boolean value (true != 0, false == 0)
  1165. I1 = 0x3, // 1 byte signed value
  1166. U1 = 0x4, // 1 byte unsigned value
  1167. I2 = 0x5, // 2 byte signed value
  1168. U2 = 0x6, // 2 byte unsigned value
  1169. I4 = 0x7, // 4 byte signed value
  1170. U4 = 0x8, // 4 byte unsigned value
  1171. I8 = 0x9, // 8 byte signed value
  1172. U8 = 0xa, // 8 byte unsigned value
  1173. R4 = 0xb, // 4 byte floating point
  1174. R8 = 0xc, // 8 byte floating point
  1175. Currency = 0xf, // A currency
  1176. BStr = 0x13, // OLE Unicode BSTR
  1177. LPStr = 0x14, // Ptr to SBCS string
  1178. LPWStr = 0x15, // Ptr to Unicode string
  1179. LPTStr = 0x16, // Ptr to OS preferred (SBCS/Unicode) string
  1180. ByValTStr = 0x17, // OS preferred (SBCS/Unicode) inline string (only valid in st…

Large files files are truncated, but you can click here to view the full file