@eagleoutice/flowr 2.17.7 → 2.17.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/abstract-interpretation/branch-paths.d.ts +10 -0
  2. package/abstract-interpretation/branch-paths.js +104 -10
  3. package/config.js +3 -1
  4. package/control-flow/control-flow-graph.js +18 -2
  5. package/data/r-base-guards.generated.js +2 -2
  6. package/dataflow/environments/ambient-effect.js +4 -1
  7. package/dataflow/environments/built-in-props.d.ts +8 -2
  8. package/dataflow/environments/built-in-props.js +16 -5
  9. package/dataflow/environments/default-builtin-config/base-functions.js +1 -1
  10. package/dataflow/environments/default-builtin-config/guards.d.ts +1 -1
  11. package/dataflow/environments/default-builtin-config/guards.js +28 -0
  12. package/dataflow/environments/default-builtin-config/index.d.ts +8 -4
  13. package/dataflow/environments/default-builtin-config/index.js +9 -5
  14. package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
  15. package/dataflow/environments/default-builtin-config/parallel-execution.js +25 -0
  16. package/dataflow/environments/guard-facts.d.ts +28 -1
  17. package/dataflow/environments/pkg-name.d.ts +2 -0
  18. package/dataflow/environments/query-fn-props.d.ts +19 -15
  19. package/dataflow/environments/query-fn-props.js +46 -36
  20. package/dataflow/environments/removal-marker.d.ts +1 -1
  21. package/dataflow/environments/removal-marker.js +18 -3
  22. package/dataflow/environments/reserved-names.d.ts +6 -0
  23. package/dataflow/environments/reserved-names.js +14 -0
  24. package/dataflow/environments/resolve-by-name.js +5 -10
  25. package/dataflow/eval/resolve/alias-tracking.js +23 -6
  26. package/dataflow/extractor.js +103 -28
  27. package/dataflow/fn/argument-roles.d.ts +3 -0
  28. package/dataflow/fn/argument-roles.js +5 -5
  29. package/dataflow/fn/exceptions-of-function.d.ts +7 -0
  30. package/dataflow/fn/exceptions-of-function.js +15 -2
  31. package/dataflow/fn/function-props.d.ts +1 -1
  32. package/dataflow/fn/function-props.js +40 -18
  33. package/dataflow/fn/function-semantics.d.ts +3 -1
  34. package/dataflow/fn/function-semantics.js +2 -0
  35. package/dataflow/fn/guards/built-in-guards.js +2 -1
  36. package/dataflow/fn/guards/condition-grouping.d.ts +11 -0
  37. package/dataflow/fn/guards/condition-grouping.js +50 -3
  38. package/dataflow/fn/guards/function-guards.d.ts +10 -0
  39. package/dataflow/fn/guards/function-guards.js +130 -14
  40. package/dataflow/fn/guards/guard-claims.d.ts +2 -0
  41. package/dataflow/fn/guards/guard-claims.js +42 -2
  42. package/dataflow/fn/guards/guard-knowledge.d.ts +7 -1
  43. package/dataflow/fn/guards/guard-knowledge.js +50 -4
  44. package/dataflow/fn/guards/guard-term.js +10 -1
  45. package/dataflow/fn/higher-order-function.d.ts +15 -1
  46. package/dataflow/fn/higher-order-function.js +54 -10
  47. package/dataflow/graph/call-graph.d.ts +5 -0
  48. package/dataflow/graph/call-graph.js +51 -15
  49. package/dataflow/graph/df-helper.d.ts +2 -0
  50. package/dataflow/graph/df-helper.js +4 -2
  51. package/dataflow/graph/graph.d.ts +21 -0
  52. package/dataflow/graph/graph.js +63 -2
  53. package/dataflow/internal/linker.d.ts +20 -0
  54. package/dataflow/internal/linker.js +190 -24
  55. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +20 -12
  56. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +5 -3
  57. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +2 -1
  58. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +2 -0
  59. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +5 -0
  60. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +7 -3
  61. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +12 -5
  62. package/dataflow/internal/process/functions/call/deferred.d.ts +7 -2
  63. package/dataflow/internal/process/functions/call/deferred.js +63 -28
  64. package/dataflow/internal/process/functions/call/quoted.js +33 -7
  65. package/documentation/data/dfg/doc-ambient.js +3 -1
  66. package/documentation/wiki-normalized-ast.js +1 -1
  67. package/documentation/wiki-query.js +9 -3
  68. package/package.json +5 -3
  69. package/project/context/flowr-analyzer-context.d.ts +7 -4
  70. package/project/context/flowr-analyzer-context.js +8 -3
  71. package/project/context/flowr-analyzer-files-context.js +1 -0
  72. package/project/context/flowr-analyzer-functions-context.d.ts +2 -1
  73. package/project/context/flowr-analyzer-functions-context.js +9 -8
  74. package/project/flowr-analyzer.d.ts +7 -4
  75. package/project/flowr-analyzer.js +37 -8
  76. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +22 -0
  77. package/project/plugins/file-plugins/files/flowr-namespace-file.js +34 -0
  78. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -1
  79. package/project/sigdb/build.js +41 -2
  80. package/project/sigdb/decode.d.ts +3 -1
  81. package/project/sigdb/decode.js +45 -1
  82. package/project/sigdb/decompress.d.ts +5 -0
  83. package/project/sigdb/decompress.js +17 -1
  84. package/project/sigdb/manifest.d.ts +2 -1
  85. package/project/sigdb/manifest.js +12 -5
  86. package/project/sigdb/native-routines.d.ts +82 -0
  87. package/project/sigdb/native-routines.js +178 -0
  88. package/project/sigdb/reader.d.ts +21 -3
  89. package/project/sigdb/reader.js +35 -3
  90. package/project/sigdb/schema.d.ts +107 -3
  91. package/project/sigdb/schema.js +8 -2
  92. package/project/sigdb/sigdb-download.js +1 -1
  93. package/project/sigdb/sigdb-version.d.ts +7 -1
  94. package/project/sigdb/sigdb-version.js +12 -9
  95. package/project/sigdb/spec-query.d.ts +9 -4
  96. package/project/sigdb/spec-query.js +71 -45
  97. package/queries/catalog/call-context-query/call-context-query-executor.js +76 -29
  98. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -12
  99. package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +3 -0
  100. package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +3 -2
  101. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +3 -0
  102. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
  103. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +3 -1
  104. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +4 -2
  105. package/queries/catalog/signature-query/signature-query-executor.js +6 -2
  106. package/queries/catalog/signature-query/signature-query-format.d.ts +4 -0
  107. package/util/collections/bounded-map.d.ts +9 -0
  108. package/util/collections/bounded-map.js +22 -0
  109. package/util/collections/defaultmap.d.ts +5 -0
  110. package/util/collections/defaultmap.js +10 -0
  111. package/util/fixpoint.d.ts +6 -1
  112. package/util/fixpoint.js +45 -3
  113. package/util/flowr-version.d.ts +1 -1
  114. package/util/flowr-version.js +2 -2
  115. package/util/global-caches.d.ts +26 -0
  116. package/util/global-caches.js +43 -0
  117. package/util/monoid.js +2 -2
  118. package/util/quads.js +11 -3
  119. package/util/r-package-urls.d.ts +19 -0
  120. package/util/r-package-urls.js +41 -0
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.exceptionsOfFunction = exceptionsOfFunction;
4
+ exports.exceptionsOfFunctions = exceptionsOfFunctions;
4
5
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
5
6
  const built_in_proc_name_1 = require("../environments/built-in-proc-name");
6
7
  const vertex_1 = require("../graph/vertex");
@@ -59,6 +60,15 @@ function joinRaised(a, b) {
59
60
  * @useInstead {@link FunctionSemantics.exceptions}
60
61
  */
61
62
  function exceptionsOfFunction(id, graph, { knownThrower = {} } = {}) {
63
+ return exceptionsOfFunctions([id], graph, { knownThrower });
64
+ }
65
+ /**
66
+ * {@link exceptionsOfFunction} for several definitions of one call graph at once: what a call raises is summarized once and
67
+ * shared by every definition reaching it, rather than walked again per definition. Answers for the `ids` and every
68
+ * definition the walk passed.
69
+ * @useInstead {@link FunctionSemantics.exceptionsOfAll}
70
+ */
71
+ function exceptionsOfFunctions(ids, graph, { knownThrower = {} } = {}) {
62
72
  const info = (0, query_fn_props_1.builtInLookup)();
63
73
  const isGuarded = (0, defaultmap_1.memoize)((n) => guarded(n, graph, info));
64
74
  const own = new Map();
@@ -80,9 +90,12 @@ function exceptionsOfFunction(id, graph, { knownThrower = {} } = {}) {
80
90
  /* a guarded call is only ever reached through the construct guarding it, which ends the walk of its own */
81
91
  return graph.edgesFrom(current).keys().filter(n => !isGuarded(n));
82
92
  }, n => own.get(n), { empty: RaisesNothing, concat: joinRaised });
83
- const result = { [id]: [...raised.of(id).values()] };
93
+ const result = {};
94
+ for (const id of ids) {
95
+ result[id] = [...raised.of(id).values()];
96
+ }
84
97
  for (const def of defs) {
85
- result[def] = [...raised.of(def).values()];
98
+ result[def] ??= [...raised.of(def).values()];
86
99
  }
87
100
  return result;
88
101
  }
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { DataflowGraph } from '../graph/graph';
6
6
  import { type StatedProps } from '../environments/built-in-props';
7
- import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
+ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import { type ArgumentRolesOptions, type FunctionArgumentRoles } from './argument-roles';
9
9
  /** What flowR infers about a set of definitions, see {@link inferFunctions}. */
10
10
  export interface InferredFunctions {
@@ -4,15 +4,20 @@ exports.inferFunctions = inferFunctions;
4
4
  const function_semantics_1 = require("./function-semantics");
5
5
  const edge_1 = require("../graph/edge");
6
6
  const vertex_1 = require("../graph/vertex");
7
+ const built_in_proc_name_1 = require("../environments/built-in-proc-name");
8
+ const native_routines_1 = require("../../project/sigdb/native-routines");
7
9
  const built_in_props_1 = require("../environments/built-in-props");
8
10
  const query_fn_props_1 = require("../environments/query-fn-props");
9
11
  const identifier_1 = require("../environments/identifier");
12
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
13
+ const r_symbol_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
10
14
  const info_1 = require("../info");
11
15
  const strict_function_1 = require("./strict-function");
12
16
  const argument_roles_1 = require("./argument-roles");
13
17
  const frame_reflection_1 = require("./frame-reflection");
14
18
  const function_guards_1 = require("./guards/function-guards");
15
19
  const logic_1 = require("../../util/logic");
20
+ const defaultmap_1 = require("../../util/collections/defaultmap");
16
21
  const df_helper_1 = require("../graph/df-helper");
17
22
  const fixpoint_1 = require("../../util/fixpoint");
18
23
  /**
@@ -20,28 +25,28 @@ const fixpoint_1 = require("../../util/fixpoint");
20
25
  * @useInstead {@link FunctionSemantics.props}
21
26
  */
22
27
  function inferFunctions(definitions, graph, options = {}) {
23
- const { ctx, only } = options;
28
+ const { ctx, only, natives = ctx === undefined ? [] : native_routines_1.NativeRoutines.ofProject(ctx) } = options;
24
29
  const strict = (0, strict_function_1.strictnessOfEach)(definitions, graph, { ctx });
30
+ const info = (0, query_fn_props_1.builtInLookup)(ctx);
25
31
  return {
26
- props: only === 'arguments' ? {} : callProps(definitions, { graph, info: (0, query_fn_props_1.builtInLookup)(ctx) }, strict),
32
+ props: only === 'arguments' ? {} : callProps(definitions, { graph, info, routineOf: native_routines_1.NativeRoutines.lookup(natives, graph, info, ctx) }, strict),
27
33
  roles: only === 'function' ? {} : rolesOfDefinitions(definitions, graph, strict, options)
28
34
  };
29
35
  }
30
- /** The {@link CallProp} mask of each definition, `Strict` included and what its callees carry mixed in. */
36
+ /** The {@link CallProp} mask of each definition, `Strict` included, what its callees carry mixed in, and `Pure` if everything it reaches only computes. */
31
37
  function callProps(definitions, state, strict) {
32
38
  const { join, filter, hasAny } = function_semantics_1.FunctionSemantics.call.props;
33
- const own = new Map();
39
+ /* a callee is asked about as well, whether or not it is one of the definitions to answer for */
40
+ const own = (0, defaultmap_1.memoize)((id) => {
41
+ const of = propsOf(id, state);
42
+ return { ...of, stated: strict[id]?.strict === logic_1.Ternary.Always ? join(of.stated, { props: built_in_props_1.CallProp.Strict }) : of.stated };
43
+ });
34
44
  /* what a function carries over to its callers: its own propagated props and those of everything it reaches */
35
- const carried = new fixpoint_1.ReachSummaries(id => {
36
- /* a callee is asked about as well, whether or not it is one of the definitions to answer for */
37
- const { stated, callees } = propsOf(id, state);
38
- own.set(id, strict[id]?.strict === logic_1.Ternary.Always ? join(stated, { props: built_in_props_1.CallProp.Strict }) : stated);
39
- return callees;
40
- }, id => filter(own.get(id), built_in_props_1.PropagatedProps), { empty: {}, concat: join });
45
+ const carried = new fixpoint_1.ReachSummaries(id => own(id).callees, id => filter(own(id).stated, built_in_props_1.PropagatedProps), { empty: {}, concat: join });
46
+ const impure = new fixpoint_1.ReachSummaries(id => own(id).callees, id => own(id).impure, { empty: false, concat: (a, b) => a || b });
41
47
  return Object.fromEntries(definitions.map(id => {
42
- const reached = carried.of(id);
43
- const mine = own.get(id);
44
- const grown = join(mine, reached);
48
+ const mine = own(id).stated;
49
+ const grown = join(join(mine, carried.of(id)), impure.of(id) ? {} : { props: built_in_props_1.CallProp.Pure });
45
50
  return [id, sameProps(grown, mine) ? mine : grown];
46
51
  }).filter(([, props]) => hasAny(props)));
47
52
  }
@@ -73,27 +78,44 @@ function rolesOfDefinitions(definitions, graph, strict, options) {
73
78
  }
74
79
  return all;
75
80
  }
81
+ /** Whether the call only computes its value, the definitions of the program it runs aside: a pure built-in or native routine, a binding in its own frame, or steering. */
82
+ function onlyComputes(vertex, info, state) {
83
+ if (vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Assignment)) {
84
+ return !(0, frame_reflection_1.bindsOutside)(vertex, info);
85
+ }
86
+ return function_guards_1.Steering.some(proc => vertex_1.DfgVertex.hasOrigin(vertex, proc)) || function_semantics_1.FunctionSemantics.call.props.hasAny(info, built_in_props_1.CallProp.Pure) || state.routineOf(vertex)?.pure === true;
87
+ }
76
88
  function propsOf(id, state) {
77
89
  const { join, filter } = function_semantics_1.FunctionSemantics.call.props;
78
90
  const definition = state.graph.getVertex(id);
79
91
  if (!vertex_1.DfgVertex.isFunctionDefinition(definition)) {
80
- return { stated: {}, callees: [] };
92
+ return { stated: {}, callees: [], impure: true };
81
93
  }
82
94
  let stated = {};
95
+ let impure = false;
96
+ const formals = new Set(Object.keys(definition.params).map(id => {
97
+ const name = state.graph.idMap?.get(node_id_1.NodeId.normalize(id));
98
+ return r_symbol_1.RSymbol.is(name) ? String(identifier_1.Identifier.getName(name.content)) : undefined;
99
+ }));
83
100
  const callees = [];
84
101
  for (const [node, vertex] of df_helper_1.Dataflow.callsIn(definition, state.graph)) {
85
102
  const info = state.info(vertex.name);
86
- const carried = filter(info, built_in_props_1.PropagatedProps);
87
- stated = join(stated, { props: (carried.props ?? 0) & ((0, frame_reflection_1.bindsOutside)(vertex, info) ? ~0 : ~built_in_props_1.CallProp.Scope), tags: carried.tags });
103
+ const routine = state.routineOf(vertex);
104
+ /* a pure routine has no effect, one starting threads or forking runs concurrently */
105
+ const carried = filter(info, routine?.pure ? built_in_props_1.PureCarriedProps : built_in_props_1.PropagatedProps);
106
+ stated = join(stated, { props: (carried.props ?? 0) & ((0, frame_reflection_1.bindsOutside)(vertex, info) ? ~0 : ~built_in_props_1.CallProp.Scope) | (native_routines_1.NativeRoutines.concurrent(routine) ? built_in_props_1.CallProp.Concurrent : 0), tags: carried.tags });
88
107
  if (built_in_props_1.DispatchCallees.has(identifier_1.Identifier.getName(vertex.name))) {
89
108
  stated = join(stated, { props: built_in_props_1.CallProp.Generic });
90
109
  }
91
- callees.push(...df_helper_1.Dataflow.calleeIdsOf(state.graph, node));
110
+ const ran = df_helper_1.Dataflow.calleeIdsOf(state.graph, node);
111
+ /* calling a formal runs whatever a caller hands over, so it is pure only as far as that is, which the definition alone cannot tell */
112
+ impure ||= formals.has(String(identifier_1.Identifier.getName(vertex.name))) || (ran.length === 0 && !onlyComputes(vertex, info, state));
113
+ callees.push(...ran);
92
114
  }
93
115
  if (exitsInvisibly(definition, state)) {
94
116
  stated = join(stated, { props: built_in_props_1.CallProp.Invisible });
95
117
  }
96
- return { stated, callees };
118
+ return { stated, callees, impure };
97
119
  }
98
120
  /** Whether every unconditional exit ends in a call returning invisibly; a bare value result (`function() 1`) never does. */
99
121
  function exitsInvisibly(definition, state) {
@@ -1,5 +1,5 @@
1
1
  import { inferFunctions } from './function-props';
2
- import { exceptionsOfFunction } from './exceptions-of-function';
2
+ import { exceptionsOfFunction, exceptionsOfFunctions } from './exceptions-of-function';
3
3
  import { promiseDependencies, promiseForcing, promiseForcingPoints, promiseRaises, settleDefinitionsInPromises, settleJumpsInPromises, strictnessOfEach } from './strict-function';
4
4
  import { isHigherOrder } from './higher-order-function';
5
5
  import { argumentRolesOfFunctions } from './argument-roles';
@@ -19,6 +19,8 @@ export declare const FunctionSemantics: {
19
19
  readonly props: typeof inferFunctions;
20
20
  /** The exceptions a definition may raise. */
21
21
  readonly exceptions: typeof exceptionsOfFunction;
22
+ /** The exceptions each of several definitions of one call graph may raise, summarized once for all of them. */
23
+ readonly exceptionsOfAll: typeof exceptionsOfFunctions;
22
24
  /** The strictness of several definitions, sharing the work between them. */
23
25
  readonly strictness: typeof strictnessOfEach;
24
26
  /** Settles what a jump within a promise does, once the calls are linked. */
@@ -29,6 +29,8 @@ exports.FunctionSemantics = {
29
29
  props: function_props_1.inferFunctions,
30
30
  /** The exceptions a definition may raise. */
31
31
  exceptions: exceptions_of_function_1.exceptionsOfFunction,
32
+ /** The exceptions each of several definitions of one call graph may raise, summarized once for all of them. */
33
+ exceptionsOfAll: exceptions_of_function_1.exceptionsOfFunctions,
32
34
  /** The strictness of several definitions, sharing the work between them. */
33
35
  strictness: strict_function_1.strictnessOfEach,
34
36
  /** Settles what a jump within a promise does, once the calls are linked. */
@@ -27,6 +27,7 @@ const group_method_guards_1 = require("./group-method-guards");
27
27
  const group_generics_1 = require("../../environments/group-generics");
28
28
  const arrays_1 = require("../../../util/collections/arrays");
29
29
  const stored_location_1 = require("./stored-location");
30
+ const global_caches_1 = require("../../../util/global-caches");
30
31
  /** The functions the terms call, see {@link StatedGuards.calls}. */
31
32
  function callsOfTerms(terms) {
32
33
  return (0, arrays_1.uniqueArray)(terms.flatMap(term => guard_term_1.GuardTerm.callsOf(term).map(id => identifier_1.Identifier.toString(id))));
@@ -184,7 +185,7 @@ function builtInGuards(name, pkg = (0, r_base_packages_1.baseRExportOwner)(name)
184
185
  return builtInGuardsCache.get(key);
185
186
  }
186
187
  /** {@link builtInGuards} per `pkg::name`, as the table and the facts do not change while flowR runs */
187
- const builtInGuardsCache = new Map();
188
+ const builtInGuardsCache = global_caches_1.GlobalCaches.map('built-in-guards', global_caches_1.CacheScope.Process, 16_384);
188
189
  function readBuiltInGuards(name, owner) {
189
190
  const stored = (0, r_base_guards_generated_1.RBaseGuards)()[String(owner)]?.[String(name)];
190
191
  const read = stored === undefined ? undefined : statedGuardsOfStored(stored, `${String(owner)}::${String(name)}`);
@@ -10,6 +10,17 @@ export declare function grouped(this: void, text: string): string;
10
10
  export declare function allOf(this: void, conditions: readonly string[]): string;
11
11
  /** The formals in groups of those that `links` tie together, each group in the order of `formals` and the groups by their first formal, so what depends on each other reads together. */
12
12
  export declare function linkedGroups(this: void, formals: readonly string[], links: readonly (readonly string[])[]): string[][];
13
+ /** `condition unless unless`, one `unless` with every way through for a condition that has one of its own: `(a unless b) unless c` reads `a unless b || c`. */
14
+ export declare function withUnless(this: void, condition: string, unless: string): string;
15
+ /**
16
+ * The ways through that rows of a contract share, so they are said once for all of them: of what two conditions both offer, the ways through
17
+ * that the most rows have times how many they are, none if fewer than two rows have any. A row is the conditions all of which have to hold.
18
+ */
19
+ export declare function sharedEscapes(this: void, rows: readonly (readonly string[])[]): string[];
20
+ /** Whether every condition of the row lets the call through by each of the `escapes`. */
21
+ export declare function hasEscapes(this: void, row: readonly string[], escapes: readonly string[]): boolean;
22
+ /** The condition without the given ways through its `unless`, without the `unless` if none is left. */
23
+ export declare function withoutEscapes(this: void, condition: string, escapes: readonly string[]): string;
13
24
  /**
14
25
  * The relations with each comparison once: a comparison that holds unless `u1` and holds unless `u2` holds unless both do,
15
26
  * written with what both offer said once, `c || (a1 && a2)` for `c || a1` and `c || a2`, and a comparison stated as well with its sides swapped is the same one.
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
- /*
3
- * How a condition of a contract groups, without anything else of flowR, so the pages showing contracts can use it as well.
4
- */
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.splitTopLevel = splitTopLevel;
7
4
  exports.grouped = grouped;
8
5
  exports.allOf = allOf;
9
6
  exports.linkedGroups = linkedGroups;
7
+ exports.withUnless = withUnless;
8
+ exports.sharedEscapes = sharedEscapes;
9
+ exports.hasEscapes = hasEscapes;
10
+ exports.withoutEscapes = withoutEscapes;
10
11
  exports.mergedRelations = mergedRelations;
12
+ /*
13
+ * How a condition of a contract groups, with nothing of flowR but a collection helper, so the pages showing contracts can use it as well.
14
+ */
15
+ const arrays_1 = require("../../../util/collections/arrays");
11
16
  /** The parts of `text` separated by `separator` outside of any parentheses, brackets, braces, or strings. */
12
17
  function splitTopLevel(text, separator) {
13
18
  const parts = [];
@@ -71,6 +76,48 @@ function linkedGroups(formals, links) {
71
76
  }
72
77
  return formals.filter((f, at) => formals.findIndex(g => groupOf.get(g) === groupOf.get(f)) === at).map(first => formals.filter(f => groupOf.get(first) === groupOf.get(f)));
73
78
  }
79
+ /** The condition and the `||`-joined ways through its outermost `unless`, none if it has no `unless`. */
80
+ function escapesOf(condition) {
81
+ const [holds, ...unless] = splitTopLevel(bare(condition), ' unless ');
82
+ return [holds, unless.flatMap(u => splitTopLevel(bare(u), ' || '))];
83
+ }
84
+ /** `condition unless unless`, one `unless` with every way through for a condition that has one of its own: `(a unless b) unless c` reads `a unless b || c`. */
85
+ function withUnless(condition, unless) {
86
+ const [holds, own] = escapesOf(condition);
87
+ const escapes = (0, arrays_1.uniqueArrayMerge)(own, splitTopLevel(bare(unless), ' || '));
88
+ return grouped(`${holds} unless ${escapes.join(' || ')}`);
89
+ }
90
+ /**
91
+ * The ways through that rows of a contract share, so they are said once for all of them: of what two conditions both offer, the ways through
92
+ * that the most rows have times how many they are, none if fewer than two rows have any. A row is the conditions all of which have to hold.
93
+ */
94
+ function sharedEscapes(rows) {
95
+ const escapes = rows.map(row => row.map(c => escapesOf(c)[1]));
96
+ /* the candidates are what two conditions both offer, the best one shared by many rows and saying much */
97
+ const offered = escapes.flat().filter(e => e.length > 0);
98
+ let best = [], score = 0;
99
+ for (let i = 0; i < offered.length; i++) {
100
+ for (let j = i + 1; j < offered.length; j++) {
101
+ const common = offered[i].filter(e => offered[j].includes(e));
102
+ const having = common.length === 0 ? 0 : escapes.filter(row => row.length > 0 && row.every(c => common.every(e => c.includes(e)))).length;
103
+ if (having >= 2 && common.length * having > score) {
104
+ best = common;
105
+ score = common.length * having;
106
+ }
107
+ }
108
+ }
109
+ return best;
110
+ }
111
+ /** Whether every condition of the row lets the call through by each of the `escapes`. */
112
+ function hasEscapes(row, escapes) {
113
+ return escapes.length > 0 && row.length > 0 && row.every(c => escapes.every(e => escapesOf(c)[1].includes(e)));
114
+ }
115
+ /** The condition without the given ways through its `unless`, without the `unless` if none is left. */
116
+ function withoutEscapes(condition, escapes) {
117
+ const [holds, own] = escapesOf(condition);
118
+ const rest = own.filter(e => !escapes.includes(e));
119
+ return own.length === 0 ? condition : rest.length === 0 ? grouped(holds) : grouped(`${holds} unless ${rest.join(' || ')}`);
120
+ }
74
121
  /** the comparisons a relation is written with, each with the one that reads the same with its sides swapped */
75
122
  const Mirrored = { ' == ': ' == ', ' != ': ' != ', ' <= ': ' >= ', ' >= ': ' <= ', ' < ': ' > ', ' > ': ' < ' };
76
123
  /** `text` without parentheses around all of it */
@@ -7,11 +7,13 @@ import { type Origin } from '../../origin/dfg-get-origin';
7
7
  import { type DataflowGraphVertexFunctionCall } from '../../graph/vertex';
8
8
  import { type ArgProps } from '../../environments/built-in-props';
9
9
  import { type BrandedIdentifier } from '../../environments/identifier';
10
+ import { BuiltInProcName } from '../../environments/built-in-proc-name';
10
11
  import { type ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
11
12
  import { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
12
13
  import type { AstIdMap, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
13
14
  import { GuardTerm, type GuardBinding, type GuardOuter } from './guard-term';
14
15
  import type { GuardFactsLookup } from '../../environments/guard-facts';
16
+ import type { SigNativeRoutineInfo } from '../../../project/sigdb/schema';
15
17
  import { type ClaimedRelation, type ConditionalClaim, type FormalClaim } from './guard-claims';
16
18
  /** One condition every normal return of a function has passed; if it does not hold, the call fails. */
17
19
  export interface GuardClause {
@@ -59,6 +61,12 @@ export interface FunctionGuards {
59
61
  export interface FunctionGuardsOptions {
60
62
  /** how to ask what a built-in states, so a configured or overwritten one answers, in the R version analyzed for */
61
63
  readonly ctx?: ReadOnlyFlowrAnalyzerContext;
64
+ /**
65
+ * The native routines of the analyzed package, as a tool read them off its compiled code, which flowR cannot do itself:
66
+ * a call to one asks what the routine's {@link SigNativeRoutineInfo.guards} state, and has an effect unless the routine is pure.
67
+ * Without them, those the signature database records for the analyzed package (see {@link NativeRoutines.ofProject}).
68
+ */
69
+ readonly natives?: readonly SigNativeRoutineInfo[];
62
70
  }
63
71
  /** Whether the id is that of a parameter of a function definition. */
64
72
  export declare function isParameter(this: void, id: NodeId, idMap: AstIdMap): boolean;
@@ -95,6 +103,8 @@ export declare function atCall(this: void, condition: GuardTerm, call: CallBindi
95
103
  };
96
104
  /** The literal message a call like `stop("...")` raises. */
97
105
  export declare function messageOf(this: void, node: RNodeWithParent | undefined): string | undefined;
106
+ /** What only steers where the body goes on, which does nothing of its own: the effects are what it runs. */
107
+ export declare const Steering: readonly BuiltInProcName[];
98
108
  /**
99
109
  * What each of the `definitions` asks of the calls it returns from, a *necessary* condition: a call that returns normally
100
110
  * has passed all of it, with the formals standing for the values they hold at the guard.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Steering = void 0;
3
4
  exports.isParameter = isParameter;
4
5
  exports.readsViaParameter = readsViaParameter;
5
6
  exports.callBinding = callBinding;
@@ -40,6 +41,9 @@ const frame_reflection_1 = require("../frame-reflection");
40
41
  const higher_order_function_1 = require("../higher-order-function");
41
42
  const defaultmap_1 = require("../../../util/collections/defaultmap");
42
43
  const guard_term_1 = require("./guard-term");
44
+ const arrays_1 = require("../../../util/collections/arrays");
45
+ const native_routines_1 = require("../../../project/sigdb/native-routines");
46
+ const guard_term_syntax_1 = require("./guard-term-syntax");
43
47
  const guard_knowledge_1 = require("./guard-knowledge");
44
48
  const group_generics_1 = require("../../environments/group-generics");
45
49
  const group_method_guards_1 = require("./group-method-guards");
@@ -61,6 +65,11 @@ const guard_claims_1 = require("./guard-claims");
61
65
  /** Nothing is known about why the code was reached, as with a loop body. */
62
66
  const UnknownStep = { holds: guard_term_1.GuardTerm.True, fails: guard_term_1.GuardTerm.True };
63
67
  const NoContract = { clauses: [], required: [], effects: true, opens: false, returned: [], reach: 0, called: false };
68
+ /** {@link Dataflow.origin} of the node, worked out once per node and guard state. */
69
+ function originsOf(state, id) {
70
+ state.origins ??= (0, defaultmap_1.memoize)(n => df_helper_1.Dataflow.origin(state.graph, n));
71
+ return state.origins(id);
72
+ }
64
73
  /** Whether the call runs the given built-in behavior for sure, rather than maybe a function of the program with the same name. */
65
74
  function runsBuiltIn(vertex, proc) {
66
75
  return vertex_1.DfgVertex.hasOrigin(vertex, proc) && !vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Function);
@@ -89,7 +98,7 @@ function readsViaParameter(origins, graph) {
89
98
  }
90
99
  /** The definition a call runs for sure, if there is exactly one and nothing else it could be. */
91
100
  function soleCallee(id, state) {
92
- const origins = df_helper_1.Dataflow.origin(state.graph, id) ?? [];
101
+ const origins = originsOf(state, id) ?? [];
93
102
  const callees = origins.filter(o => o.type === 2 /* OriginType.FunctionCallOrigin */);
94
103
  return callees.length === 1 && !readsViaParameter(origins, state.graph) && !origins.some(o => o.type === 3 /* OriginType.BuiltInFunctionOrigin */) ? callees[0].id : undefined;
95
104
  }
@@ -99,7 +108,7 @@ function packageOf(facts) {
99
108
  }
100
109
  /** Whether the call may run a function of the program, an operator linked to the `Ops` methods of the program still being the operator. */
101
110
  function mayRunOwn(id, vertex, state) {
102
- return vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Function) && df_helper_1.Dataflow.origin(state.graph, id)?.some(o => o.type !== 3 /* OriginType.BuiltInFunctionOrigin */) === true;
111
+ return vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Function) && originsOf(state, id)?.some(o => o.type !== 3 /* OriginType.BuiltInFunctionOrigin */) === true;
103
112
  }
104
113
  /** The name of the function a call runs, if it is what R or the named package ships with rather than something the program defines. */
105
114
  function knownNameOf(id, vertex, state) {
@@ -125,7 +134,7 @@ function onlyComputes(id, vertex, state) {
125
134
  if (vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Assignment)) {
126
135
  return !(0, frame_reflection_1.bindsOutside)(vertex, info);
127
136
  }
128
- return (0, guard_knowledge_1.onlyComputesBy)(state.facts(name)) || built_in_props_1.CallProps.hasAny(info, built_in_props_1.CallProp.Pure);
137
+ return (0, guard_knowledge_1.onlyComputesBy)(state.facts(name)) || built_in_props_1.CallProps.hasAny(info, built_in_props_1.CallProp.Pure) || state.routineOf(vertex)?.pure === true;
129
138
  }
130
139
  /** Whether every call within the term is one flowR knows computes nothing but its value, so it may stand in where a variable was read. */
131
140
  function isPureTerm(term, state) {
@@ -163,7 +172,7 @@ function symbolTerm(node, scope, state, depth) {
163
172
  else if (scope.frameIsOpen) {
164
173
  return undefined;
165
174
  }
166
- const found = df_helper_1.Dataflow.origin(state.graph, node.info.id)?.filter(o => !scope.skips.has(o.id));
175
+ const found = originsOf(state, node.info.id)?.filter(o => !scope.skips.has(o.id));
167
176
  /* the target of `names(x) <- v` is defined there, while the replacement function reads what it held before */
168
177
  const origins = found !== undefined && found.length > 1 ? found.filter(o => o.id !== node.info.id) : found;
169
178
  if (origins === undefined || origins.length === 0) {
@@ -419,7 +428,7 @@ function termOfUncached(node, scope, state, depth) {
419
428
  return seen;
420
429
  }
421
430
  /* a function of the body's own has no name a caller could call it by */
422
- if (df_helper_1.Dataflow.origin(state.graph, node.info.id)?.some(o => o.type === 2 /* OriginType.FunctionCallOrigin */ && scope.vertex.subflow.graph.has(o.id))) {
431
+ if (originsOf(state, node.info.id)?.some(o => o.type === 2 /* OriginType.FunctionCallOrigin */ && scope.vertex.subflow.graph.has(o.id))) {
423
432
  return undefined;
424
433
  }
425
434
  const args = vertex !== undefined && built_in_props_1.CallProps.hasAny(state.info(vertex.name), built_in_props_1.ImpureProps) ? undefined : argumentTerms(node.arguments, scope, state, depth);
@@ -608,12 +617,18 @@ function conditionRequirement(construct, part, condNode, path, run) {
608
617
  /** What the call of a built-in asks of what it was handed, on top of evaluating it. */
609
618
  function builtInRequirements(name, vertex, path, run) {
610
619
  const { state, scope } = run;
611
- const asks = state.facts(name)?.asks;
612
- if (asks === undefined) {
620
+ const facts = state.facts(name);
621
+ const asks = facts?.asks;
622
+ if (asks === undefined && facts?.recycles === undefined) {
613
623
  return;
614
624
  }
615
- const bound = boundArguments(vertex, state.info(vertex.name)?.sig?.map(([formal]) => formal) ?? Object.keys(asks), state);
625
+ const stated = [...Object.keys(asks ?? {}), ...(facts?.recycles ?? []).flatMap(r => [...r.among, ...[r.to, r.unless].filter(f => f !== undefined)])];
626
+ const bound = boundArguments(vertex, state.info(vertex.name)?.sig?.map(([formal]) => formal) ?? (0, arrays_1.uniqueArray)(stated), state);
616
627
  const termOfNode = (n) => termOf(n, scope, state);
628
+ recyclingRequirements(facts?.recycles ?? [], facts?.masks === true, bound, termOfNode, vertex, path, run);
629
+ if (asks === undefined) {
630
+ return;
631
+ }
617
632
  /* an operator also dispatches on its other operand, which has to be stated to be ruled out */
618
633
  const operands = Object.keys(asks).length === 2 ? [...bound.values()].flat() : [];
619
634
  /* what another formal was handed, as far as it is one of the caller's, as a literal would only spell out what is known of it */
@@ -635,6 +650,104 @@ function builtInRequirements(name, vertex, path, run) {
635
650
  }
636
651
  }
637
652
  }
653
+ /** What the native routine a foreign function call runs asks of the values handed to it, see {@link FunctionGuardsOptions.natives}. */
654
+ function nativeRequirements(vertex, path, run) {
655
+ const { state, scope } = run;
656
+ const routine = state.routineOf(vertex);
657
+ const params = routine?.params?.map(p => p.name) ?? [];
658
+ const condition = routine?.guards?.requires ? (0, guard_term_syntax_1.parseGuardTerm)(routine.guards.requires, params, state.facts) : undefined;
659
+ if (condition === undefined) {
660
+ return;
661
+ }
662
+ const args = native_routines_1.NativeRoutines.argumentsOf(vertex, state.graph.idMap);
663
+ const binding = new Map(params.flatMap((param, i) => {
664
+ const term = args[i] === undefined ? undefined : termOf(args[i], scope, state);
665
+ return term === undefined ? [] : [[param, term]];
666
+ }));
667
+ const { requires } = atCall(condition, { binding, dotsUnnamed: false }, undefined, state.facts);
668
+ if (guard_term_1.GuardTerm.formalsOf(requires).size > 0) {
669
+ addClause(run, path, requires, vertex.id, { kind: 'implicit' });
670
+ }
671
+ }
672
+ /**
673
+ * Where the call masks the variables of the caller, see {@link GuardFacts.masks}: per value handed over, the names an argument before it gives,
674
+ * `undefined` once an unnamed one before it may bring names of its own, as a data frame does.
675
+ */
676
+ function maskedNames(vertex, termOfNode, graph) {
677
+ const masked = new Map();
678
+ let names = new Set();
679
+ for (const arg of vertex.args) {
680
+ if (!graph_1.FunctionArgument.isNotEmpty(arg)) {
681
+ continue;
682
+ }
683
+ const value = valueOfArgument(arg.nodeId, vertex, graph);
684
+ if (value !== undefined) {
685
+ masked.set(value.info.id, names === undefined ? undefined : new Set(names));
686
+ }
687
+ if (graph_1.FunctionArgument.isNamed(arg)) {
688
+ names?.add(String(arg.name));
689
+ }
690
+ else if (value === undefined || termOfNode(value)?.kind !== 'constant') {
691
+ names = undefined;
692
+ }
693
+ }
694
+ return masked;
695
+ }
696
+ /**
697
+ * The formal a name the dataflow leaves unlinked as masked (see {@link GuardFacts.masks}) reads if there is no column of that name:
698
+ * a formal of that name the function never binds anew, whose value is what it was handed wherever the call is.
699
+ */
700
+ function maskedFormal(name, scope, state) {
701
+ if (scope.frameIsOpen || !isFormalName(name, scope) || [...scope.formals].some(([id, formal]) => formal === name && scope.drifting.has(id))) {
702
+ return undefined;
703
+ }
704
+ const rebinds = scope.vertex.subflow.graph.values().some(id => {
705
+ const vertex = state.graph.getVertex(id);
706
+ return vertex_1.DfgVertex.isVariableDefinition(vertex) && !scope.formals.has(id) && node_id_1.NodeId.recoverBareName(id, state.graph.idMap) === name;
707
+ });
708
+ return rebinds ? undefined : guard_term_1.GuardTerm.formal(name);
709
+ }
710
+ /** What the call asks of the sizes of the values it recycles, see {@link RRecycling}, for the values the caller can state. */
711
+ function recyclingRequirements(recycles, masks, bound, termOfNode, vertex, path, run) {
712
+ if (recycles.length === 0) {
713
+ return;
714
+ }
715
+ const { state } = run;
716
+ const masked = masks ? maskedNames(vertex, termOfNode, state.graph) : undefined;
717
+ /* with masking, only a literal or a formal no argument before it names is known to be what the caller has */
718
+ const stated = (node) => {
719
+ const term = termOfNode(node);
720
+ if (masked === undefined || term === undefined || term.kind === 'constant') {
721
+ return term;
722
+ }
723
+ const names = masked.get(node.info.id);
724
+ const formal = term.kind === 'free' && r_symbol_1.RSymbol.is(node) ? maskedFormal(term.name, run.scope, state) : term;
725
+ return formal?.kind === 'formal' && names !== undefined && !names.has(String(formal.name)) ? formal : undefined;
726
+ };
727
+ const single = (formal) => {
728
+ const nodes = formal === undefined ? [] : bound.get(formal) ?? [];
729
+ const term = nodes.length === 1 ? stated(nodes[0]) : undefined;
730
+ return nodes.length === 0 || (term?.kind === 'constant' && term.lexeme === 'NULL') ? 'none' : term;
731
+ };
732
+ const handsOnDots = match_args_1.MatchArgs.handsOnDots(vertex.args, state.graph);
733
+ for (const recycling of recycles) {
734
+ const to = single(recycling.to);
735
+ if (single(recycling.unless) !== 'none' || to === undefined) {
736
+ continue;
737
+ }
738
+ const terms = recycling.among.flatMap(formal => bound.get(formal) ?? []).map(stated);
739
+ /* the largest size is only known with every value */
740
+ if (recycling.rule === 'divides' && (handsOnDots || terms.includes(undefined))) {
741
+ continue;
742
+ }
743
+ const known = terms.filter(t => t !== undefined);
744
+ for (const condition of (0, guard_knowledge_1.recyclingConditions)(recycling, known, to === 'none' ? undefined : to, n => isDefined(n, state))) {
745
+ if (guard_term_1.GuardTerm.formalsOf(condition).size > 0) {
746
+ addClause(run, path, condition, vertex.id, { kind: 'implicit', message: recycling.message });
747
+ }
748
+ }
749
+ }
750
+ }
638
751
  /** What the methods of the base packages for the classes of R's own values ask on a call of a member of a group generic, but for classes the program has methods for. */
639
752
  function groupMethodRequirements(name, asks, bound, termOfNode, vertex, path, run) {
640
753
  const group = (0, group_generics_1.s3GroupGenericOf)(name);
@@ -772,7 +885,7 @@ function decidedMethods(dispatch, via, state) {
772
885
  decided ||= at.within === undefined;
773
886
  level = at.within;
774
887
  }
775
- return decided ? (df_helper_1.Dataflow.origin(state.graph, dispatch.id) ?? []).filter(o => o.type === 2 /* OriginType.FunctionCallOrigin */ && !ruledOut.has(o.id)).map(o => o.id) : undefined;
888
+ return decided ? (originsOf(state, dispatch.id) ?? []).filter(o => o.type === 2 /* OriginType.FunctionCallOrigin */ && !ruledOut.has(o.id)).map(o => o.id) : undefined;
776
889
  }
777
890
  /** The formals a function rebinds anywhere, which `NextMethod` hands on with the value they have by then. */
778
891
  function reboundFormals(scope, state) {
@@ -908,7 +1021,7 @@ function operatorMethods(name, vertex, path, run) {
908
1021
  /** `FUN(x)` for a formal `FUN`: a formal not holding a function makes R look for a function of the same name. */
909
1022
  function calledFormal(call, path, run) {
910
1023
  const { state, scope } = run;
911
- const reads = df_helper_1.Dataflow.origin(state.graph, call.info.id)?.filter(o => o.type === 0 /* OriginType.ReadVariableOrigin */) ?? [];
1024
+ const reads = originsOf(state, call.info.id)?.filter(o => o.type === 0 /* OriginType.ReadVariableOrigin */) ?? [];
912
1025
  const formal = reads.length === 1 ? scope.formals.get(reads[0].id) : undefined;
913
1026
  if (formal !== undefined && formal === identifier_1.Identifier.getName(call.functionName.content)) {
914
1027
  addClause(run, path, (0, guard_knowledge_1.callable)(guard_term_1.GuardTerm.formal(formal), n => isDefined(n, state), false), call.info.id, { kind: 'implicit' });
@@ -939,7 +1052,7 @@ function returnsValue(value, path, run) {
939
1052
  run.returned.push({ value, holds: path.map(step => step.holds) });
940
1053
  }
941
1054
  /** What only steers where the body goes on, which does nothing of its own: the effects are what it runs. */
942
- const Steering = [built_in_proc_name_1.BuiltInProcName.Stop, built_in_proc_name_1.BuiltInProcName.StopIfNot, built_in_proc_name_1.BuiltInProcName.Return, built_in_proc_name_1.BuiltInProcName.IfThenElse, built_in_proc_name_1.BuiltInProcName.ForLoop,
1055
+ exports.Steering = [built_in_proc_name_1.BuiltInProcName.Stop, built_in_proc_name_1.BuiltInProcName.StopIfNot, built_in_proc_name_1.BuiltInProcName.Return, built_in_proc_name_1.BuiltInProcName.IfThenElse, built_in_proc_name_1.BuiltInProcName.ForLoop,
943
1056
  built_in_proc_name_1.BuiltInProcName.WhileLoop, built_in_proc_name_1.BuiltInProcName.RepeatLoop, built_in_proc_name_1.BuiltInProcName.ExpressionList, built_in_proc_name_1.BuiltInProcName.Break, built_in_proc_name_1.BuiltInProcName.Switch];
944
1057
  /** The ways each node of every body of the graph is reached, worked out once per run, see {@link BranchPaths}. */
945
1058
  function branchPathsOf(state) {
@@ -1120,7 +1233,7 @@ function orderOf(run) {
1120
1233
  }
1121
1234
  const target = r_function_call_1.RFunctionCall.isNamed(nodeOf(id, state)) ? soleCallee(id, state) : undefined;
1122
1235
  const contract = target === undefined ? undefined : contractOf(target, state, viaCall(id, run));
1123
- if (contract !== undefined ? contract.effects : !Steering.some(proc => runsBuiltIn(vertex, proc)) && !onlyComputes(id, vertex, state)) {
1236
+ if (contract !== undefined ? contract.effects : !exports.Steering.some(proc => runsBuiltIn(vertex, proc)) && !onlyComputes(id, vertex, state)) {
1124
1237
  effects.add(id);
1125
1238
  }
1126
1239
  if (contract?.opens) {
@@ -1333,6 +1446,7 @@ function callRequirements(node, vertex, run) {
1333
1446
  }
1334
1447
  operatorMethods(name, vertex, path, run);
1335
1448
  builtInRequirements(name, vertex, path, run);
1449
+ nativeRequirements(vertex, path, run);
1336
1450
  if (name === 'get') {
1337
1451
  getRequirement(node, path, run);
1338
1452
  }
@@ -1449,11 +1563,13 @@ function contractOf(id, state, via = []) {
1449
1563
  state.contracts.set(key, contract);
1450
1564
  return contract;
1451
1565
  }
1452
- function stateOf(graph, { ctx }) {
1566
+ function stateOf(graph, { ctx, natives = ctx === undefined ? [] : native_routines_1.NativeRoutines.ofProject(ctx) }) {
1453
1567
  const bindings = df_helper_1.Dataflow.definitionsByName(graph);
1568
+ const info = (0, query_fn_props_1.builtInLookup)(ctx);
1569
+ const routineOf = native_routines_1.NativeRoutines.lookup(natives, graph, info, ctx);
1454
1570
  const bindsFunction = (0, defaultmap_1.memoize)((name) => bindings.get(name).some(id => (0, higher_order_function_1.definitionsBehind)(id, graph).size > 0));
1455
1571
  const methodClasses = (0, defaultmap_1.memoize)((generic) => [...bindings.keys()].flatMap(fn => fn.startsWith(`${generic}.`) && bindsFunction(fn) ? [fn.slice(generic.length + 1)] : []));
1456
- return { graph, info: (0, query_fn_props_1.builtInLookup)(ctx), facts: (0, guard_knowledge_1.guardFactsOf)(ctx), contracts: new Map(), terms: new Map(), bindings, bindsFunction, methodClasses, depth: 0, ctx: ctx ?? (0, flowr_analyzer_context_1.contextFromInput)('') };
1572
+ return { graph, info, facts: (0, guard_knowledge_1.guardFactsOf)(ctx), contracts: new Map(), terms: new Map(), bindings, bindsFunction, methodClasses, depth: 0, ctx: ctx ?? (0, flowr_analyzer_context_1.contextFromInput)(''), routineOf };
1457
1573
  }
1458
1574
  /** The claims with the cases of each formal. */
1459
1575
  function withCases(claims, cases) {
@@ -110,6 +110,8 @@ export declare function returnedFormalOf(this: void, returned: readonly Returned
110
110
  * @param group - the group generic the failing call dispatches through, like `Math`
111
111
  */
112
112
  export declare function readingOf(this: void, condition: GuardTerm, facts: GuardFactsLookup, group?: BrandedIdentifier): string | undefined;
113
+ /** The claim without a type that only rules out what is no data (`typeof(x) not in {function, environment, ...}`), which says nothing concrete of the formal. */
114
+ export declare function concreteClaim(this: void, claim: FormalClaim): FormalClaim;
113
115
  /**
114
116
  * Reads a claim on `formal` as conditions written the way R would test them, all of which hold, like
115
117
  * `typeof(m) in {integer, double}`, `length(m) == 1`, and `m >= 0`.