Skip to content
Myr

Expose the names of a module's defined function via `modulemeta`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This reuses the existing `block_list_funcs` capability and adds an extra field on the `modulemeta` output, called `defs`, containing that list of functions.

authored by Alex Wilson · committed by Nico Williams · parent fdab39b · Browse files · 2 files+8 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+8 added−3 removed

  • tests:+7 added−3 removed
  • other:+1 added−0 removed

2 files+8 added−3 removed

modified:src/linker.c+1 added
388 unmodified lines
389 meta = block_module_meta(program);390 if (jv_get_kind(meta) == JV_KIND_NULL)391 meta = jv_object();392 meta = jv_object_set(meta, jv_string("deps"), block_take_imports(&program));393 meta = jv_object_set(meta, jv_string("defs"), block_list_funcs(program, 0));394 }395 locfile_free(src);396 block_free(program);397 }
47 unmodified lines
modified:tests/jq.test+7 added-3 removed
1622 unmodified lines
1623jq: error: Import path must be constant at <top-level>, line 1:16241625modulemeta1626"c"1627{"whatever":null,"deps":[{"as":"foo","is_data":false,"relpath":"a"},{"search":"./","as":"d","is_data":false,"relpath":"d"},{"search":"./","as":"d2","is_data":false,"relpath":"d"},{"search":"./../lib/jq","as":"e","is_data":false,"relpath":"e"},{"search":"./../lib/jq","as":"f","is_data":false,"relpath":"f"},{"as":"d","is_data":true,"relpath":"data"}]}1627{"whatever":null,"deps":[{"as":"foo","is_data":false,"relpath":"a"},{"search":"./","as":"d","is_data":false,"relpath":"d"},{"search":"./","as":"d2","is_data":false,"relpath":"d"},{"search":"./../lib/jq","as":"e","is_data":false,"relpath":"e"},{"search":"./../lib/jq","as":"f","is_data":false,"relpath":"f"},{"as":"d","is_data":true,"relpath":"data"}],"defs":["a/0","c/0"]}16281629modulemeta | .deps |= length1629modulemeta | .deps | length1630"c"1631{"whatever":null,"deps":6}1631616321633modulemeta | .defs | length1634"c"1635216361637%%FAIL IGNORE MSG1638import "syntaxerror" as e; .1639jq: error: syntax error, unexpected ';', expecting $end (Unix shell quoting issues?) at /home/nico/ws/jq/tests/modules/syntaxerror/syntaxerror.jq, line 1:1640
370 unmodified lines