pineforge-codegen 1.6.0__tar.gz → 1.6.1rc1__tar.gz

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 (74) hide show
  1. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/CHANGELOG.md +48 -0
  2. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/PKG-INFO +1 -1
  3. pineforge_codegen-1.6.1rc1/VERSION +1 -0
  4. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/analyzer/types.py +21 -1
  5. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/types.py +51 -6
  6. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/visit_call.py +13 -6
  7. pineforge_codegen-1.6.0/VERSION +0 -1
  8. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/.gitignore +0 -0
  9. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/CONTRIBUTING.md +0 -0
  10. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/LEGAL.md +0 -0
  11. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/LICENSE +0 -0
  12. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/README.md +0 -0
  13. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/docs/PUBLIC_CONTRACT.md +0 -0
  14. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/docs/codegen-coverage-gaps.md +0 -0
  15. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/docs/pine-cap-activation.md +0 -0
  16. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/__init__.py +0 -0
  17. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/analyzer/__init__.py +0 -0
  18. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/analyzer/base.py +0 -0
  19. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/analyzer/call_handlers.py +0 -0
  20. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/analyzer/contracts.py +0 -0
  21. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/analyzer/diagnostics.py +0 -0
  22. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/analyzer/tables.py +0 -0
  23. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/ast_nodes.py +0 -0
  24. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/block_locals.py +0 -0
  25. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/builtin_keywords.py +0 -0
  26. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/__init__.py +0 -0
  27. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/base.py +0 -0
  28. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/capabilities.py +0 -0
  29. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/checked_settings.py +0 -0
  30. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/collection_history.py +0 -0
  31. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/constant_fold.py +0 -0
  32. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/drawing.py +0 -0
  33. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/emit_top.py +0 -0
  34. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/helpers.py +0 -0
  35. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/helpers_syminfo.py +0 -0
  36. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/host_members.py +0 -0
  37. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/input.py +0 -0
  38. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/order_shapes.py +0 -0
  39. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/run_stops.py +0 -0
  40. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/security.py +0 -0
  41. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/session_market.py +0 -0
  42. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/ta.py +0 -0
  43. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/tables.py +0 -0
  44. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/tv_number_format.py +0 -0
  45. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/visit_expr.py +0 -0
  46. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/codegen/visit_stmt.py +0 -0
  47. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/collection_history.py +0 -0
  48. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/diagnostic_codes.py +0 -0
  49. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/diagnostics_catalog.json +0 -0
  50. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/errors.py +0 -0
  51. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/external_requests.py +0 -0
  52. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/finite_ta_length.py +0 -0
  53. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/lexer.py +0 -0
  54. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/library_inline.py +0 -0
  55. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/library_modules.py +0 -0
  56. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/library_v5.py +0 -0
  57. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/limits.py +0 -0
  58. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/matrix_overloads.py +0 -0
  59. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/method_binding.py +0 -0
  60. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/parser.py +0 -0
  61. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/pine_libraries.py +0 -0
  62. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/pine_spelling.py +0 -0
  63. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/pragmas.py +0 -0
  64. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/request_discovery.py +0 -0
  65. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/request_feed_inventory.py +0 -0
  66. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/security_contexts.py +0 -0
  67. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/session_reads.py +0 -0
  68. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/signatures.py +0 -0
  69. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/support_checker.py +0 -0
  70. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/symbols.py +0 -0
  71. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/timeframe_token_cli.py +0 -0
  72. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/tokens.py +0 -0
  73. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pineforge_codegen/tv_input_choices.py +0 -0
  74. {pineforge_codegen-1.6.0 → pineforge_codegen-1.6.1rc1}/pyproject.toml +0 -0
@@ -20,6 +20,54 @@ supported as exact pairs; on the 0.x line they are independent. See the
20
20
  the release commit. A prerelease note describes changes since the preceding
21
21
  prerelease or stable tag; the final stable note consolidates the series.
22
22
 
23
+ ## 1.6.1 — Unreleased
24
+
25
+ The planned number of the next patch release of the exact engine/codegen pair;
26
+ it stays **Unreleased** until its tag exists, and the package version is
27
+ unchanged. Codegen 1.6.1 is planned as the exact engine/codegen pair with
28
+ engine `v1.6.1`; the prerelease `1.6.1-rc.1` pairs with engine
29
+ `v1.6.1-rc.1`. This entry records what changed in this repository since 1.6.0,
30
+ and nothing else: the engine pairing, the date and the final text are set when
31
+ the release is prepared.
32
+
33
+ ### Compatibility and migration
34
+
35
+ - No Python, JSON, diagnostic or C ABI contract changes.
36
+ - Strategies that previously failed native C++ compilation when calling a
37
+ calendar built-in (`hour`, `minute`, `second`, `dayofmonth`, `dayofweek`,
38
+ `month`, `year`, `weekofyear`) with `timezone=` and no positional `time`
39
+ argument, or when initializing a `var` array with `array.from(...)` over
40
+ unary-signed or mixed numeric constants, now emit matching C++ types and
41
+ compile cleanly.
42
+ - A pair change requires regenerated C++ and relinked strategy libraries against
43
+ the paired engine release's headers and `libpineforge.a` (README
44
+ [Engine pairing](README.md#engine-pairing)).
45
+
46
+ ### Changes since 1.6.0
47
+
48
+ - Bind the omitted `time` argument of calendar built-ins (`hour`, `minute`,
49
+ `second`, `dayofmonth`, `dayofweek`, `month`, `year`, `weekofyear`) to the
50
+ active bar's timestamp (`current_bar_.timestamp` on the chart, `bar.timestamp`
51
+ inside `request.security`) when called with a `timezone=` keyword argument
52
+ only
53
+ ([#205](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/205)).
54
+ - Infer a single consistent element type across every `array.from(...)` call
55
+ (`var` array declarations, plain declarations and inline arguments alike) in
56
+ `pineforge_codegen/codegen/types.py` and `pineforge_codegen/analyzer/types.py`,
57
+ preserving `int` for integer constants (including unary-signed constants and
58
+ function-local constants) and promoting to `double` when any element is
59
+ `float`. For previously compiling scripts, the observable emitted-C++ change
60
+ is that an `array.from` whose arguments are all integer, including
61
+ unary-signed ones like `array.from(-1, 1)`, now emits `std::vector<int>`
62
+ instead of `std::vector<double>`; with `na` mixed in (`array.from(-1, na)`) it
63
+ emits `int` with the `int` `na` sentinel, as `array.from(1, na)` already did.
64
+ Values are unchanged for arithmetic, since `/`, `%`, `math.max` and the array
65
+ reductions already work in `double`
66
+ ([#205](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/205)).
67
+ - Group weekly Dependabot pull requests into one pull request per ecosystem
68
+ (`npm` and `pip`) in `.github/dependabot.yml`
69
+ ([#206](https://github.com/pineforge-4pass/pineforge-codegen-oss/pull/206)).
70
+
23
71
  ## 1.6.0 — 2026-10-17
24
72
 
25
73
  A minor release of the exact engine/codegen pair, paired with engine `v1.6.0`
@@ -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-rc.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
@@ -0,0 +1 @@
1
+ 1.6.1-rc.1
@@ -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 +0,0 @@
1
- 1.6.0