MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / blankCudaConstructs

Function blankCudaConstructs

src/extraction/languages/c-cpp.ts:1663–1682  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

1661// braces it never closes, so it fails the balance check and stays untouched.
1662const CUDA_LAUNCH_CONFIG_RE = /<<<[^;]{0,400}?>>>/g;
1663export function blankCudaConstructs(source: string): string {
1664 let out = source;
1665 if (out.indexOf('__') !== -1) {
1666 out = out
1667 .replace(CUDA_LAUNCH_BOUNDS_RE, (m) => ' '.repeat(m.length))
1668 .replace(CUDA_SPECIFIER_RE, (m) => ' '.repeat(m.length));
1669 }
1670 if (out.indexOf('<<<') !== -1) {
1671 out = out.replace(CUDA_LAUNCH_CONFIG_RE, (m) => {
1672 let depth = 0;
1673 for (let i = 0; i < m.length; i++) {
1674 const ch = m.charCodeAt(i);
1675 if (ch === 0x7b /* { */) depth++;
1676 else if (ch === 0x7d /* } */ && --depth < 0) return m;
1677 }
1678 return depth === 0 ? m.replace(/[^\n]/g, ' ') : m;
1679 });
1680 }
1681 return out;
1682}
1683
1684/** Strong content markers for CUDA source in files without a CUDA extension
1685 * (headers). The dunders are execution-space specifiers that only nvcc defines;

Callers 3

extraction.test.tsFile · 0.90
preParseCppSourceFunction · 0.85
preParseCSourceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected