@pineforge/codegen-pyodide 0.7.1 → 0.7.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pineforge/codegen-pyodide",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Gate-validated Pyodide payload for the PineScript v6 -> C++ transpiler: archive (run in Pyodide), unpacked source, introspected tables, and release metadata.",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
@@ -185,19 +185,31 @@ class CodeGen(CallVisitor, ExprVisitor, StmtVisitor, TopLevelEmitter, SecurityEm
185
185
  # This ensures sub-function series vars get cloned for the parent's call sites.
186
186
  func_var_originals: dict[str, list[str]] = {} # func_name -> list of original var names
187
187
 
188
- # First, collect all function-scoped series vars (union across all functions)
189
- all_func_scoped_series: set[str] = set()
188
+ # First, collect all function-scoped series vars (union across all functions).
189
+ # Use an ordered, de-duplicated list (NOT a set): set iteration order is
190
+ # PYTHONHASHSEED-randomized, and this order reaches emitted C++ member
191
+ # declarations via ``orig_names`` -> ``func_var_originals`` ->
192
+ # ``_func_cs_var_remap``. ``ctx.func_series_vars`` is a dict whose VALUES
193
+ # are themselves sets (analyzer stores ``dict[str, set]``), so we must
194
+ # iterate each value in ``sorted`` order to be hash-seed independent.
195
+ all_func_scoped_series: list[str] = []
190
196
  for svars in ctx.func_series_vars.values():
191
- all_func_scoped_series.update(svars)
192
- # Also include function-scoped var_members
193
- all_func_scoped_vars: set[str] = set()
197
+ for sv in sorted(svars):
198
+ if sv not in all_func_scoped_series:
199
+ all_func_scoped_series.append(sv)
200
+ # Also include function-scoped var_members (same ordered-list rationale).
201
+ # ``ctx.func_var_members`` values are lists (already insertion-ordered).
202
+ all_func_scoped_vars: list[str] = []
194
203
  for vlist in ctx.func_var_members.values():
195
204
  for n, _, _ in vlist:
196
- all_func_scoped_vars.add(n)
205
+ if n not in all_func_scoped_vars:
206
+ all_func_scoped_vars.append(n)
197
207
 
198
208
  # For each function with call-site cloning (has TA ranges or is called multiple times),
199
- # include ALL function-scoped series/var vars that could be used in its body
200
- for fname in set(ctx.func_call_site_counts.keys()):
209
+ # include ALL function-scoped series/var vars that could be used in its body.
210
+ # Iterate the dict directly (insertion-ordered) rather than ``set(...keys())``,
211
+ # which would randomize the order of emitted clones across hash seeds.
212
+ for fname in ctx.func_call_site_counts:
201
213
  total_cs = ctx.func_call_site_counts[fname]
202
214
  if total_cs <= 1:
203
215
  continue # No cloning needed for single-call-site functions
@@ -207,9 +219,9 @@ class CodeGen(CallVisitor, ExprVisitor, StmtVisitor, TopLevelEmitter, SecurityEm
207
219
  for n, _, _ in ctx.func_var_members[fname]:
208
220
  if n not in orig_names:
209
221
  orig_names.append(n)
210
- # Include function's own series vars
222
+ # Include function's own series vars (set -> sorted for determinism)
211
223
  if fname in ctx.func_series_vars:
212
- for sv in ctx.func_series_vars[fname]:
224
+ for sv in sorted(ctx.func_series_vars[fname]):
213
225
  if sv not in orig_names:
214
226
  orig_names.append(sv)
215
227
  # Include series vars from sub-functions (they share the same class members)
Binary file
package/release.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
- "codegen": "0.7.1",
2
+ "codegen": "0.7.2",
3
3
  "pyodide": "314.0.0",
4
4
  "python": "3.14.0",
5
5
  "emscripten": "emscripten_5_0_3",
6
- "sha256": "51be5f3cdecf1ce87685bdd570d60f8c15e5fa0c4ce3b2e9e2594eefe89babd0"
6
+ "sha256": "343bba428db5fc925dc0ba459fed888bdf974496333b7d74c27f695afaca3e23"
7
7
  }
package/tables.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "CODEGEN_VERSION": "0.7.1",
2
+ "CODEGEN_VERSION": "0.7.2",
3
3
  "TA_CLASS_MAP_KEYS": [
4
4
  "sma",
5
5
  "ema",
Binary file