int GetDISubprogram(AST.FunctionDefinition fd) { if (fd.body == null) { return(-1); } if (!debugInfoScopeLookup.TryGetValue(fd, out int subprogramIdx)) { AST.Block block = (AST.Block)fd.body; var ft = typeChecker.GetNodeType(fd); var variablesIdx = AddDebugInfoNode("!{}"); string nodeString = $"distinct !DISubprogram(name: \"{fd.funName}\", linkageName: \"{fd.funName}\", file: !{GetDIFile(block)}, line: {fd.token.Line}, type: !{GetDIType(ft, true)}, isLocal: true, isDefinition: true, scopeLine: {block.token.Line}, flags: DIFlagPrototyped, isOptimized: false, unit: !{debugInfoCompileUnitIdx}, retainedNodes: !{variablesIdx})"; subprogramIdx = AddDebugInfoNode(nodeString); debugInfoScopeLookup.Add(fd, subprogramIdx); } return(subprogramIdx); }
/// <summary> /// Creates a new function invocation /// </summary> /// <param name="source">The function to invoke</param> public FunctionInvocation(AST.FunctionDefinition source, AST.FunctionStatement statment) { Source = source ?? throw new ArgumentNullException(nameof(source)); Statement = statment ?? throw new ArgumentNullException(nameof(statment)); Statements = source.Statements.Select(x => x.Clone()).ToArray(); }