* spawn_patterns.h — process-spawning call sites, per language.
*
* Like the HTTP client tables in service_patterns.h: a call that starts
* another program (subprocess.run, exec.Command, posix_spawn, Process.Start,
* Command::new, ...) becomes a SPAWNS edge to a Process node named after the
* program it starts. Nothing resolves the program to code: the edge records
* that the caller leaves the graph through a process boundary, and which
* program it starts when the call spells it as a literal.
*/
#ifndef CBM_SPAWN_PATTERNS_H
#define CBM_SPAWN_PATTERNS_H
#include "cbm.h"
#include <stdbool.h>
#include <stddef.h>
typedef enum {
* (`sp.run` with `import subprocess as sp`, `run` from
* `from subprocess import run`, Go `exec.Command` from "os/exec"). */
CBM_SPAWN_QUALIFIED = 0,
* definition of that name in the calling module (or one the call reaches
* through an import) still makes it an ordinary call. */
CBM_SPAWN_BARE,
* (Haskell `callProcess` with System.Process, a destructured
* `const { spawn } = require("child_process")`). */
CBM_SPAWN_BARE_IMPORTED,
CBM_SPAWN_STRING_RECEIVER,
} cbm_spawn_rule_t;
typedef struct {
const char *api;
const char *module;
unsigned char rule;
signed char arg;
signed char alt;
* or CBM_SPAWN_ANY_LITERAL */
} cbm_spawn_api_t;
* which is an options tuple or struct (Elixir {:spawn, "cat"}, Zig
* .{ .argv = &.{"ls"} }). Elsewhere only a leading literal or a collection's
* first element is the program. */
#define CBM_SPAWN_ANY_LITERAL (-2)
* import statements (local name -> module path) as extracted, external
* modules included: subprocess or os/exec never resolve to project nodes, so
* the resolver's import map does not hold them. Whether the call is a spawn
* after all is the resolver's to decide: an evidence-backed resolution onto
* project code (an import, the same module, the LSP; never a name guess)
* makes it an ordinary call (src/pipeline/pass_spawns.c). */
const cbm_spawn_api_t *cbm_spawn_match(CBMLanguage lang, const char *callee,
const CBMImport *imports, int count);
* argument, that literal's first word, without directories
* ("/usr/bin/git status" -> "git"). CBM_SPAWN_DYNAMIC when the program is
* not a literal. Writes into buf (at least CBM_SPAWN_PROGRAM_MAX bytes). */
#define CBM_SPAWN_DYNAMIC "<dynamic>"
#define CBM_SPAWN_PROGRAM_MAX 64
void cbm_spawn_program(const cbm_spawn_api_t *api, CBMLanguage lang, const CBMCall *call, char *buf,
size_t n);
#endif