private string GetEmittedMethodName(Symbol methodSymbol) { string name; if (!_methodNameCache.TryGetValue(methodSymbol.Location, out name)) { Method method = methodSymbol.Type as Method; if (method == null || _programName == null) { // "method" will be null if the symbol is undefined. // There should already be a compile error emitted for the undefined symbol. // "m_programName" is null in some unit testing cases. name = "_Unknown"; } else if (methodSymbol.ImportInfo != null) { ImportedMethod importedMethod = (ImportedMethod)methodSymbol.ImportInfo; StringBuilder nameBuilder = new StringBuilder(); if (!importedMethod.IsStatic) { nameBuilder.Append("instance "); } nameBuilder.Append(IrisTypeToCilTypeName(importedMethod.ReturnType)); nameBuilder.Append(' '); AppendImportedMemberName(nameBuilder, importedMethod); AppendParameterList(nameBuilder, importedMethod.GetParameters()); name = nameBuilder.ToString(); } else { StringBuilder nameBuilder = new StringBuilder(); nameBuilder.Append(IrisTypeToCilTypeName(method.ReturnType)); nameBuilder.Append(' '); nameBuilder.Append(_programName); nameBuilder.Append("::"); nameBuilder.Append(methodSymbol.Name); AppendParameterList(nameBuilder, method.GetParameters()); name = nameBuilder.ToString(); } _methodNameCache.Add(methodSymbol.Location, name); } return(name); }
private static string TryGetFrameNameHelper(DkmInspectionContext inspectionContext, DkmStackWalkFrame frame, DkmVariableInfoFlags argumentFlags) { ImportedMethod currentMethod = TryGetCurrentMethod(inspectionContext, frame); if (currentMethod == null) { return(null); } string name = currentMethod.Name; if (argumentFlags == DkmVariableInfoFlags.None) { return(name); } var type = currentMethod.DeclaringType; if (type.IsStatic && type.Name == "Functions") { ; // No prefix for 'normal' functions } else { // static or instance method ? if (currentMethod.IsStatic) { name = type.FullName + "." + name; } else { name = type.FullName + ":" + name; } } Variable[] args = currentMethod.GetParameters(); if (args.Length == 0) { return(name + "()"); } StringBuilder nameBuilder = new StringBuilder(); nameBuilder.Append(name); nameBuilder.Append('('); bool first = true; bool showTypes = argumentFlags.HasFlag(DkmVariableInfoFlags.Types); bool showNames = argumentFlags.HasFlag(DkmVariableInfoFlags.Names); foreach (Variable arg in args) { if (first) { first = false; } else { nameBuilder.Append(", "); } XSharpType argType = arg.Type; if (showNames) { nameBuilder.Append(arg.Name); } if (showNames && showTypes) { if (arg.In && arg.Out) { nameBuilder.Append(" REF "); } else if (arg.Out) { nameBuilder.Append(" OUT "); } else { nameBuilder.Append(" AS "); } } if (showTypes) { nameBuilder.Append(argType.ToString()); } } nameBuilder.Append(')'); var result = nameBuilder.ToString(); if (result.Contains(clArgs)) { result = result.Replace(clArgs, "[ClipperArguments]"); } return(result); }
private static string TryGetFrameNameHelper(DkmInspectionContext inspectionContext, DkmStackWalkFrame frame, DkmVariableInfoFlags argumentFlags) { ImportedMethod currentMethod = TryGetCurrentMethod(inspectionContext, frame); if (currentMethod == null) { return(null); } string name = currentMethod.Name; if (string.Equals(name, "$.main", StringComparison.Ordinal)) { return("<Main Block>"); } if (argumentFlags == DkmVariableInfoFlags.None) { return(name); } Variable[] args = currentMethod.GetParameters(); if (args.Length == 0) { return(name); } StringBuilder nameBuilder = new StringBuilder(); nameBuilder.Append(name); nameBuilder.Append('('); bool first = true; bool showTypes = argumentFlags.HasFlag(DkmVariableInfoFlags.Types); bool showNames = argumentFlags.HasFlag(DkmVariableInfoFlags.Names); foreach (Variable arg in args) { if (first) { first = false; } else { nameBuilder.Append("; "); } IrisType argType = arg.Type; if (argType.IsByRef) { nameBuilder.Append("var "); argType = argType.GetElementType(); } if (showNames) { nameBuilder.Append(arg.Name); } if (showNames && showTypes) { nameBuilder.Append(" : "); } if (showTypes) { nameBuilder.Append(argType); } } nameBuilder.Append(')'); return(nameBuilder.ToString()); }