public DebugInfoSourceFileEntry(DebugInfoGenerator debugInfoGenerator, string directory, string fileName) { this.debugInfoGenerator = debugInfoGenerator; this.Directory = directory; this.FileName = fileName; this.file = this.debugInfoGenerator.DefineFile(this); }
public DebugInfoSourceMethodBuilder(DebugInfoGenerator debugInfoGenerator, ISourceMethod method, CollectionMetadata file, CollectionMetadata subprograms) { this.debugInfoGenerator = debugInfoGenerator; CollectionMetadata subroutineTypes; CollectionMetadata functionVariables; subprograms.Add(this.function = debugInfoGenerator.DefineMethod(method, file, out functionVariables)); this.functionVariables = functionVariables; }
public DebugInfoCompileUnitEntry(DebugInfoGenerator debugInfoGenerator, ISourceFileEntry entry, CollectionMetadata file) { this.debugInfoGenerator = debugInfoGenerator; this.file = file; CollectionMetadata enumTypes; CollectionMetadata retainedTypes; CollectionMetadata subprograms; CollectionMetadata globalVariables; CollectionMetadata importedEntities; this.debugInfoGenerator.DefineCompilationUnit( this.file, out enumTypes, out retainedTypes, out subprograms, out globalVariables, out importedEntities); this.enumTypes = enumTypes; this.retainedTypes = retainedTypes; this.subprograms = subprograms; this.globalVariables = globalVariables; this.importedEntities = importedEntities; }
public void DefineCompilationUnit( CollectionMetadata file, out CollectionMetadata enumTypes, out CollectionMetadata retainedTypes, out CollectionMetadata subprograms, out CollectionMetadata globalVariables, out CollectionMetadata importedEntities) { if (!this.CompileUnit.IsEmpty) { var first = this.CompileUnit[0] as CollectionMetadata; enumTypes = first[2] as CollectionMetadata; retainedTypes = first[3] as CollectionMetadata; subprograms = first[4] as CollectionMetadata; globalVariables = (first[5] as CollectionMetadata)[0] as CollectionMetadata; importedEntities = first[6] as CollectionMetadata; this.file = file; this.fileType = new CollectionMetadata(this.indexedMetadata).Add("0x29", file); return; } // 4 - C++ // 12 - C var lang = 4; var compilationUnit = new CollectionMetadata(this.indexedMetadata).Add( string.Format(@"0x11\00{0}\00{1}\000\00\000\00\001", lang, IdentityString), // file file, // Enum Types enumTypes = new CollectionMetadata(this.indexedMetadata), // Retained Types retainedTypes = new CollectionMetadata(this.indexedMetadata), // Subprograms subprograms = new CollectionMetadata(this.indexedMetadata), // Global Variables new CollectionMetadata(this.indexedMetadata).Add(globalVariables = new CollectionMetadata(this.indexedMetadata) { NullIfEmpty = true }), // Imported entities importedEntities = new CollectionMetadata(this.indexedMetadata)); this.globalVariables = globalVariables; this.retainedTypes = retainedTypes; this.file = file; this.fileType = new CollectionMetadata(this.indexedMetadata).Add("0x29", file); this.CompileUnit.Add(compilationUnit); }
private void DefineStructureType(IType type, int line, int offset, int flags, CollectionMetadata structureType) { structureType.Add( string.Format( @"0x13\00{0}\00{1}\00{2}\00{3}\00{4}\00{5}\000", type.Name, line, type.GetTypeSize(true) * 8, LlvmWriter.PointerSize * 8, offset, flags), this.file, null, null, // members this.DefineMembers(type, structureType), null, null, this.structuresByName ? type.FullName : null); if (structuresByName) { this.retainedTypes.Add(structureType); } }
private CollectionMetadata DefineMembers(IType type, CollectionMetadata structureType) { var members = new CollectionMetadata(this.indexedMetadata); foreach (var field in IlReader.Fields(type)) { members.Add(this.DefineMember(field, true, structureType)); } return members; }
public void SequencePoint(int offset, int lineBegin, int colBegin, CollectionMetadata function) { var dbgLine = new CollectionMetadata(this.indexedMetadata).Add(lineBegin, colBegin, function, null); if (dbgLine.Index.HasValue) { this.indexByOffset[offset] = dbgLine.Index.Value; } }
public object DefineType(IType type) { var line = 0; var offset = 0; var flags = 0; object typeMetadata; if (this.typesMetadataCache.TryGetValue(type, out typeMetadata)) { return typeMetadata; } if (type.IsPrimitiveType()) { typeMetadata = this.DefinePrimitiveType(type, line, offset, flags); this.typesMetadataCache[type] = typeMetadata; } else { var structureType = new CollectionMetadata(this.indexedMetadata); var reference = this.structuresByName ? (object)type.FullName : (object)structureType; this.typesMetadataCache[type] = reference; this.DefineStructureType(type, line, offset, flags, structureType); typeMetadata = reference; } return typeMetadata; }
public CollectionMetadata DefineTagExpression() { if (this.tagExpression == null) { this.tagExpression = new CollectionMetadata(this.indexedMetadata).Add("0x102"); } return this.tagExpression; }
public CollectionMetadata DefineMethod(ISourceMethod method, CollectionMetadata file, out CollectionMetadata functionVariables) { // Flags 256 - definition (as main()), 259 - public (member of a class) var flag = 256; // Line number of the opening '{' of the function var scopeLine = method.LineNumber; // find method definition this.methodDefinition = this.writer.MethodsByToken[method.Token]; var methodReferenceType = this.writer.WriteToString(() => this.writer.WriteMethodPointerType(this.writer.Output, this.methodDefinition)); var methodDefinitionName = this.writer.WriteToString(() => this.writer.WriteMethodDefinitionName(this.writer.Output, this.methodDefinition)); CollectionMetadata subroutineTypes; CollectionMetadata parametersTypes; // add compile unit template var methodMetadataDefinition = new CollectionMetadata(this.indexedMetadata).Add( string.Format( @"0x2e\00{0}\00{1}\00{2}\00{3}\000\001\000\000\00{4}\000\00{5}", method.Name, method.DisplayName, method.LinkageName, method.LineNumber, flag, scopeLine), // Source directory (including trailing slash) & file pair file, // Reference to context descriptor this.fileType, // Subroutine types subroutineTypes = new CollectionMetadata(this.indexedMetadata), // indicates which base type contains the vtable pointer for the derived class null, // function method reference ex. "i32 ()* @main" new PlainTextMetadata(string.Concat(methodReferenceType, " ", methodDefinitionName)), // Lists function template parameters null, // Function declaration descriptor null, // List of function variables functionVariables = new CollectionMetadata(this.indexedMetadata)); // add subrouting type subroutineTypes.Add( @"0x15\00\000\000\000\000\000\000", null, null, null, parametersTypes = new CollectionMetadata(this.indexedMetadata), null, null, null); this.currentFunction = methodMetadataDefinition; // add return type parametersTypes.Add( !this.methodDefinition.ReturnType.IsVoid() && !this.methodDefinition.ReturnType.IsStructureType() ? this.DefineType(this.methodDefinition.ReturnType) : null); foreach (var parameter in this.methodDefinition.GetParameters()) { parametersTypes.Add(this.DefineType(parameter.ParameterType)); } return methodMetadataDefinition; }
public CollectionMetadata DefineMember(IField field, bool create = false, CollectionMetadata structureType = null) { var line = 0; var size = field.FieldType.GetTypeSize(true) * 8; var align = LlvmWriter.PointerSize * 8; var offset = !field.IsStatic ? field.GetFieldOffset() * 8 : 0; // static var flags = field.IsStatic ? 4096 : 0; CollectionMetadata memberMetadata; if (!create && this.typeMembersMetadataCache.TryGetValue(field, out memberMetadata)) { return memberMetadata; } var fieldMetadata = new CollectionMetadata(this.indexedMetadata); var typeMember = fieldMetadata.Add( string.Format(@"0xd\00{0}\00{1}\00{2}\00{3}\00{4}\00{5}", field.Name, line, size, align, offset, flags), this.file, this.structuresByName || structureType == null ? (object)this.DefineType(field.DeclaringType) : (object)structureType, this.DefineType(field.FieldType)); if (this.structuresByName) { typeMember.Add((object)null); } typeMembersMetadataCache[field] = typeMember; return typeMember; }