pineforge-codegen 1.6.0__py3-none-any.whl → 1.6.1__py3-none-any.whl

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.
@@ -173,6 +173,13 @@ class TypeHelper:
173
173
  return TypeSpec.primitive("bool")
174
174
  if isinstance(value, StringLiteral):
175
175
  return TypeSpec.primitive("string")
176
+ if isinstance(value, UnaryOp):
177
+ if value.op == "not":
178
+ return TypeSpec.primitive("bool")
179
+ operand = self._array_from_element_spec(value.operand)
180
+ if operand is not None and operand.kind == "primitive" and operand.name in ("int", "int64", "float"):
181
+ return operand
182
+ return None
176
183
  if isinstance(value, BinOp):
177
184
  left = self._array_from_element_spec(value.left)
178
185
  right = self._array_from_element_spec(value.right)
@@ -507,7 +514,20 @@ class TypeHelper:
507
514
  elem = self._type_spec_from_hint(targs[0]) or TypeSpec.udt(targs[0])
508
515
  return TypeSpec.array(elem)
509
516
  if func == "from" and value.args:
510
- first_spec = self._array_from_element_spec(value.args[0])
517
+ elem_specs = [
518
+ self._array_from_element_spec(arg)
519
+ or self._pine_type_to_spec(self._visit(arg))
520
+ for arg in value.args
521
+ ]
522
+ if any(
523
+ s is not None and s.kind == "primitive" and s.name == "float"
524
+ for s in elem_specs
525
+ ) and all(
526
+ s is not None and s.kind == "primitive" and s.name in ("int", "int64", "float")
527
+ for s in elem_specs
528
+ ):
529
+ return TypeSpec.array(TypeSpec.primitive("float"))
530
+ first_spec = elem_specs[0]
511
531
  if first_spec is not None:
512
532
  return TypeSpec.array(first_spec)
513
533
  first = self._visit(value.args[0])
@@ -1373,6 +1373,13 @@ class TypeInferer:
1373
1373
  slot populated; recover that exact scalar here rather than silently
1374
1374
  defaulting ``array.from(string_udf())`` to ``std::vector<double>``.
1375
1375
  """
1376
+ if isinstance(node, UnaryOp):
1377
+ if node.op == "not":
1378
+ return TypeSpec.primitive("bool")
1379
+ operand = self._array_from_element_spec(node.operand)
1380
+ if operand is not None and operand.kind == "primitive" and operand.name in ("int", "int64", "float"):
1381
+ return operand
1382
+ return None
1376
1383
  if isinstance(node, BinOp):
1377
1384
  left = self._array_from_element_spec(node.left)
1378
1385
  right = self._array_from_element_spec(node.right)
@@ -1527,12 +1534,30 @@ class TypeInferer:
1527
1534
  node.name
1528
1535
  )
1529
1536
  if found_udt_binding:
1530
- return (
1531
- TypeSpec.udt(exact_udt)
1532
- if exact_udt is not None
1533
- else None
1534
- )
1537
+ if exact_udt is not None:
1538
+ return TypeSpec.udt(exact_udt)
1539
+ local_cpp = getattr(self, "_current_func_local_types", {}).get(node.name)
1540
+ local_prim = {
1541
+ "int": "int",
1542
+ "int64_t": "int64",
1543
+ "double": "float",
1544
+ "bool": "bool",
1545
+ "std::string": "string",
1546
+ }.get(local_cpp)
1547
+ if local_prim is not None:
1548
+ return TypeSpec.primitive(local_prim)
1549
+ return None
1535
1550
  if self._collection_name_is_lexically_shadowed(node.name):
1551
+ local_cpp = getattr(self, "_current_func_local_types", {}).get(node.name)
1552
+ local_prim = {
1553
+ "int": "int",
1554
+ "int64_t": "int64",
1555
+ "double": "float",
1556
+ "bool": "bool",
1557
+ "std::string": "string",
1558
+ }.get(local_cpp)
1559
+ if local_prim is not None:
1560
+ return TypeSpec.primitive(local_prim)
1536
1561
  return None
1537
1562
  sym = self.ctx.symbols.resolve(node.name)
1538
1563
  if sym is not None:
@@ -1762,8 +1787,28 @@ class TypeInferer:
1762
1787
  if targs:
1763
1788
  return TypeSpec.array(self._type_spec_from_hint_name(targs[0]) or TypeSpec.udt(targs[0]))
1764
1789
  if func_name == "from" and node.args:
1790
+ elem_specs = [
1791
+ self._array_from_element_spec(arg)
1792
+ for arg in node.args
1793
+ ]
1794
+ if any(
1795
+ s is not None and s.kind == "primitive" and s.name == "float"
1796
+ for s in elem_specs
1797
+ ) and all(
1798
+ (s is None or (s.kind == "primitive" and s.name in ("int", "int64", "float")))
1799
+ for s in elem_specs
1800
+ ):
1801
+ return TypeSpec.array(TypeSpec.primitive("float"))
1802
+ if any(
1803
+ s is not None and s.kind == "primitive" and s.name == "int64"
1804
+ for s in elem_specs
1805
+ ) and all(
1806
+ s is not None and s.kind == "primitive" and s.name in ("int", "int64")
1807
+ for s in elem_specs
1808
+ ):
1809
+ return TypeSpec.array(TypeSpec.primitive("int64"))
1765
1810
  return TypeSpec.array(
1766
- self._array_from_element_spec(node.args[0])
1811
+ elem_specs[0]
1767
1812
  or TypeSpec.primitive("float")
1768
1813
  )
1769
1814
  return TypeSpec.array(TypeSpec.primitive("float"))
@@ -2202,6 +2202,10 @@ class CallVisitor:
2202
2202
  # ``color[] cs = array.from(c1, c2)`` declares
2203
2203
  # ``std::vector<int64_t>`` and must construct one.
2204
2204
  declared = self._collection_spec_for_name(target)
2205
+ if declared is None and getattr(self, "_active_func_name", None) is not None:
2206
+ declared = self._callable_var_collection_spec(
2207
+ target, self._active_func_name
2208
+ )
2205
2209
  if (declared is not None and declared.kind == "array"
2206
2210
  and declared.element is not None
2207
2211
  and declared.element.kind == "primitive"
@@ -2408,13 +2412,16 @@ class CallVisitor:
2408
2412
  and func_name in TIME_FIELD_EXPRS
2409
2413
  and (node.args or node.kwargs)
2410
2414
  ):
2411
- params = sigs.get_param_names(None, func_name)
2412
- arg_nodes = _merge_kwargs(node.args, node.kwargs, params, lambda a: a)
2413
- args = [self._visit_expr(a) for a in arg_nodes]
2414
- ts_node = arg_nodes[0] if arg_nodes else None
2415
- ts_arg = args[0] if args else "current_bar_.timestamp"
2415
+ bound = self._resolve_func_args(node, func_name)
2416
+ ts_node = bound.get("time")
2417
+ ts_arg = (
2418
+ self._visit_expr(ts_node)
2419
+ if ts_node is not None
2420
+ else "current_bar_.timestamp"
2421
+ )
2416
2422
  ts_arg = self._coerce_int_slot(ts_arg, ts_node, "int64_t")
2417
- tz_arg = args[1] if len(args) > 1 else None
2423
+ tz_node = bound.get("timezone")
2424
+ tz_arg = self._visit_expr(tz_node) if tz_node is not None else None
2418
2425
  field_expr = TIME_FIELD_EXPRS[func_name]
2419
2426
  if tz_arg is None:
2420
2427
  # 1-arg form — fall back to ``syminfo.timezone`` per TV
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pineforge-codegen
3
- Version: 1.6.0
3
+ Version: 1.6.1
4
4
  Summary: PineScript v6 to C++ transpiler that targets the pineforge-engine runtime.
5
5
  Project-URL: Homepage, https://github.com/pineforge-4pass/pineforge-codegen-oss
6
6
  Project-URL: Issues, https://github.com/pineforge-4pass/pineforge-codegen-oss/issues
@@ -327,7 +327,7 @@ for the changes in each release from 1.0.0 on and the release-note policy.
327
327
  ## Releases and this README
328
328
 
329
329
  <!-- Release lane: before a release is tagged, add it to the Engine pairing
330
- table and update every line that names `1.6.0` or `v1.6.0` as the current
330
+ table and update every line that names `1.6.1` or `v1.6.1` as the current
331
331
  release or pair (this section's version and date, the baseline paragraph at
332
332
  the top, the engine `src/source/` link, the `@pf-trace` note, the clone
333
333
  command and its example output, "This section describes …", the timing note)
@@ -337,7 +337,7 @@ hosted-server line name no version. -->
337
337
 
338
338
  This README ships with each release as its package description on PyPI
339
339
  (`pineforge-codegen`); releases from 0.7.0 on are also on npm as
340
- `@pineforge/codegen-pyodide`. It describes 1.6.0 (2026-10-17)
340
+ `@pineforge/codegen-pyodide`. It describes 1.6.1 (2026-10-18)
341
341
  and what changed since 0.10.4. The 1.4.0 release's behavior was validated
342
342
  before tagging on codegen `bfc4ddce` with engine `b3192bfc`, excluding engine
343
343
  request #356; those validation builds reported `1.3.0`. Historical measurements
@@ -410,8 +410,8 @@ It does **not** own execution semantics. Order lifecycle, bracket legs,
410
410
  fill-price and slippage rules, `process_orders_on_close` / `calc_on_order_fills`,
411
411
  margin revival and trail/stop behaviour — everything TradingView parity depends
412
412
  on at run time — live in the engine's source-adapter runtime
413
- ([`src/source/`](https://github.com/pineforge-4pass/pineforge-engine/tree/v1.6.0/src/source)
414
- in engine `v1.6.0`), which maps them onto the engine's Pine-agnostic kernel.
413
+ ([`src/source/`](https://github.com/pineforge-4pass/pineforge-engine/tree/v1.6.1/src/source)
414
+ in engine `v1.6.1`), which maps them onto the engine's Pine-agnostic kernel.
415
415
  See
416
416
  the engine's [architecture notes](https://github.com/pineforge-4pass/pineforge-engine#architecture-kernel-vs-parity).
417
417
 
@@ -826,6 +826,7 @@ Generated C++ compiles only against the engine it was generated for:
826
826
  | 1.4.0 (PyPI, 2026-10-08) | `v1.4.0` | Adds paired coded failures, corrected input manifests and collection lowering. C ABI 4 does not authorize a mixed pair. Regenerate and relink. |
827
827
  | 1.5.0 (PyPI, 2026-10-12) | `v1.5.0` | Adds the nonfatal `note` diagnostic severity and diagnostic `user_message` templates. Regenerate and relink. |
828
828
  | 1.6.0 (PyPI, 2026-10-17) | `v1.6.0` | Emitted C++ and the Python, JSON and diagnostic contract are unchanged since 1.5.0; test and comment cleanup only (#200, #201, #202). Regenerate and relink. |
829
+ | 1.6.1 (PyPI, 2026-10-18) | `v1.6.1` | Fixes emitted C++ for calendar built-ins called with `timezone=` and no positional `time`, and for `var` array initializers over unary-signed or mixed numeric constants (#205); the Python, JSON and diagnostic contract are unchanged since 1.6.0. Regenerate and relink. |
829
830
  | Later `X.Y.Z` releases | `vX.Y.Z` of the same version | See below. |
830
831
 
831
832
  On the 0.x line the engine and codegen versions are independent, and the
@@ -851,8 +852,8 @@ Pine as `strategy.pine`, write `strategy.generated.cpp` with the
851
852
  [file example](#transpile-a-file-to-a-cpp) above, then from the same directory:
852
853
 
853
854
  ```bash
854
- # 1.6.0 pairs with engine v1.6.0. For 0.10.4 use v0.13.1.
855
- git clone --branch v1.6.0 https://github.com/pineforge-4pass/pineforge-engine.git
855
+ # 1.6.1 pairs with engine v1.6.1. For 0.10.4 use v0.13.1.
856
+ git clone --branch v1.6.1 https://github.com/pineforge-4pass/pineforge-engine.git
856
857
  cd pineforge-engine
857
858
  cp ../strategy.generated.cpp tutorial/macd/generated.cpp # the tutorial's strategy slot
858
859
  bash tutorial/run.sh # needs cmake, a C++17 compiler and python3
@@ -978,7 +979,7 @@ quote. The commercial-license store (coming soon) will take orders online.
978
979
 
979
980
  ## Explicit Pine execution attachment
980
981
 
981
- This section describes the 1.6.0 and engine `v1.6.0` pair. The Pine execution adapter is
982
+ This section describes the 1.6.1 and engine `v1.6.1` pair. The Pine execution adapter is
982
983
  the engine's full Pine execution runtime (`PineExecutionAdapter` and
983
984
  `PineStrategyHost` in the engine's `src/source/`): order lifecycle, bracket
984
985
  legs, fill-price and slippage rules, POOC / `calc_on_order_fills`, margin
@@ -1001,9 +1002,9 @@ Regenerate old generated C++ before using a new engine for Pine execution. C++
1001
1002
  generated before the source-layer cut
1002
1003
  ([#129](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/129)),
1003
1004
  0.10.4's included, derives from `BacktestEngine` and does not compile against
1004
- engine `v1.6.0`; old cap-only C++ does not attach the priority rule, and
1005
+ engine `v1.6.1`; old cap-only C++ does not attach the priority rule, and
1005
1006
  metadata cannot silently restore it. Rebuild all modules against the
1006
- new matching C++ layout (`engine_script_run_v19` in engine `v1.6.0`). Retaining
1007
+ new matching C++ layout (`engine_script_run_v19` in engine `v1.6.1`). Retaining
1007
1008
  that epoch does not promise equal fingerprints, state hashes or trades across
1008
1009
  releases. The extraction preserves Pine policy
1009
1010
  under explicit attachment; it does not implement the generic native
@@ -35,7 +35,7 @@ pineforge_codegen/analyzer/call_handlers.py,sha256=tkAlIWvuIIWyPX7crFpI_ch2UQe1Q
35
35
  pineforge_codegen/analyzer/contracts.py,sha256=L0-bpMAp7685mW4L03IN8a3T13_JskpMHAetUZf1-6E,23547
36
36
  pineforge_codegen/analyzer/diagnostics.py,sha256=5tJZCEeqPbWbYh658iCK5AK43KhBWJUTWYQapH6U_FU,7183
37
37
  pineforge_codegen/analyzer/tables.py,sha256=zBhk2bw1UhR_eHTWqgs-ojY5bKCTcaieMsQer4oJKW8,10023
38
- pineforge_codegen/analyzer/types.py,sha256=h0mo__4z8zh5meCn5iZeOP92hg5BQDDAJpW1FRcH2nk,58386
38
+ pineforge_codegen/analyzer/types.py,sha256=r9aMoeL0N_Yubc1DyLjvrvZUFZ7W8zZ_TyST8HxUmFI,59380
39
39
  pineforge_codegen/codegen/__init__.py,sha256=GU1iNcDHG0wbMBz4_rFffEZAx3W6Qh7vjZPbMbP56Cs,2336
40
40
  pineforge_codegen/codegen/base.py,sha256=tHU8wC7rHgrrl3LbWOTmLUSHojKt2F4NwW7xbKpyFEE,314554
41
41
  pineforge_codegen/codegen/capabilities.py,sha256=WpzpQiRg-aaAxByl5rcm8tKXyB1Kcz9mWEx6K9QDxuQ,17653
@@ -55,11 +55,11 @@ pineforge_codegen/codegen/session_market.py,sha256=-urGaWozZ0k4uNzZ5lPB2fqftpJrf
55
55
  pineforge_codegen/codegen/ta.py,sha256=w9nvIqbbLCOL8jLnW7z9vMlu8RqYyF8nTtrQoRKnwcA,106771
56
56
  pineforge_codegen/codegen/tables.py,sha256=KiGrUc_j8HHEwb8kUbczl9KHFnyRS3B6PRTmlN6mc1w,65492
57
57
  pineforge_codegen/codegen/tv_number_format.py,sha256=SZ70zOmMD9vC1ko0WQnt6X0q7PJ_-jT93N7ZtquwPLE,11637
58
- pineforge_codegen/codegen/types.py,sha256=6jqFekrLxahAyhQ6rFuzQKhzarKArsDISJDuBsJWwVc,210048
59
- pineforge_codegen/codegen/visit_call.py,sha256=xP_pBkFU8EPytG0Fi94-lbackJSSC3wOQ_H00n9nzlE,194990
58
+ pineforge_codegen/codegen/types.py,sha256=lC-HVTYE-knXHcJSzVRTSMnl4o_1ZaCtKVmRHKt93Jc,212252
59
+ pineforge_codegen/codegen/visit_call.py,sha256=eXR_8iPfL40egxcE39myBGgMwlBtOEJczU_oEnpJQQo,195250
60
60
  pineforge_codegen/codegen/visit_expr.py,sha256=nLFf4ErbvEAKJZYjeQUiDyh_H3_8ICEsk_h6VholoG4,111358
61
61
  pineforge_codegen/codegen/visit_stmt.py,sha256=czS0z7QuskBeCjpy9i2srg2Z8nR0VdXqho3-AVIeZ1U,118214
62
- pineforge_codegen-1.6.0.dist-info/METADATA,sha256=3IMQ-aJAYXK3sEQe3qwDGGLVIZMgWsIm9EPQrelCB7A,54240
63
- pineforge_codegen-1.6.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
64
- pineforge_codegen-1.6.0.dist-info/licenses/LICENSE,sha256=jOb1NwvEgyuqWgdxUE6jTtQGRZqCz261Ws0d_LRztvw,11164
65
- pineforge_codegen-1.6.0.dist-info/RECORD,,
62
+ pineforge_codegen-1.6.1.dist-info/METADATA,sha256=OYQ9pTd0oU-NxHnMmovug8_5VFxpb-_y_uS7xJLz6gs,54550
63
+ pineforge_codegen-1.6.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
64
+ pineforge_codegen-1.6.1.dist-info/licenses/LICENSE,sha256=jOb1NwvEgyuqWgdxUE6jTtQGRZqCz261Ws0d_LRztvw,11164
65
+ pineforge_codegen-1.6.1.dist-info/RECORD,,