| 660 | } |
| 661 | |
| 662 | private categorizeSymbols() { |
| 663 | for (const sym of this.allSymbols) { |
| 664 | const scope = sym.scope; |
| 665 | const type = sym.type; |
| 666 | if (scope !== SymbolScope.Local) { |
| 667 | if (type === SymbolType.Function) { |
| 668 | sym.scope = SymbolScope.Global; |
| 669 | this.globalFuncsMap[sym.name] = sym; |
| 670 | } else if (type === SymbolType.Object) { |
| 671 | if (scope === SymbolScope.Global) { |
| 672 | this.globalVars.push(sym); |
| 673 | } else { |
| 674 | // These fail gdb create-vars. So ignoring them. C++ generates them. |
| 675 | if (debugConsoleLogging) { |
| 676 | console.log('SymbolTable: ignoring non local object: ' + sym.name); |
| 677 | } |
| 678 | } |
| 679 | } |
| 680 | } else if (sym.file) { |
| 681 | // Yes, you can have statics with no file association in C++. They are neither |
| 682 | // truly global or local. Some can be considered global but not sure how to filter. |
| 683 | if (type === SymbolType.Object) { |
| 684 | this.staticVars.push(sym); |
| 685 | } else if (type === SymbolType.Function) { |
| 686 | const tmp = this.staticFuncsMap[sym.name]; |
| 687 | if (tmp) { |
| 688 | tmp.push(sym); |
| 689 | } else { |
| 690 | this.staticFuncsMap[sym.name] = [sym]; |
| 691 | } |
| 692 | } |
| 693 | } else if (type === SymbolType.Function) { |
| 694 | sym.scope = SymbolScope.Global; |
| 695 | this.globalFuncsMap[sym.name] = sym; |
| 696 | } else if (type === SymbolType.Object) { |
| 697 | // We are currently ignoring Local objects with no file association for objects. |
| 698 | // Revisit later with care and decide how to classify them |
| 699 | if (debugConsoleLogging) { |
| 700 | console.log('SymbolTable: ignoring local object: ' + sym.name); |
| 701 | } |
| 702 | } |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | public printSyms(cb?: (str: string) => any) { |
| 707 | cb = cb || console.log; |