Commit e4d1b4a2
e4d1b4a27f92Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
First-class Proc: Proc#parameters
Emit each proc's parameter metadata -- kind (:req for lambdas, :opt for procs) and name, as interned symbol ids -- as static sp_sym arrays passed to sp_proc_new_meta, and dispatch #parameters on a TY_PROC receiver to sp_proc_parameters (-> [[:kind, :name], ...]).
The kind/name symbols are pre-interned during analyze (alongside the existing SymbolNode-literal interning) so they are present in the symbol table before the codegen prologue emits sp_sym_names.
make test: 167 pass / 5 fail / 672 error (was 166 / 5 / 673); proc_introspection green, no regressions.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- e4d1b4a27f92
- Parent
- f09c6f97a644
src/analyze.cmodifiedView file
if (recv >= 0 && rt == TY_PROC && argc == 0) { if (!strcmp(name, "arity")) return TY_INT; if (!strcmp(name, "lambda?")) return TY_BOOL; if (!strcmp(name, "parameters")) return TY_POLY_ARRAY; } /* identity methods: return the receiver unchanged */ if (v) comp_sym_intern(c, v); } } /* Proc#parameters reports param kinds (:req/:opt) and names as symbols; intern them now so they land in the table before the codegen prologue. */ for (int id = 0; id < c->nt->count; id++) { if (!is_proc_create(c, id)) continue; comp_sym_intern(c, "req"); comp_sym_intern(c, "opt"); int pn = a_proc_params_node(c, id); if (pn < 0) continue; int rn = 0; const int *reqs = nt_arr(c->nt, pn, "requireds", &rn); for (int k = 0; k < rn; k++) { const char *nm = nt_str(c->nt, reqs[k], "name"); if (nm) comp_sym_intern(c, nm); } } for (int iter = 0; iter < 128; iter++) { int ch = 0;src/codegen.cmodifiedView file
Loading diff…