public static void SymbolDocument(string fileName, Guid language, Guid languageVendor, Guid documentType) { if (documentType == new Guid(0x5a869d0b, 0x6611, 0x11d3, 0xbd, 0x2a, 0, 0, 0xf8, 8, 0x49, 0xbd)) { if (languageVendor == Guid.Empty) { if (language == Guid.Empty) { // SymbolDocument(string) SymbolDocumentInfo symbolDocument1 = Expression.SymbolDocument(fileName); VerifySymbolDocumentInfo(symbolDocument1, fileName, language, languageVendor, documentType); } // SymbolDocument(string, Guid) SymbolDocumentInfo symbolDocument2 = Expression.SymbolDocument(fileName, language); VerifySymbolDocumentInfo(symbolDocument2, fileName, language, languageVendor, documentType); } // SymbolDocument(string, Guid) SymbolDocumentInfo symbolDocument3 = Expression.SymbolDocument(fileName, language, languageVendor); VerifySymbolDocumentInfo(symbolDocument3, fileName, language, languageVendor, documentType); } // SymbolDocument(string, Guid, Guid) SymbolDocumentInfo symbolDocument4 = Expression.SymbolDocument(fileName, language, languageVendor, documentType); VerifySymbolDocumentInfo(symbolDocument4, fileName, language, languageVendor, documentType); }
private static void VerifySymbolDocumentInfo(SymbolDocumentInfo document, string fileName, Guid language, Guid languageVendor, Guid documentType) { Assert.Equal(fileName, document.FileName); Assert.Equal(language, document.Language); Assert.Equal(languageVendor, document.LanguageVendor); Assert.Equal(documentType, document.DocumentType); }
// ===== ===== ===== ===== ===== ctor ===== ===== ===== ===== ===== public GlobalGen(string filename, BinderFactory factory, ParameterExpression global) { _filename = filename; _factory = factory; _global = global; _docInfo = Expression.SymbolDocument(filename, Engine.Guid); }
//SymbolDocument(string, Guid, Guid, Guid) public static void SymbolDocument4() { //<Snippet1> //Add the following directive to your file //using Microsoft.Scripting.Ast; //We'll create a guid that represents our language. //In real life, this would be a well defined guid, not just created on the fly. Guid MyLanguageGuid = Guid.NewGuid(); //We'll create a guid that represents a vendor //In real life, this would also be a well defined guid, not just created on the fly. Guid MyVendorGuid = Guid.NewGuid(); //We'll create a guid that represents a document type. //Again, in real life, this would also be a well defined guid, not just created on the fly. Guid MyDocumentTypeGuid = Guid.NewGuid(); // This represents a source file that is to be referenced by debug information associated to the code // by a DebugInfo expression. //It also identifies the language the source file contains by its guid. SymbolDocumentInfo MySymbolDocument = Expression.SymbolDocument( "MySourceFile.CoolLanguage", MyLanguageGuid, MyVendorGuid, MyDocumentTypeGuid ); //<Snippet1> }
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()); } _docInfo = Expression.SymbolDocument(sourceName); _moduleBuilder = _assyGen.ModuleBuilder; Path = ComputeAssemblyPath(directory, aname.Name, extension); #if NET461 if (_isDebuggable) { _docWriter = ModuleBuilder.DefineDocument(sourceName, ClojureContext.Default.LanguageGuid, ClojureContext.Default.VendorGuid, Guid.Empty); } #endif }
//The following method does not check the validaity of the span public static Expression AddDebugInfo(Expression expression, SymbolDocumentInfo document, int startLine, int startColumn, int endLine, int endColumn) { if (expression == null) { throw new System.ArgumentNullException("expression"); } var sequencePoint = Expression.DebugInfo(document, startLine, startColumn, endLine, endColumn); var clearance = Expression.ClearDebugInfo(document); //always attach a clearance if (expression.Type == typeof(void)) { return(Expression.Block( sequencePoint, expression, clearance )); } else { //save the expression to a variable var p = Expression.Parameter(expression.Type, null); return(Expression.Block( new[] { p }, sequencePoint, Expression.Assign(p, expression), clearance, p )); } }
public static void DebugInfo(int startLine, int startColumn, int endLine, int endColumn, bool isClear) { SymbolDocumentInfo document = Expression.SymbolDocument("AFile"); DebugInfoExpression ex = Expression.DebugInfo(document, startLine, startColumn, endLine, endColumn); VerifyDebugInfoExpression(ex, document, startLine, startColumn, endLine, endColumn, isClear); }
public static void ClearDebugInfo() { SymbolDocumentInfo document = Expression.SymbolDocument("AFile"); DebugInfoExpression ex = Expression.ClearDebugInfo(document); VerifyDebugInfoExpression(ex, document, 0xfeefee, 0, 0xfeefee, 0, true); }
private GenContext(string sourceName, string assyName, string extension, string directory, bool createDynInitHelper) { // TODO: Make this settable from a *debug* flag #if DEBUG _isDebuggable = true; #else _isDebuggable = false; #endif if (directory != null) { if (directory.Length > 0) //&& directory != ".") { assyName = assyName.Replace("/", "."); } } AssemblyName aname = new AssemblyName(assyName); _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); }
//ClearDebugInfo(SymbolDocumentInfo) static public void ClearDebugInfo1() { //<Snippet1> // add the following directive to your file // using Microsoft.Scripting.Ast; //This SymbolDocumentInfo represents the source file that resulted in the expressions marked with the DebugInfo. SymbolDocumentInfo DocInfo = Expression.SymbolDocument("FakeSourceFile.Fake"); //This Expression represents the end of a section identified by a previous DebugInfo DebugInfoExpression MyClearDebug = Expression.ClearDebugInfo( DocInfo ); //To demonstrate the use of ClearDebugInfo, we create a block with several expressions, some of which are //marked by by a sequence of a DebugInfo and a ClearDebugInfo. //In this case, we've marked the expression that creates a constant with value 6 to have been generated from source //in the file 'FakeSourceFile.Fake', on line 5, between columns 1 and 10. The other expressions will not get associated //debug info (they might have been, for example, compiler generated code). Expression MyBlock = Expression.Block( Expression.Constant(5), Expression.DebugInfo(DocInfo, 5, 1, 5, 10), Expression.Constant(6), MyClearDebug, Expression.Constant(7) ); //</Snippet1> }
public UpdatePositionExpr(IScriptExtent extent, int sequencePoint, SymbolDocumentInfo debugSymbolDocument, bool checkBreakpoints) { this._extent = extent; this._checkBreakpoints = checkBreakpoints; this._debugSymbolDocument = debugSymbolDocument; this._sequencePoint = sequencePoint; }
public DebugExpressionVistor(SymbolDocumentInfo symbolDocumentInfo, Expression initialExpression, IExpressionDescriber expressionDescriber) { _symbolDocumentInfo = symbolDocumentInfo; _expressionDescriber = expressionDescriber; _initialDebugView = _expressionDescriber.Describe(initialExpression); }
public DynamicToExplicitCallSiteConvertor(TypeBuilder typeBuilder, string fileName) { _builder = typeBuilder; if (!string.IsNullOrEmpty(fileName)) { _symbolDocument = Expression.SymbolDocument(fileName); } }
public static Expression AddDebugInfo(Expression expression, SymbolDocumentInfo document, SourceLocation start, SourceLocation end) { if (document == null || !start.IsValid || !end.IsValid) { return(expression); } return(AddDebugInfo(expression, document, start.Line, start.Column, end.Line, end.Column)); }
private Expression <TDelegate> MutateLambdaExpression <TDelegate>(Expression <TDelegate> expression, SymbolDocumentInfo symbolDocument) { Expression returnValue = GetVisitors(expression, symbolDocument) .Aggregate <ExpressionVisitor, Expression>(expression, (current, visitor) => visitor.Visit(current)); return((Expression <TDelegate>)returnValue); }
internal SpanDebugInfoExpression(SymbolDocumentInfo document, int startLine, int startColumn, int endLine, int endColumn) : base(document) { _startLine = startLine; _startColumn = startColumn; _endLine = endLine; _endColumn = endColumn; }
public LuaDebugInfo(string sChunkName, string sMethodName, SymbolDocumentInfo document, int ilOffset, int iLine, int iColumn) { this.sChunkName = sChunkName; this.sMethodName = sMethodName; this.sFileName = document.FileName; this.ilOffset = ilOffset; this.iLine = iLine; this.iColumn = iColumn; } // ctor
private ParsedSymbolDocumentInfo Serialize(SymbolDocumentInfo symbolDocumentInfo) { if (symbolDocumentInfo == null) { throw new ArgumentNullException(nameof(symbolDocumentInfo)); } return(new ParsedSymbolDocumentInfo(symbolDocumentInfo.FileName)); }
public LuaDebugInfo(string chunkName, string methodName, SymbolDocumentInfo document, int ilOffset, int line, int column) { this.chunkName = chunkName; this.methodName = methodName; this.fileName = document.FileName; this.ilOffset = ilOffset; this.line = line; this.column = column; } // ctor
private static string Compile(NativeCompilerParameters parameters, bool installMetaAnnotations, IEnumerable <string> sourceFiles) { List <PathFileInInformation> fileIns = new List <PathFileInInformation>(); foreach (string sourceFile in sourceFiles) { SymbolDocumentInfo symbolDocument = null; if (parameters.EmitDebugSymbols) { symbolDocument = Expression.SymbolDocument(sourceFile, GlobalConstants.LanguageGuid, GlobalConstants.VendorGuid); } PathFileInInformation fileIn = new PathFileInInformation(sourceFile, System.Text.Encoding.UTF8, new FileInErrorSink(sourceFile), symbolDocument); fileIns.Add(fileIn); } if (fileIns.Count == 0) { return(null); } SmalltalkRuntime runtime; if (parameters.ExtensionScopeInitializer == null) { runtime = new SmalltalkRuntime(); } else { runtime = NativeLoadHelper.CreateRuntime(false, (rt, scope) => { parameters.ExtensionScopeInitializer.Invoke(null, new object[] { rt, scope }); }, (rt, scope) => { /* Nothing here */ }); } FileInService compilerService = new FileInService(runtime, installMetaAnnotations, fis => parameters.IsBaseLibrary ? new InternalInstallerContext(fis.Runtime) : new InterchangeInstallerContext(fis.Runtime)); InterchangeInstallerContext installer = compilerService.Read(fileIns); foreach (var fileIn in fileIns) { if (((FileInErrorSink)fileIn.ErrorSink).HadError) { return(null); // Some of the source file had errors, do not attempt the rest - it's meaningless } } installer.ErrorSink = new InstallErrorSink(); installer.InstallMetaAnnotations = compilerService.InstallMetaAnnotations; if (!installer.Install()) { return(null); } parameters.Runtime = runtime; return(NativeCompiler.NativeCompiler.GenerateNativeAssembly(parameters)); }
public ScriptScope(ScriptScope parent, string name, SymbolDocumentInfo document) { _parent = parent; _block = Utils.Lambda(typeof(object), name ?? MakeLambdaName()); if (parent != null && document == null) { document = _parent.Document; } _document = document; }
public TypedDebugInfoExpression(Expression expression, DebugInfoExpression debugInfo) { _document = debugInfo.Document; this.expression = expression; _startLine = debugInfo.StartLine; _startColumn = debugInfo.StartColumn; _endLine = debugInfo.EndLine; _endColumn = debugInfo.EndColumn; this.debugInfo = debugInfo; }
public TypedDebugInfoExpression(SymbolDocumentInfo document, Expression expression, int startLine, int startColumn, int endLine, int endColumn) { Document = document; this.Expression = expression; StartLine = startLine; StartColumn = startColumn; EndLine = endLine; EndColumn = endColumn; DebugInfo = DebugInfo(Document, StartLine, StartColumn, EndLine, EndColumn); }
public TypedDebugInfoExpression(SymbolDocumentInfo document, Expression expression, int startLine, int startColumn, int endLine, int endColumn) { _document = document; this.expression = expression; _startLine = startLine; _startColumn = startColumn; _endLine = endLine; _endColumn = endColumn; debugInfo = Expression.DebugInfo(Document, StartLine, StartColumn, EndLine, EndColumn); }
/// <summary> /// Creates a <see cref="DebugInfoExpression"/> with the specified span. /// </summary> /// <param name="document">The <see cref="SymbolDocumentInfo"/> that represents the source file.</param> /// <param name="startLine">The start line of this <see cref="DebugInfoExpression" />. Must be greater than 0.</param> /// <param name="startColumn">The start column of this <see cref="DebugInfoExpression" />. Must be greater than 0.</param> /// <param name="endLine">The end line of this <see cref="DebugInfoExpression" />. Must be greater or equal than the start line.</param> /// <param name="endColumn">The end column of this <see cref="DebugInfoExpression" />. If the end line is the same as the start line, it must be greater or equal than the start column. In any case, must be greater than 0.</param> /// <returns>An instance of <see cref="DebugInfoExpression"/>.</returns> public static DebugInfoExpression DebugInfo(SymbolDocumentInfo document, int startLine, int startColumn, int endLine, int endColumn) { ContractUtils.RequiresNotNull(document, "document"); if (startLine == 0xfeefee && startColumn == 0 && endLine == 0xfeefee && endColumn == 0) { return(new ClearDebugInfoExpression(document)); } ValidateSpan(startLine, startColumn, endLine, endColumn); return(new SpanDebugInfoExpression(document, startLine, startColumn, endLine, endColumn)); }
private static void VerifyDebugInfoExpression(DebugInfoExpression ex, SymbolDocumentInfo document, int startLine, int startColumn, int endLine, int endColumn, bool isClear) { Assert.Same(document, ex.Document); Assert.Equal(startLine, ex.StartLine); Assert.Equal(startColumn, ex.StartColumn); Assert.Equal(endLine, ex.EndLine); Assert.Equal(endColumn, ex.EndColumn); Assert.Equal(ExpressionType.DebugInfo, ex.NodeType); Assert.Equal(typeof(void), ex.Type); Assert.Equal(isClear, ex.IsClear); }
public JsonNode Serialize(object value) { SymbolDocumentInfo document = (SymbolDocumentInfo)value; return(new JsonObject { ["documenttype"] = new JsonValue(document.DocumentType.ToString()), ["filename"] = new JsonValue(document.FileName), ["language"] = new JsonValue(document.Language.ToString()), ["languagevendor"] = new JsonValue(document.LanguageVendor.ToString()) }); }
private int GetHashSymbolDocumentInfo(SymbolDocumentInfo symbolDocumentInfo) { if (symbolDocumentInfo == null) { return(0); } return(GetHashCode( symbolDocumentInfo.DocumentType.GetHashCode(), symbolDocumentInfo.Language.GetHashCode(), symbolDocumentInfo.LanguageVendor.GetHashCode(), GetDefaultHashCode(symbolDocumentInfo.FileName))); }
private ISymbolDocumentWriter GetSymbolWriter(MethodBuilder method, SymbolDocumentInfo document) { ISymbolDocumentWriter result; if (_symbolWriters == null) { _symbolWriters = new Dictionary<SymbolDocumentInfo, ISymbolDocumentWriter>(); } if (!_symbolWriters.TryGetValue(document, out result)) { result = ((ModuleBuilder)method.Module).DefineDocument(document.FileName, document.Language, document.LanguageVendor, SymbolGuids.DocumentType_Text); _symbolWriters.Add(document, result); } return result; }
//SymbolDocument(string) public static void SymbolDocument1() { //<Snippet1> //Add the following directive to your file //using Microsoft.Scripting.Ast; // This represents a source file that is to be referenced by debug information associated to the code // by a DebugInfo expression. SymbolDocumentInfo MySymbolDocument = Expression.SymbolDocument( "MySourceFile.CoolLanguage" ); //<Snippet1> }
public static void DebugInfo_Invalid() { Assert.Throws <ArgumentNullException>("document", () => Expression.DebugInfo(null, 1, 1, 1, 1)); SymbolDocumentInfo document = Expression.SymbolDocument("AFile"); Assert.Throws <ArgumentOutOfRangeException>("startLine", () => Expression.DebugInfo(document, 0, 1, 1, 1)); Assert.Throws <ArgumentOutOfRangeException>("startColumn", () => Expression.DebugInfo(document, 1, 0, 1, 1)); Assert.Throws <ArgumentOutOfRangeException>("endLine", () => Expression.DebugInfo(document, 1, 1, 0, 1)); Assert.Throws <ArgumentOutOfRangeException>("endColumn", () => Expression.DebugInfo(document, 1, 1, 1, 0)); Assert.Throws <ArgumentException>(null, () => Expression.DebugInfo(document, 10, 1, 1, 1)); Assert.Throws <ArgumentException>(null, () => Expression.DebugInfo(document, 1, 10, 1, 1)); }
private ISymbolDocumentWriter GetSymbolWriter(SymbolDocumentInfo document) { Debug.Assert(_emitDebugSymbols); ISymbolDocumentWriter result; if (!_tree.SymbolWriters.TryGetValue(document, out result)) { var module = (ModuleBuilder)_typeBuilder.Module; result = module.DefineDocument(document.FileName, document.Language, document.LanguageVendor, SymbolGuids.DocumentType_Text); _tree.SymbolWriters.Add(document, result); } return result; }
internal DebugInfoExpression(SymbolDocumentInfo document) { _document = document; }
/// <summary> /// Creates a <see cref="DebugInfoExpression"/> for clearing a sequence point. /// </summary> /// <param name="document">The <see cref="SymbolDocumentInfo"/> that represents the source file.</param> /// <returns>An instance of <see cref="DebugInfoExpression"/> for clearning a sequence point.</returns> public static DebugInfoExpression ClearDebugInfo(SymbolDocumentInfo document) { ContractUtils.RequiresNotNull(document, "document"); return new ClearDebugInfoExpression(document); }
/// <summary> /// Creates a <see cref="DebugInfoExpression"/> with the specified span. /// </summary> /// <param name="document">The <see cref="SymbolDocumentInfo"/> that represents the source file.</param> /// <param name="startLine">The start line of this <see cref="DebugInfoExpression" />. Must be greater than 0.</param> /// <param name="startColumn">The start column of this <see cref="DebugInfoExpression" />. Must be greater than 0.</param> /// <param name="endLine">The end line of this <see cref="DebugInfoExpression" />. Must be greater or equal than the start line.</param> /// <param name="endColumn">The end column of this <see cref="DebugInfoExpression" />. If the end line is the same as the start line, it must be greater or equal than the start column. In any case, must be greater than 0.</param> /// <returns>An instance of <see cref="DebugInfoExpression"/>.</returns> public static DebugInfoExpression DebugInfo(SymbolDocumentInfo document, int startLine, int startColumn, int endLine, int endColumn) { ContractUtils.RequiresNotNull(document, "document"); if (startLine == 0xfeefee && startColumn == 0 && endLine == 0xfeefee && endColumn == 0) { return new ClearDebugInfoExpression(document); } ValidateSpan(startLine, startColumn, endLine, endColumn); return new SpanDebugInfoExpression(document, startLine, startColumn, endLine, endColumn); }
internal ClearDebugInfoExpression(SymbolDocumentInfo document) : base(document) { }