MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / compileIntArg

Function compileIntArg

src/compute-engine/compilation/gpu-target.ts:403–412  ·  view source on GitHub ↗

Compile an expression as a GPU integer argument. * Integer constants emit as plain literals (`200`); other expressions * are wrapped in a cast (`int(...)` or `i32(...)`).

(
  expr: Expression,
  compile: (e: Expression) => string,
  target?: CompileTarget<Expression>
)

Source from the content-addressed store, hash-verified

401 * `return <body>;` — so a `return` anywhere in them is misplaced, including at
402 * offset 0.
403 *
404 * A token scan, deliberately: it reads the source that is actually about to be
405 * emitted, so it covers every shape (including ones no probe enumerated)
406 * rather than mirroring the emitter's position rules. `return` is a reserved
407 * word in both languages (`gpuCheckIdentifier`), so `\breturn\b` cannot match a
408 * user identifier.
409 */
410function gpuAssertReturnPlacement(
411 subject: string,
412 body: string,
413 language: string
414): void {
415 if (!/\breturn\b/.test(body)) return;

Callers 1

gpu-target.tsFile · 0.85

Calls 4

tryGetConstantFunction · 0.90
compileFunction · 0.70
toStringMethod · 0.65
isIntegerMethod · 0.45

Tested by

no test coverage detected