public Emitter(EmitterOptions options) { _options = options; _assemblyName = new AssemblyName(_options.AssemblyName); _assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(_assemblyName, AssemblyBuilderAccess.RunAndSave);// TODO: temp for debugging .RunAndCollect); if (_options.DebugOn) _assembly.SetCustomAttribute ( new CustomAttributeBuilder ( typeof(DebuggableAttribute).GetConstructor ( new System.Type[] { typeof(DebuggableAttribute.DebuggingModes) } ), new object[] { DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.Default } ) ); _module = _assembly.DefineDynamicModule(_assemblyName.Name, _assemblyName.Name + ".dll", _options.DebugOn); if (_options.DebugOn) _symbolWriter = _module.DefineDocument(_options.SourceFileName, Guid.Empty, Guid.Empty, Guid.Empty); _tupleToNative = new Dictionary<Type.TupleType, System.Type>(); }
public ILDynamicMethodDebugImpl(string name, Type delegateType, Type thisType) { _delegateType = delegateType; _expectedLength = 64; var mi = delegateType.GetMethod("Invoke"); var uniqueName = ILDynamicTypeDebugImpl.UniqueName(name); _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(uniqueName), AssemblyBuilderAccess.RunAndSave, DynamicILDirectoryPath.DynamicIL); _moduleBuilder = _assemblyBuilder.DefineDynamicModule(uniqueName + ".dll", true); var sourceCodeFileName = Path.Combine(DynamicILDirectoryPath.DynamicIL, uniqueName + ".il"); _symbolDocumentWriter = _moduleBuilder.DefineDocument(sourceCodeFileName, SymDocumentType.Text, SymLanguageType.ILAssembly, SymLanguageVendor.Microsoft); _sourceCodeWriter = new SourceCodeWriter(sourceCodeFileName, _symbolDocumentWriter); Type[] parameterTypes; if (thisType != null) { parameterTypes = new[] { thisType }.Concat(mi.GetParameters().Select(pi => pi.ParameterType)).ToArray(); } else { parameterTypes = mi.GetParameters().Select(pi => pi.ParameterType).ToArray(); } _sourceCodeWriter.StartMethod(name, mi.ReturnType, parameterTypes, MethodAttributes.Static); _typeBuilder = _moduleBuilder.DefineType(name, TypeAttributes.Public, typeof(object), Type.EmptyTypes); _forbidenInstructions = new ILGenForbidenInstructionsCheating(_typeBuilder); _dynamicMethod = _typeBuilder.DefineMethod("Invoke", MethodAttributes.Public | MethodAttributes.Static, mi.ReturnType, parameterTypes); for (int i = 0; i < parameterTypes.Length; i++) { _dynamicMethod.DefineParameter(i + 1, ParameterAttributes.In, string.Format("arg{0}", i)); } }
internal ProxyBuilderGeneratorItems(AssemblyBuilder assembly, ModuleBuilder module, ISymbolDocumentWriter symbolDocumentWriter) : this() { this.Assembly = assembly; this.Module = module; this.SymbolDocumentWriter = symbolDocumentWriter; }
public void SetPythonSourceFile(string sourceFileName) { if (emitDebugInfo) { sourceFile = myModule.DefineDocument(sourceFileName, PythonLanguageGuid, SymLanguageVendor.Microsoft, SymDocumentType.Text); } }
//------------------------------------------------------------------------------ // SetMethodSourceRange() wrapper //------------------------------------------------------------------------------ void ISymbolWriter.SetMethodSourceRange(ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn) { throw new NotSupportedException(); // Intentionally not supported to match desktop CLR }
public virtual void MarkSequencePoint( ISymbolDocumentWriter document, int startLine, // line number is 1 based int startColumn, // column is 0 based int endLine, // line number is 1 based int endColumn) // column is 0 based { il.MarkSequencePoint(document, startLine, startColumn, endLine, endColumn); }
public void BeginModule(string ifile) { appdomain = System.Threading.Thread.GetDomain(); appname = getAssemblyName(filename); appbuild = appdomain.DefineDynamicAssembly(appname, AssemblyBuilderAccess.Save, "."); emodule = appbuild.DefineDynamicModule(filename + "_module", io.GetOutputFilename(), io.getGenDebug()); Guid g = System.Guid.Empty; if (io.getGenDebug()) srcdoc = emodule.DefineDocument(ifile, g, g, g); }
internal static void Emit(this ILGenerator @this, OpCode opCode, ISymbolDocumentWriter document, StreamWriter file, int lineNumber) { var line = opCode.Name; file.WriteLine(line); @this.MarkSequencePoint(document, lineNumber, 1, lineNumber, line.Length + 1); @this.Emit(opCode); }
public void DefineSequencePoints(ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns) { currentMethod.document = (Document)document; currentMethod.offsets = offsets; currentMethod.lines = lines; currentMethod.columns = columns; currentMethod.endLines = endLines; currentMethod.endColumns = endColumns; }
//------------------------------------------------------------------------------ // DefineSequencePoints() wrapper //------------------------------------------------------------------------------ void ISymbolWriter.DefineSequencePoints(ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns) { int spCount = 0; if (offsets != null) { spCount = offsets.Length; } else if (lines != null) { spCount = lines.Length; } else if (columns != null) { spCount = columns.Length; } else if (endLines != null) { spCount = endLines.Length; } else if (endColumns != null) { spCount = endColumns.Length; } if (spCount == 0) { return; } if ((offsets != null && offsets.Length != spCount) || (lines != null && lines.Length != spCount) || (columns != null && columns.Length != spCount) || (endLines != null && endLines.Length != spCount) || (endColumns != null && endColumns.Length != spCount)) { throw new ArgumentException(); } // Sure, claim to accept any type that implements ISymbolDocumentWriter but the only one that actually // works is the one returned by DefineDocument. The .NET Framework ISymWrapper commits the same signature fraud. // Ideally we'd just return a sealed opaque cookie type, which had an internal accessor to // get the writer out. // Regardless, this cast is important for security - we cannot allow our caller to provide // arbitrary instances of this interface. SymDocumentWriter docwriter = (SymDocumentWriter)document; int hr = m_vtable.DefineSequencePoints(m_pWriter, docwriter.GetUnmanaged(), spCount !, offsets !, lines !, columns !, endLines !, endColumns !); if (hr < 0) { throw Marshal.GetExceptionForHR(hr) !; } }
public static ILGenerator GetILGenerator(this MethodBuilder mb, ISymbolDocumentWriter symbolDocumentWriter, int ilsize = 64) { var ilGenerator = mb.GetILGenerator(ilsize); if (symbolDocumentWriter != null) { ilGenerator.MarkSequencePoint(symbolDocumentWriter, 1, 1, 1, 1); } return(ilGenerator); }
public SourceUnit(CompilationUnitBase /*!*/ compilationUnit, PhpSourceFile /*!*/ sourceFile, Encoding /*!*/ encoding) { Debug.Assert(compilationUnit != null && sourceFile != null && encoding != null); this.compilationUnit = compilationUnit; this.sourceFile = sourceFile; this.encoding = encoding; this.namingContextFieldBuilder = null; // to be filled during compilation just before the unit gets emitted this.symbolDocumentWriter = null; // to be filled during compilation just before the unit gets emitted }
internal void AddLineNumberInfo(ISymbolDocumentWriter document, int iOffset, int iStartLine, int iStartColumn, int iEndLine, int iEndColumn) { this.EnsureCapacity(); this.m_iOffsets[this.m_iLineNumberCount] = iOffset; this.m_iLines[this.m_iLineNumberCount] = iStartLine; this.m_iColumns[this.m_iLineNumberCount] = iStartColumn; this.m_iEndLines[this.m_iLineNumberCount] = iEndLine; this.m_iEndColumns[this.m_iLineNumberCount] = iEndColumn; this.m_iLineNumberCount++; }
public void DefineSequencePoints(ISymbolDocumentWriter document, uint arraySize, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns) { var doc = document as SymbolDocumentWriter; if (doc == null) { throw new ArgumentException("document isn't a non-null SymbolDocumentWriter instance"); } writer.DefineSequencePoints(doc.SymUnmanagedDocumentWriter, arraySize, offsets, lines, columns, endLines, endColumns); }
internal static void Emit(this ILGenerator @this, OpCode opcode, MethodInfo method, ISymbolDocumentWriter document, StreamWriter file, int lineNumber) { var line = opcode.Name + " " + new MethodDescriptor( method, method.DeclaringType.Assembly).Value; file.WriteLine(line); @this.MarkSequencePoint(document, lineNumber, 1, lineNumber, line.Length + 1); @this.Emit(opcode, method); }
internal void AddLineNumberInfo(ISymbolDocumentWriter document, int iOffset, int iStartLine, int iStartColumn, int iEndLine, int iEndColumn) { this.EnsureCapacity(); this.m_iOffsets[this.m_iLineNumberCount] = iOffset; this.m_iLines[this.m_iLineNumberCount] = iStartLine; this.m_iColumns[this.m_iLineNumberCount] = iStartColumn; this.m_iEndLines[this.m_iLineNumberCount] = iEndLine; this.m_iEndColumns[this.m_iLineNumberCount] = iEndColumn; this.m_iLineNumberCount = checked (this.m_iLineNumberCount + 1); }
/// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.SetMethodSourceRange"]/*' /> public void SetMethodSourceRange(ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn) { m_target.SetMethodSourceRange(((SymDocumentWriter)startDoc).InternalDocumentWriter, startLine, startColumn, ((SymDocumentWriter)endDoc).InternalDocumentWriter, endLine, endColumn); }
/// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.DefineSequencePoints"]/*' /> public void DefineSequencePoints(ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns) { m_target.DefineSequencePoints(((SymDocumentWriter)document).InternalDocumentWriter, offsets.Length, offsets, lines, columns, endLines, endColumns); }
public void MarkSequencePoint(ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn) { SequencePoint sp = new SequencePoint(); sp.document = document; sp.offset = code.Position; sp.startLine = startLine; sp.startColumn = startColumn; sp.endLine = endLine; sp.endColumn = endColumn; sequencePoints.Add(sp); }
public IFluentILGenerator MarkSequencePoint( ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn) { _logger.LogMeta($"// ({startLine}, {startColumn}) - ({endLine}-{endColumn})"); _generator.MarkSequencePoint(document, startLine, startColumn, endLine, endColumn); return(this); }
internal TypeDebugging(TypeBuilder type, HashSet <Type> interfacesToImplement, CodeDocument document, ISymbolDocumentWriter symbolDocument, Indention firstIndent) : base() { this.Builder = type; this.Document = document; this.SymbolDocument = symbolDocument; this.InterfacesToImplement = interfacesToImplement; this.AddInterfacesToImplement(); this.BeginType(firstIndent); }
internal int WriteBody(bool initLocals) { if (moduleBuilder.symbolWriter != null) { Debug.Assert(scope != null && scope.parent == null); scope.endOffset = code.Position; } ResolveBranches(); ByteBuffer bb = moduleBuilder.methodBodies; int localVarSigTok = 0; int rva; if (localsCount == 0 && exceptions.Count == 0 && maxStack <= 8 && code.Length < 64 && !fatHeader) { rva = WriteTinyHeaderAndCode(bb); } else { rva = WriteFatHeaderAndCode(bb, ref localVarSigTok, initLocals); } if (moduleBuilder.symbolWriter != null) { if (sequencePoints.Count != 0) { ISymbolDocumentWriter document = sequencePoints[0].document; int[] offsets = new int[sequencePoints.Count]; int[] lines = new int[sequencePoints.Count]; int[] columns = new int[sequencePoints.Count]; int[] endLines = new int[sequencePoints.Count]; int[] endColumns = new int[sequencePoints.Count]; for (int i = 0; i < sequencePoints.Count; i++) { if (sequencePoints[i].document != document) { throw new NotImplementedException(); } offsets[i] = sequencePoints[i].offset; lines[i] = sequencePoints[i].startLine; columns[i] = sequencePoints[i].startColumn; endLines[i] = sequencePoints[i].endLine; endColumns[i] = sequencePoints[i].endColumn; } moduleBuilder.symbolWriter.DefineSequencePoints(document, offsets, lines, columns, endLines, endColumns); } WriteScope(scope, localVarSigTok); } return(rva); }
public virtual void MarkSequencePoint (ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn) { if (currentSequence == null || currentSequence.Document != document) { if (sequencePointLists == null) sequencePointLists = new ArrayList (); currentSequence = new SequencePointList (document); sequencePointLists.Add (currentSequence); } currentSequence.AddSequencePoint (code_len, startLine, startColumn, endLine, endColumn); }
public void DefineSequencePoints(ISymbolDocumentWriter document, int[] ilOffsets, int[] startLines, int[] startColumns, int[] endLines, int[] endColumns) { // we only support a single call per method Debug.Assert(this.document == null); this.document = (DocumentImpl)document; this.ilOffsets = ilOffsets; this.startLines = startLines; this.startColumns = startColumns; this.endLines = endLines; this.endColumns = endColumns; }
internal SourceCodeWriter(string fileName, ISymbolDocumentWriter symbolDocumentWriter) { var directoryName = Path.GetDirectoryName(fileName); if (!string.IsNullOrEmpty(directoryName)) Directory.CreateDirectory(directoryName); _stringBuilder = new StringBuilder(); _sourceWriter = new StringWriter(_stringBuilder); _fileName = fileName; _symbolDocumentWriter = symbolDocumentWriter; _currentLine = 1; Indent = 0; }
private void WriteFiles(List <Document> documents) { foreach (Document doc in documents) { ISymbolDocumentWriter docwriter = m_writer.DefineDocument( doc.url, doc.language, doc.languageVendor, doc.documentType); m_docWriters.Add(doc.id, docwriter); } }
internal DocumentContext(String documentName, int startLine, int startCol, int lastLineInSource, VsaItem sourceItem){ this.documentName = documentName; this.documentWriter = null; this.startLine = startLine; this.startCol = startCol; this.lastLineInSource = lastLineInSource; this.sourceItem = sourceItem; this.engine = sourceItem.engine; this.debugOn = null == engine ? false : engine.GenerateDebugInfo; this._compilerGlobals = null; this.checkForFirst = false; }
internal void Emit(CodeGenerator /*!*/ codeGen) { if (!compilationUnit.IsTransient || ((TransientCompilationUnit)compilationUnit).EvalKind == EvalKinds.SyntheticEval) { this.symbolDocumentWriter = compilationUnit.GetSymbolDocumentWriter(sourceFile.FullPath); } // emit naming context: this.namingContextFieldBuilder = EmitInitNamingContext(); // emit AST content: ast.Emit(codeGen); }
internal DocumentContext(String name, VsaEngine engine){ this.documentName = name; this.documentWriter = null; this.startLine = 0; this.startCol = 0; this.lastLineInSource = 0; this.sourceItem = null; this.engine = engine; this.debugOn = null == engine ? false : engine.GenerateDebugInfo; this._compilerGlobals = null; this.reportedVariables = null; this.checkForFirst = false; }
public void BeginModule(string ifile) { appdomain = System.Threading.Thread.GetDomain(); appname = getAssemblyName(filename); appbuild = appdomain.DefineDynamicAssembly(appname, AssemblyBuilderAccess.Save, "."); emodule = appbuild.DefineDynamicModule(filename + "_module", io.GetOutputFilename(), io.getGenDebug()); Guid g = System.Guid.Empty; if (io.getGenDebug()) { srcdoc = emodule.DefineDocument(ifile, g, g, g); } }
[Category("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly public void DuplicateSymbolDocument() { AssemblyBuilder ab = genAssembly(); ModuleBuilder mb = ab.DefineDynamicModule("foo.dll", "foo.dll", true); // Check that it is possible to redefine a symbol document ISymbolDocumentWriter doc1 = mb.DefineDocument("foo.il", SymDocumentType.Text, SymLanguageType.ILAssembly, SymLanguageVendor.Microsoft); ISymbolDocumentWriter doc2 = mb.DefineDocument("foo.il", SymDocumentType.Text, SymLanguageType.ILAssembly, SymLanguageVendor.Microsoft); }
internal DocumentContext(String documentName, int startLine, int startCol, int lastLineInSource, VsaItem sourceItem) { this.documentName = documentName; this.documentWriter = null; this.startLine = startLine; this.startCol = startCol; this.lastLineInSource = lastLineInSource; this.sourceItem = sourceItem; this.engine = sourceItem.engine; this.debugOn = null == engine ? false : engine.GenerateDebugInfo; this._compilerGlobals = null; this.checkForFirst = false; }
public void SetMethodSourceRange( ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn) { int nsId = GetCurrentNamespace(startDoc); SourceMethodImpl sm = new SourceMethodImpl(methodName, currentToken, nsId); msw.OpenMethod(((ICompileUnit)startDoc).Entry, nsId, sm); methodOpened = true; }
internal DocumentContext(String name, VsaEngine engine) { this.documentName = name; this.documentWriter = null; this.startLine = 0; this.startCol = 0; this.lastLineInSource = 0; this.sourceItem = null; this.engine = engine; this.debugOn = null == engine ? false : engine.GenerateDebugInfo; this._compilerGlobals = null; this.reportedVariables = null; this.checkForFirst = false; }
public void SetMethodSourceRange( ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn) { #if FIXME SourceMethodImpl sm = new SourceMethodImpl(methodName, currentToken, GetCurrentNamespace(startDoc)); msw.OpenMethod(startDoc as ISourceFile, sm, startLine, startColumn, endLine, endColumn); methodOpened = true; #endif }
public void DefineSequencePoints(ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns) { var symDoc = document as SymbolDocumentWriter; if (symDoc == null) { throw new InvalidOperationException(); } HRESULT.ThrowOnFailure(_unmanaged.DefineSequencePoints( symDoc.Unmanaged, offsets.Length, offsets, lines, columns, endLines, endColumns)); }
public ILDynamicTypeDebugImpl(string name, Type baseType, Type[] interfaces) { _name = name; var uniqueName = UniqueName(name); _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(uniqueName), AssemblyBuilderAccess.RunAndSave, "dynamicIL"); _moduleBuilder = _assemblyBuilder.DefineDynamicModule(uniqueName + ".dll", true); var sourceCodeFileName = Path.GetFullPath("dynamicIL/" + uniqueName + ".il"); _symbolDocumentWriter = _moduleBuilder.DefineDocument(sourceCodeFileName, SymDocumentType.Text, SymLanguageType.ILAssembly, SymLanguageVendor.Microsoft); _sourceCodeWriter = new SourceCodeWriter(sourceCodeFileName, _symbolDocumentWriter); _sourceCodeWriter.WriteLine(string.Format("class {0} : {1}{2}", name, baseType.ToSimpleName(), string.Concat(interfaces.Select(i => ", " + i.ToSimpleName())))); _sourceCodeWriter.OpenScope(); _typeBuilder = _moduleBuilder.DefineType(name, TypeAttributes.Public, baseType, interfaces); _forbidenInstructions = new ILGenForbidenInstructionsCheating(_typeBuilder); }
internal SourceCodeWriter(string fileName, ISymbolDocumentWriter symbolDocumentWriter) { var directoryName = Path.GetDirectoryName(fileName); if (!string.IsNullOrEmpty(directoryName)) { Directory.CreateDirectory(directoryName); } _stringBuilder = new StringBuilder(); _sourceWriter = new StringWriter(_stringBuilder); _fileName = fileName; _symbolDocumentWriter = symbolDocumentWriter; _currentLine = 1; Indent = 0; }
public ILDynamicTypeDebugImpl(string name, Type baseType, Type[] interfaces) { _name = name; var uniqueName = UniqueName(name, 259 - (DynamicILDirectoryPath.DynamicIL.Length + 1 + 4)); _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(uniqueName), AssemblyBuilderAccess.RunAndSave, DynamicILDirectoryPath.DynamicIL); _moduleBuilder = _assemblyBuilder.DefineDynamicModule(uniqueName + ".dll", true); var sourceCodeFileName = Path.Combine(DynamicILDirectoryPath.DynamicIL, uniqueName + ".il"); _symbolDocumentWriter = _moduleBuilder.DefineDocument(sourceCodeFileName, SymDocumentType.Text, SymLanguageType.ILAssembly, SymLanguageVendor.Microsoft); _sourceCodeWriter = new SourceCodeWriter(sourceCodeFileName, _symbolDocumentWriter); _sourceCodeWriter.WriteLine( $"class {name} : {baseType.ToSimpleName()}{string.Concat(interfaces.Select(i => ", " + i.ToSimpleName()))}"); _sourceCodeWriter.OpenScope(); _typeBuilder = _moduleBuilder.DefineType(name, TypeAttributes.Public, baseType, interfaces); _forbidenInstructions = new ILGenForbidenInstructionsCheating(_typeBuilder); }
public void SetMethodSourceRange(ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn) { var sdoc = startDoc as SymbolDocumentWriter; if (sdoc == null) { throw new ArgumentException("startDoc isn't a non-null SymbolDocumentWriter instance"); } var edoc = endDoc as SymbolDocumentWriter; if (edoc == null) { throw new ArgumentException("endDoc isn't a non-null SymbolDocumentWriter instance"); } writer.SetMethodSourceRange(sdoc.SymUnmanagedDocumentWriter, (uint)startLine, (uint)startColumn, edoc.SymUnmanagedDocumentWriter, (uint)endLine, (uint)endColumn); }
private GenContext(string directory, AssemblyName aname, string extension, bool createDynInitHelper, string sourceName) { // TODO: Make this settable from a *debug* flag #if DEBUG _isDebuggable = true; #else _isDebuggable = false; #endif _assyGen = new AssemblyGen(aname, directory, extension, _isDebuggable); if ( createDynInitHelper ) _dynInitHelper = new DynInitHelper(_assyGen, GenerateName()); if (_isDebuggable) _docWriter = ModuleBuilder.DefineDocument(sourceName, ClojureContext.Default.LanguageGuid, ClojureContext.Default.VendorGuid, Guid.Empty); _docInfo = Expression.SymbolDocument(sourceName); }
internal DocumentContext(VsaItem sourceItem){ if (sourceItem.codebase != null) this.documentName = sourceItem.codebase; else{ string rootMoniker = sourceItem.engine.RootMoniker; this.documentName = rootMoniker + (rootMoniker.EndsWith("/", StringComparison.Ordinal) ? "" : "/") + sourceItem.Name; } this.documentWriter = null; this.startLine = 0; this.startCol = 0; this.lastLineInSource = 0; this.sourceItem = sourceItem; this.engine = sourceItem.engine; this.debugOn = null == engine ? false : engine.GenerateDebugInfo; this._compilerGlobals = null; this.checkForFirst = false; }
private int FindDocument(ISymbolDocumentWriter document) { if ((this.m_iLastFound >= this.m_DocumentCount) || (this.m_Documents[this.m_iLastFound].m_document != document)) { for (int i = 0; i < this.m_DocumentCount; i++) { if (this.m_Documents[i].m_document == document) { this.m_iLastFound = i; return this.m_iLastFound; } } this.EnsureCapacity(); this.m_iLastFound = this.m_DocumentCount; this.m_Documents[this.m_iLastFound] = new REDocument(document); this.m_DocumentCount++; } return this.m_iLastFound; }
public Emitter(EmitterOptions options) { _options = options; //// TODO: setup separate app domain with appropriate cache path, shadow copying etc. //var domainName = "plan" + DateTime.Now.Ticks.ToString(); //var domain = AppDomain.CreateDomain(domainName); _assemblyName = new AssemblyName(_options.AssemblyName); _assembly = AppDomain.CurrentDomain.DefineDynamicAssembly ( _assemblyName, _options.DebugOn ? AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.RunAndCollect ); if (_options.DebugOn) _assembly.SetCustomAttribute ( new CustomAttributeBuilder ( typeof(DebuggableAttribute).GetConstructor ( new System.Type[] { typeof(DebuggableAttribute.DebuggingModes) } ), new object[] { DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.Default } ) ); _module = _assembly.DefineDynamicModule(_assemblyName.Name, _assemblyName.Name + ".dll", _options.DebugOn); if (_options.DebugOn) _symbolWriter = _module.DefineDocument(_options.SourceFileName, Guid.Empty, Guid.Empty, Guid.Empty); _tupleToNative = new Dictionary<TupleType, System.Type>(); }
internal void AddLineNumberInfo( ISymbolDocumentWriter document, int iOffset, int iStartLine, int iStartColumn, int iEndLine, int iEndColumn) { int i; // make sure that arrays are large enough to hold addition info i = FindDocument(document); Contract.Assert(i < m_DocumentCount, "Bad document look up!"); m_Documents[i].AddLineNumberInfo(document, iOffset, iStartLine, iStartColumn, iEndLine, iEndColumn); }
public virtual void MarkSequencePoint( ISymbolDocumentWriter document, int startLine, // line number is 1 based int startColumn, // column is 0 based int endLine, // line number is 1 based int endColumn) // column is 0 based { if (startLine == 0 || startLine < 0 || endLine == 0 || endLine < 0) { throw new ArgumentOutOfRangeException("startLine"); } Contract.EndContractBlock(); m_LineNumberInfo.AddLineNumberInfo(document, m_length, startLine, startColumn, endLine, endColumn); }
/// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.SetMethodSourceRange"]/*' /> public void SetMethodSourceRange(ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn) { m_target.SetMethodSourceRange(((SymDocumentWriter)startDoc).InternalDocumentWriter, startLine, startColumn, ((SymDocumentWriter)endDoc).InternalDocumentWriter, endLine, endColumn); }
/// <include file='doc\SymWriter.uex' path='docs/doc[@for="SymbolWriter.DefineSequencePoints"]/*' /> public void DefineSequencePoints(ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns) { m_target.DefineSequencePoints(((SymDocumentWriter)document).InternalDocumentWriter, offsets.Length, offsets, lines, columns, endLines, endColumns); }
public virtual void MarkSequencePoint (ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn) { if (currentSequence == null || currentSequence.Document != document) { if (sequencePointLists == null) sequencePointLists = new ArrayList (); currentSequence = new SequencePointList (document); sequencePointLists.Add (currentSequence); } currentSequence.AddSequencePoint (code_len, startLine, startColumn, endLine, endColumn); }
internal void AddLineNumberInfo( ISymbolDocumentWriter document, int iOffset, int iStartLine, int iStartColumn, int iEndLine, int iEndColumn) { Contract.Assert(document == m_document, "Bad document look up!"); // make sure that arrays are large enough to hold addition info EnsureCapacity(); m_iOffsets[m_iLineNumberCount] = iOffset; m_iLines[m_iLineNumberCount] = iStartLine; m_iColumns[m_iLineNumberCount] = iStartColumn; m_iEndLines[m_iLineNumberCount] = iEndLine; m_iEndColumns[m_iLineNumberCount] = iEndColumn; checked { m_iLineNumberCount++; } }
internal REDocument(ISymbolDocumentWriter document) { this.m_document = document; }
/// <summary> /// Marks a sequence point in the Microsoft intermediate language (MSIL) stream. /// </summary> /// <param name="document">The document for which the sequence point is being defined.</param> /// <param name="startLine">The line where the sequence point begins.</param> /// <param name="startColumn">The column in the line where the sequence point begins.</param> /// <param name="endLine">The line where the sequence point ends.</param> /// <param name="endColumn">The column in the line where the sequence point ends.</param> /// <returns>Current instance of the EmitHelper.</returns> public EmitHelper MarkSequencePoint( ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn) { _ilGenerator.MarkSequencePoint(document, startLine, startColumn, endLine, endColumn); return this; }
internal void DefineSymbolDocument(ModuleBuilder module, string url, Guid language, Guid languageVendor, Guid documentType) { symbols = module.DefineDocument(url, language, languageVendor, documentType); }
/// <summary> /// Marks a sequence point in the Microsoft intermediate language (MSIL) stream. /// </summary> /// <param name="il"/> /// <param name="document">The document for which the sequence point is being defined.</param> /// <param name="startLine">The line where the sequence point begins.</param> /// <param name="startColumn">The column in the line where the sequence point begins.</param> /// <param name="endLine">The line where the sequence point ends.</param> /// <param name="endColumn">The column in the line where the sequence point ends.</param> public static ILGenerator MarkSequencePoint( this ILGenerator il, ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn) { il.MarkSequencePoint(document, startLine, startColumn, endLine, endColumn); return il; }
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void MarkSequencePoint(ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn) { throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); }
// Find a REDocument representing document. If we cannot find one, we will add a new entry into // the REDocument array. private int FindDocument(ISymbolDocumentWriter document) { int i; // This is an optimization. The chance that the previous line is coming from the same // document is very high. if (m_iLastFound < m_DocumentCount && m_Documents[m_iLastFound].m_document == document) return m_iLastFound; for (i = 0; i < m_DocumentCount; i++) { if (m_Documents[i].m_document == document) { m_iLastFound = i; return m_iLastFound; } } // cannot find an existing document so add one to the array EnsureCapacity(); m_iLastFound = m_DocumentCount; m_Documents[m_iLastFound] = new REDocument(document); checked { m_DocumentCount++; } return m_iLastFound; }
internal REDocument(ISymbolDocumentWriter document) { // initialize data variables m_iLineNumberCount = 0; m_document = document; }
internal void EmitLineInfo(ILGenerator ilgen, int line, int column, int endLine, int endColumn) { if (debugOn) { if (checkForFirst && line == this.firstStartLine && column == this.firstStartCol && endLine == this.firstEndLine && endColumn == this.firstEndCol) checkForFirst = false; else{ if (this.documentWriter == null) this.documentWriter = this.GetSymDocument(documentName); ilgen.MarkSequencePoint(this.documentWriter, this.startLine + line - this.lastLineInSource, this.startCol + column + 1, this.startLine - this.lastLineInSource + endLine, this.startCol + endColumn + 1); } } }
/// <summary> /// Marks a sequence point in the Microsoft intermediate language (MSIL) stream. /// </summary> public void MarkSequencePoint(ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn) { il.MarkSequencePoint(document, startLine, startColumn, endLine, endColumn); }
public SequencePointList (ISymbolDocumentWriter doc) { this.doc = doc; }