@almadar/evaluator 2.30.0 → 2.31.0
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.
- package/dist/{index-BjtK8dP9.d.ts → index-rPqsFqVO.d.ts} +11 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/operators/index.d.ts +1 -1
- package/dist/operators/index.js +3 -2
- package/dist/operators/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -268,6 +268,17 @@ type Evaluator$2 = (expr: SExpr, ctx: EvaluationContext) => unknown;
|
|
|
268
268
|
* Supports two formats:
|
|
269
269
|
* - Array of pairs: ["let", [["x", 10], ["y", 20]], body]
|
|
270
270
|
* - Object style: ["let", {"x": 10, "y": 20}, body]
|
|
271
|
+
*
|
|
272
|
+
* Sequential (`let*`) semantics: each binding's value expression can
|
|
273
|
+
* reference any EARLIER binding in the same `let` via `@<name>` — matches
|
|
274
|
+
* `@almadar/runtime`'s `EffectExecutor` `let` case (its own, independent
|
|
275
|
+
* implementation, which already threads bindings this way) and how `.lolo`
|
|
276
|
+
* is authored in practice: multi-step chains where a later step's formula
|
|
277
|
+
* builds on an earlier one (e.g. std-evade-chase's `chase` tick computing
|
|
278
|
+
* `nc2x` from `nc1x`). Evaluating every binding against the original,
|
|
279
|
+
* unmodified `ctx` (the prior behavior here) left every cross-binding
|
|
280
|
+
* reference unresolved (`undefined`), silently corrupting any `let` with
|
|
281
|
+
* dependent bindings.
|
|
271
282
|
*/
|
|
272
283
|
declare function evalLet(args: SExpr[], evaluate: Evaluator$2, ctx: EvaluationContext): unknown;
|
|
273
284
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SExpr } from '@almadar/core';
|
|
2
2
|
export { CORE_BINDINGS, CoreBinding, Expression, ExpressionSchema, ParsedBinding, SExpr, SExprAtom, SExprSchema, collectBindings, getArgs, getOperator, isBinding, isSExpr, isSExprAtom, isSExprCall, isValidBinding, parseBinding, sexpr, walkSExpr } from '@almadar/core';
|
|
3
|
-
import { E as EvaluationContext } from './index-
|
|
4
|
-
export { U as UserContext, c as createChildContext, a as createEffectContext, b as createMinimalContext, e as evalAbs, d as evalAdd, f as evalAnd, g as evalAtomic, h as evalCallService, i as evalCeil, j as evalClamp, k as evalConcat, l as evalCount, m as evalDecrement, n as evalDeref, o as evalDespawn, p as evalDivide, q as evalDo, r as evalEmit, s as evalEmpty, t as evalEqual, u as evalFilter, v as evalFind, w as evalFirst, x as evalFloor, y as evalFn, z as evalGreaterThan, A as evalGreaterThanOrEqual, B as evalIf, C as evalIncludes, D as evalIncrement, F as evalLast, G as evalLessThan, H as evalLessThanOrEqual, I as evalLet, J as evalList, K as evalMap, L as evalMatches, M as evalMax, N as evalMin, O as evalModulo, P as evalMultiply, Q as evalNavigate, R as evalNot, S as evalNotEqual, T as evalNotify, V as evalNth, W as evalOr, X as evalPersist, Y as evalRef, Z as evalRenderUI, _ as evalRound, $ as evalSet, a0 as evalSetDynamic, a1 as evalSpawn, a2 as evalSubtract, a3 as evalSum, a4 as evalSwap, a5 as evalWatch, a6 as evalWhen, a7 as resolveBinding } from './index-
|
|
3
|
+
import { E as EvaluationContext } from './index-rPqsFqVO.js';
|
|
4
|
+
export { U as UserContext, c as createChildContext, a as createEffectContext, b as createMinimalContext, e as evalAbs, d as evalAdd, f as evalAnd, g as evalAtomic, h as evalCallService, i as evalCeil, j as evalClamp, k as evalConcat, l as evalCount, m as evalDecrement, n as evalDeref, o as evalDespawn, p as evalDivide, q as evalDo, r as evalEmit, s as evalEmpty, t as evalEqual, u as evalFilter, v as evalFind, w as evalFirst, x as evalFloor, y as evalFn, z as evalGreaterThan, A as evalGreaterThanOrEqual, B as evalIf, C as evalIncludes, D as evalIncrement, F as evalLast, G as evalLessThan, H as evalLessThanOrEqual, I as evalLet, J as evalList, K as evalMap, L as evalMatches, M as evalMax, N as evalMin, O as evalModulo, P as evalMultiply, Q as evalNavigate, R as evalNot, S as evalNotEqual, T as evalNotify, V as evalNth, W as evalOr, X as evalPersist, Y as evalRef, Z as evalRenderUI, _ as evalRound, $ as evalSet, a0 as evalSetDynamic, a1 as evalSpawn, a2 as evalSubtract, a3 as evalSum, a4 as evalSwap, a5 as evalWatch, a6 as evalWhen, a7 as resolveBinding } from './index-rPqsFqVO.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* S-Expression Evaluator
|
package/dist/index.js
CHANGED
|
@@ -276,11 +276,12 @@ function evalLet(args, evaluate2, ctx) {
|
|
|
276
276
|
const body = args[1];
|
|
277
277
|
const bindingPairs = Array.isArray(rawBindings) ? rawBindings.map((b) => [b[0], b[1]]) : Object.entries(rawBindings);
|
|
278
278
|
const locals = /* @__PURE__ */ new Map();
|
|
279
|
+
let childCtx = ctx;
|
|
279
280
|
for (const [name, valueExpr] of bindingPairs) {
|
|
280
|
-
const value = evaluate2(valueExpr,
|
|
281
|
+
const value = evaluate2(valueExpr, childCtx);
|
|
281
282
|
locals.set(name, value);
|
|
283
|
+
childCtx = createChildContext(ctx, locals);
|
|
282
284
|
}
|
|
283
|
-
const childCtx = createChildContext(ctx, locals);
|
|
284
285
|
return evaluate2(body, childCtx);
|
|
285
286
|
}
|
|
286
287
|
function evalDo(args, evaluate2, ctx) {
|
|
@@ -972,6 +973,8 @@ function evalWithItem(expr, evaluate2, ctx, item, index) {
|
|
|
972
973
|
let result = evaluate2(expr, childCtx);
|
|
973
974
|
if (isSExpr(result)) {
|
|
974
975
|
result = evalWithItem(result, evaluate2, childCtx, item, index);
|
|
976
|
+
} else if (typeof result === "function") {
|
|
977
|
+
result = result(item, evaluate2, childCtx);
|
|
975
978
|
}
|
|
976
979
|
return result;
|
|
977
980
|
}
|