Sprint 273 — PolyglotFFIGlueGenerator (steps 1893-1897): ABIBoundaryExtractor, CHeaderEmitter, RustPythonBindingEmitter, GoCppBindingEmitter. Extracts exported symbols from toComponent provider and emits C ABI + language-specific bindings. Sprint 274 — More Binding Pairs + DWARF (steps 1898-1902): CppJSBindingEmitter (N-API), RustGoBindingEmitter (#[no_mangle]), DWARFBoundaryAnnotator (DW_TAG_* + crossLangBoundary), FFIGlueDispatcher (routes by fromLang→toLang pair), MCP tool whetstone_generate_ffi_glue (#92). Sprint 275 — Cross-Language Symbol Index (steps 1903-1907): SCIPEmitter (SCIP JSON, one doc/language, caller+provider roles), CrossLanguageSymbolTable (byLangName_ + byScip_ dual index), SymbolIndexUpdater (nodeKey diff, clear-and-rebuild), SymbolIndexOrchestrator (orchestrate + update), MCP tool whetstone_emit_symbol_index (#93). Sprint 276 — LSP Proxy Core (steps 1908-1912): LSPProxyServer (JSON-RPC 2.0 dispatcher), LanguageServerRouter (routeByUri/routeByLanguageId), CrossLanguageBoundaryDetector (detect/detectWithUri/detectInLanguage), CrossLanguageDefinitionResolver (resolve/resolveFromUri → DefinitionLocation). End-to-end: Python call site goto-def resolves to Rust sort-core provider. 100/100 tests passing across all four sprints. Architecture gate clean. LoRA sessions recorded for all sprints (~14k tokens captured). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
75 lines
2.2 KiB
C++
75 lines
2.2 KiB
C++
#pragma once
|
|
#include "ABIBoundaryExtractor.h"
|
|
#include <map>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
namespace whetstone {
|
|
|
|
struct SymbolRecord {
|
|
bool found = false;
|
|
std::string name;
|
|
std::string kind;
|
|
std::string fromComponent;
|
|
std::string toComponent;
|
|
std::string fromLanguage;
|
|
std::string toLanguage;
|
|
std::string scipSymbol; // "<toComponent>/<name>."
|
|
};
|
|
|
|
struct SymbolAppearance {
|
|
std::string language; // "Python" | "Rust" | etc.
|
|
std::string role; // "caller" | "provider"
|
|
std::string scipSymbol;
|
|
};
|
|
|
|
class CrossLanguageSymbolTable {
|
|
public:
|
|
void insert(const ABIBoundaryNode& node) {
|
|
std::string scip = makeScipSymbol(node);
|
|
|
|
SymbolRecord rec;
|
|
rec.found = true;
|
|
rec.name = node.name;
|
|
rec.kind = node.kind;
|
|
rec.fromComponent = node.fromComponent;
|
|
rec.toComponent = node.toComponent;
|
|
rec.fromLanguage = node.fromLanguage;
|
|
rec.toLanguage = node.toLanguage;
|
|
rec.scipSymbol = scip;
|
|
|
|
byLangName_[{node.toLanguage, node.name}] = rec;
|
|
byLangName_[{node.fromLanguage, node.name}] = rec;
|
|
|
|
byScip_[scip].push_back({node.toLanguage, "provider", scip});
|
|
byScip_[scip].push_back({node.fromLanguage, "caller", scip});
|
|
}
|
|
|
|
SymbolRecord lookup(const std::string& language, const std::string& name) const {
|
|
auto it = byLangName_.find({language, name});
|
|
if (it == byLangName_.end()) return {};
|
|
return it->second;
|
|
}
|
|
|
|
bool contains(const std::string& language, const std::string& name) const {
|
|
return byLangName_.count({language, name}) > 0;
|
|
}
|
|
|
|
std::vector<SymbolAppearance> lookupByScip(const std::string& scipSymbol) const {
|
|
auto it = byScip_.find(scipSymbol);
|
|
if (it == byScip_.end()) return {};
|
|
return it->second;
|
|
}
|
|
|
|
private:
|
|
std::map<std::pair<std::string,std::string>, SymbolRecord> byLangName_;
|
|
std::map<std::string, std::vector<SymbolAppearance>> byScip_;
|
|
|
|
static std::string makeScipSymbol(const ABIBoundaryNode& node) {
|
|
return node.toComponent + "/" + node.name + ".";
|
|
}
|
|
};
|
|
|
|
} // namespace whetstone
|