pineforge-codegen 1.6.2__tar.gz → 1.6.3__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.
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/CONTRIBUTING.md +48 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/PKG-INFO +1 -1
- pineforge_codegen-1.6.3/VERSION +1 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/base.py +4 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/types.py +16 -5
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/visit_call.py +106 -2
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/visit_expr.py +34 -4
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/visit_stmt.py +5 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/parser.py +29 -5
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/pine_libraries.py +1 -1
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/support_checker.py +21 -0
- pineforge_codegen-1.6.2/VERSION +0 -1
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/.gitignore +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/CHANGELOG.md +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/LEGAL.md +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/LICENSE +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/README.md +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/docs/PUBLIC_CONTRACT.md +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/docs/codegen-coverage-gaps.md +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/docs/pine-cap-activation.md +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/__init__.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/__init__.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/base.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/call_handlers.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/contracts.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/diagnostics.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/tables.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/types.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/ast_nodes.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/block_locals.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/builtin_keywords.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/__init__.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/capabilities.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/checked_settings.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/collection_history.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/constant_fold.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/drawing.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/emit_top.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/helpers.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/helpers_syminfo.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/host_members.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/input.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/order_shapes.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/run_stops.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/security.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/session_market.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/ta.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/tables.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/tv_number_format.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/collection_history.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/cpp_allowlist.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/diagnostic_codes.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/diagnostics_catalog.json +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/errors.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/external_requests.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/finite_ta_length.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/lexer.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/library_inline.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/library_modules.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/library_v5.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/limits.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/matrix_overloads.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/method_binding.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/pine_spelling.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/pragmas.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/request_discovery.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/request_feed_inventory.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/security_contexts.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/session_reads.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/signatures.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/symbols.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/timeframe_token_cli.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/tokens.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/tv_input_choices.py +0 -0
- {pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pyproject.toml +0 -0
|
@@ -109,6 +109,54 @@ the Python `build` frontend, run `python -m build`, assemble the npm payload,
|
|
|
109
109
|
then run `npm pack --dry-run` from `npm/`. These commands build local artifacts;
|
|
110
110
|
publishing is a separate release operation.
|
|
111
111
|
|
|
112
|
+
## npm publication (operators)
|
|
113
|
+
|
|
114
|
+
The release and npm publication workflows run on GitHub-hosted runners.
|
|
115
|
+
Run both workflows with `workflow_dispatch` on `main`.
|
|
116
|
+
`release.yml` publishes to PyPI, commits and pushes the release tag, then
|
|
117
|
+
creates the GitHub Release and notifies the release hub. After the tag exists
|
|
118
|
+
on main and the release job is green, the operator doing the cut, using a
|
|
119
|
+
GitHub account with write access, publishes npm with this separate dispatch:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
gh workflow run publish-pyodide.yml --repo pineforge-4pass/pineforge-codegen-oss --ref main -f tag=<tag> -f dry_run=false
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Use the existing release tag in place of `<tag>`. Set `dry_run=true` to
|
|
126
|
+
validate first. A tag push alone publishes nothing. A green `release.yml`
|
|
127
|
+
run does not mean npm published; watch the `publish-pyodide.yml` run.
|
|
128
|
+
Every npm run requires an existing release tag, including dry runs and
|
|
129
|
+
placeholder claims. Its first job, `tag-guard`, has only Contents read
|
|
130
|
+
permission and checks out main with credentials persistence disabled. It
|
|
131
|
+
checks the dispatch ref is `refs/heads/main`, validates the release pattern
|
|
132
|
+
(`vX.Y.Z` or `vX.Y.Z-{alpha,beta,rc}.N`) before using the input in git,
|
|
133
|
+
fetches tags and full main history, peels the tag to a 40-hex commit and
|
|
134
|
+
checks that commit is an ancestor of `refs/remotes/origin/main`.
|
|
135
|
+
A missing tag, a tag that cannot peel to a commit, an invalid name or a tag
|
|
136
|
+
outside main fails the run before either npm job can start. Publish checks
|
|
137
|
+
out the verified commit SHA with credentials persistence disabled, verifies
|
|
138
|
+
its `VERSION`, and runs the gate before publishing. The workflow run stays
|
|
139
|
+
at `refs/heads/main` while its checkout uses the pinned commit; moving the tag
|
|
140
|
+
after verification does not change what gets built.
|
|
141
|
+
|
|
142
|
+
For a manual npm dry run, dispatch `publish-pyodide.yml` on `main` with
|
|
143
|
+
`dry_run=true` and an existing release `tag` on main. For a real npm retry
|
|
144
|
+
after a successful tag push, dispatch on `main` with the existing release
|
|
145
|
+
`tag` and `dry_run=false`. A placeholder claim uses `claim_placeholder=true`
|
|
146
|
+
and the same required tag guard. The guard fails a dispatch at another ref;
|
|
147
|
+
both npm jobs also retain their main-ref job conditions and require the
|
|
148
|
+
guard to succeed.
|
|
149
|
+
The guard and job conditions live in the workflow file on `main`, but GitHub
|
|
150
|
+
executes the file from the dispatched ref, so they alone cannot stop a user
|
|
151
|
+
with write access who pushes and dispatches a modified workflow on another
|
|
152
|
+
branch. The server-side bound is the GitHub environment `npm-publish`: both npm
|
|
153
|
+
jobs (`publish` and `claim-npm`) run in it, and it carries a `main`-only
|
|
154
|
+
deployment-branch policy, so a run from any other ref is refused by GitHub. The
|
|
155
|
+
npm trusted publisher for the package is set by the repository owner to require
|
|
156
|
+
that environment (owner decision NPM-TP; that setting lives on npmjs.com and
|
|
157
|
+
cannot be read from this repository), so a publish from a workflow that does not
|
|
158
|
+
declare the environment fails at npm.
|
|
159
|
+
|
|
112
160
|
## Change and review notes
|
|
113
161
|
|
|
114
162
|
- Add or update tests for behavior changes. Keep the engine corpus compiling;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pineforge-codegen
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.3
|
|
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.3
|
|
@@ -905,6 +905,10 @@ class CodeGen(CallVisitor, ExprVisitor, StmtVisitor, TopLevelEmitter, SecurityEm
|
|
|
905
905
|
self._security_calls: list[dict] = [self._normalize_security_call(item) for item in ctx.security_calls]
|
|
906
906
|
# Current function parameter types (set during _emit_func_def)
|
|
907
907
|
self._current_func_param_types: dict[str, str] = {}
|
|
908
|
+
# The emitted C++ type of each tuple-destructuring binding, so a field
|
|
909
|
+
# read can recognise a chart.point binding whose TypeSpec is a
|
|
910
|
+
# deliberate tombstone.
|
|
911
|
+
self._tuple_binding_cpp_types_by_name: dict[str, str] = {}
|
|
908
912
|
self._current_func_param_specs: dict[str, "TypeSpec"] = {}
|
|
909
913
|
# Copy-on-write lexical collection inventory for the function/method
|
|
910
914
|
# currently being emitted. Activated by _emit_func_def and restored
|
|
@@ -507,16 +507,25 @@ class TypeInferer:
|
|
|
507
507
|
def _default_for_spec(self, spec: TypeSpec | None) -> str:
|
|
508
508
|
"""Default initialiser for a TypeSpec; vector/map specs get ``T()``.
|
|
509
509
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
510
|
+
A user type brace-inits its struct name when the type is declared in
|
|
511
|
+
this translation unit (an imported type is inlined before codegen).
|
|
512
|
+
An enum element defaults to the double ``na`` (its slot is a double);
|
|
513
|
+
an undeclared name is not a C++ type and falls back to its slot's
|
|
514
|
+
default.
|
|
513
515
|
"""
|
|
514
516
|
if spec is not None and spec.kind == "udt" and spec.name:
|
|
515
517
|
# Drawing handle default (P2): brace-init the C++ struct name
|
|
516
518
|
# (Line{} = na handle), NOT the lowercase Pine name (line{}).
|
|
517
519
|
if spec.name in DRAWING_TYPE_TO_CPP:
|
|
518
520
|
return f"{DRAWING_TYPE_TO_CPP[spec.name]}{{}}"
|
|
519
|
-
|
|
521
|
+
if spec.name in getattr(self, "_enum_defs", ()):
|
|
522
|
+
# An enum's element slot is a double (``_type_spec_to_cpp``);
|
|
523
|
+
# the absent value is na<double>(), not the first member and
|
|
524
|
+
# not the integer sentinel, which a double does not carry.
|
|
525
|
+
return "na<double>()"
|
|
526
|
+
if spec.name in getattr(self, "_udt_defs", ()):
|
|
527
|
+
return f"{self._safe_name(spec.name)}{{}}"
|
|
528
|
+
return self._default_for_type(self._type_spec_to_cpp(spec))
|
|
520
529
|
cpp_type = self._type_spec_to_cpp(spec)
|
|
521
530
|
if cpp_type.startswith("std::vector") or cpp_type.startswith("PineMap"):
|
|
522
531
|
return f"{cpp_type}()"
|
|
@@ -4047,7 +4056,9 @@ class TypeInferer:
|
|
|
4047
4056
|
return "int"
|
|
4048
4057
|
# format.* constants emit std::string literals (consumed by
|
|
4049
4058
|
# pine_str_tostring); bare reads must declare std::string.
|
|
4050
|
-
if ename
|
|
4059
|
+
if ename in ("format", "currency", "order"):
|
|
4060
|
+
return "std::string"
|
|
4061
|
+
if ename == "session" and node.member in ("regular", "extended"):
|
|
4051
4062
|
return "std::string"
|
|
4052
4063
|
if ename == "alert" and node.member in ALERT_FREQ_VALUES:
|
|
4053
4064
|
return "std::string"
|
|
@@ -196,6 +196,50 @@ from .tables import (
|
|
|
196
196
|
_merge_kwargs,
|
|
197
197
|
)
|
|
198
198
|
|
|
199
|
+
# Pine member names the codegen has a lowering for somewhere. A method the
|
|
200
|
+
# type resolver cannot route back to one of these tables (a history read of a
|
|
201
|
+
# UDT collection field, for example) keeps its historical pass-through
|
|
202
|
+
# spelling; anything else is not a Pine method and must not become C++ text.
|
|
203
|
+
PINEFORGE_MEMBER_NAMES = frozenset(
|
|
204
|
+
ARRAY_METHODS
|
|
205
|
+
) | frozenset(MAP_METHODS) | frozenset(MATRIX_METHODS) | frozenset(
|
|
206
|
+
ALL_DRAWING_METHODS
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def _spec_for_cpp_param(cpp: str | None):
|
|
211
|
+
"""A TypeSpec for an untyped parameter's emitted C++ type, if known.
|
|
212
|
+
|
|
213
|
+
Only ``std::string`` is resolved: it carries C++ members of its own, so a
|
|
214
|
+
Pine method name that collides (``copy``, ``size``, ``clear``) must not
|
|
215
|
+
pass through. A numeric parameter has no such members; a collection
|
|
216
|
+
parameter is resolved by its own spec before this fallback.
|
|
217
|
+
"""
|
|
218
|
+
if cpp == "std::string":
|
|
219
|
+
return TypeSpec.primitive("string")
|
|
220
|
+
return None
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def _member_name_has_lowering(recv_spec, name: str) -> bool:
|
|
224
|
+
"""Whether ``name`` is a Pine method of a receiver of ``recv_spec``.
|
|
225
|
+
|
|
226
|
+
A resolved receiver admits only its own namespace's table: a string has no
|
|
227
|
+
Pine methods, so a name like ``size`` or ``copy`` must not reach
|
|
228
|
+
``std::string``. An unresolved receiver keeps the historical pass-through
|
|
229
|
+
for any Pine method name.
|
|
230
|
+
"""
|
|
231
|
+
if recv_spec is None:
|
|
232
|
+
return name in PINEFORGE_MEMBER_NAMES
|
|
233
|
+
if recv_spec.kind == "array":
|
|
234
|
+
return name in ARRAY_METHODS
|
|
235
|
+
if recv_spec.kind == "map":
|
|
236
|
+
return name in MAP_METHODS
|
|
237
|
+
if recv_spec.kind == "matrix":
|
|
238
|
+
return name in MATRIX_METHODS
|
|
239
|
+
if recv_spec.kind == "udt" and recv_spec.name in DRAWING_TYPE_TO_CPP:
|
|
240
|
+
return name in ALL_DRAWING_METHODS
|
|
241
|
+
return False
|
|
242
|
+
|
|
199
243
|
|
|
200
244
|
def _parse_pine_datestring_ms(text: str) -> int | None:
|
|
201
245
|
"""Parse a Pine ``timestamp(dateString)`` literal to Unix milliseconds.
|
|
@@ -310,6 +354,25 @@ class CallVisitor:
|
|
|
310
354
|
# Function-call dispatch
|
|
311
355
|
# ------------------------------------------------------------------
|
|
312
356
|
|
|
357
|
+
def _reject_unknown_element_type(self, node, element_spec) -> None:
|
|
358
|
+
"""Refuse an element type that is not a type this unit can name.
|
|
359
|
+
|
|
360
|
+
The support checker normally refuses it; a switch arm downgrades that
|
|
361
|
+
error to a warning, so the emitter checks again and never defaults an
|
|
362
|
+
undeclared name.
|
|
363
|
+
"""
|
|
364
|
+
if (element_spec is not None and element_spec.kind == "udt"
|
|
365
|
+
and element_spec.name
|
|
366
|
+
and element_spec.name not in self._udt_defs
|
|
367
|
+
and element_spec.name not in self._enum_defs
|
|
368
|
+
and element_spec.name not in DRAWING_TYPE_TO_CPP
|
|
369
|
+
and element_spec.name not in ("table", "polyline")):
|
|
370
|
+
full = element_spec.name
|
|
371
|
+
self._codegen_error(
|
|
372
|
+
node,
|
|
373
|
+
f"{full}(...) is not implemented in PineForge runtime.",
|
|
374
|
+
)
|
|
375
|
+
|
|
313
376
|
def _udt_method_call_emit_name(self, fi, node: FuncCall) -> str:
|
|
314
377
|
"""Resolve a UDT method call through the ordinary UDF clone graph."""
|
|
315
378
|
base = self._emit_udt_method_cpp_name(fi)
|
|
@@ -1794,6 +1857,17 @@ class CallVisitor:
|
|
|
1794
1857
|
self._array_method_args(meth, arg_nodes, recv_spec),
|
|
1795
1858
|
recv_spec, node,
|
|
1796
1859
|
)
|
|
1860
|
+
if recv_spec is None:
|
|
1861
|
+
# A builtin namespace's constant lowers to a string
|
|
1862
|
+
# temporary; its emitted type is what the member
|
|
1863
|
+
# would be called on.
|
|
1864
|
+
recv_spec = _spec_for_cpp_param(self._infer_type(obj))
|
|
1865
|
+
if not _member_name_has_lowering(recv_spec, meth):
|
|
1866
|
+
full = meth
|
|
1867
|
+
self._codegen_error(
|
|
1868
|
+
node,
|
|
1869
|
+
f"{full}(...) is not implemented in PineForge runtime.",
|
|
1870
|
+
)
|
|
1797
1871
|
args = ", ".join(raw_args)
|
|
1798
1872
|
if meth == "delete":
|
|
1799
1873
|
meth = "_delete_"
|
|
@@ -1943,6 +2017,16 @@ class CallVisitor:
|
|
|
1943
2017
|
force_stage=self._binds_fresh_array_to_reference(
|
|
1944
2018
|
fi_u, rest_nodes, first_param=1),
|
|
1945
2019
|
)
|
|
2020
|
+
if recv_spec is None:
|
|
2021
|
+
recv_spec = _spec_for_cpp_param(
|
|
2022
|
+
self._current_func_param_types.get(obj.name)
|
|
2023
|
+
) or _spec_for_cpp_param(self._infer_type(obj))
|
|
2024
|
+
if not _member_name_has_lowering(recv_spec, meth_raw):
|
|
2025
|
+
full = meth_raw
|
|
2026
|
+
self._codegen_error(
|
|
2027
|
+
node,
|
|
2028
|
+
f"{full}(...) is not implemented in PineForge runtime.",
|
|
2029
|
+
)
|
|
1946
2030
|
args = ", ".join(self._visit_expr(a) for a in node.args)
|
|
1947
2031
|
recv = self._visit_expr(obj)
|
|
1948
2032
|
meth = meth_raw
|
|
@@ -2166,6 +2250,7 @@ class CallVisitor:
|
|
|
2166
2250
|
spec = self._widen_array_spec_for_name(target, spec)
|
|
2167
2251
|
cpp_type = self._type_spec_to_cpp(spec)
|
|
2168
2252
|
elem_spec = spec.element if spec.element is not None else TypeSpec.primitive("float")
|
|
2253
|
+
self._reject_unknown_element_type(node, elem_spec)
|
|
2169
2254
|
init_default = self._default_for_spec(elem_spec)
|
|
2170
2255
|
if node.args:
|
|
2171
2256
|
size_arg = self._visit_expr(node.args[0])
|
|
@@ -2214,6 +2299,7 @@ class CallVisitor:
|
|
|
2214
2299
|
spec = declared
|
|
2215
2300
|
spec = self._widen_array_spec_for_name(target, spec)
|
|
2216
2301
|
elem_spec = spec.element
|
|
2302
|
+
self._reject_unknown_element_type(node, elem_spec)
|
|
2217
2303
|
for a in node.args:
|
|
2218
2304
|
self._warn_narrow_int_element(a, spec, a)
|
|
2219
2305
|
elems = ", ".join(
|
|
@@ -2738,6 +2824,13 @@ class CallVisitor:
|
|
|
2738
2824
|
if func_name == "new":
|
|
2739
2825
|
targs = self._template_args_from_call(node)
|
|
2740
2826
|
elem_spec = self._type_spec_from_hint_name(targs[0]) if targs else TypeSpec.primitive("float")
|
|
2827
|
+
if elem_spec is None:
|
|
2828
|
+
full = targs[0]
|
|
2829
|
+
self._codegen_error(
|
|
2830
|
+
node,
|
|
2831
|
+
f"{full}(...) is not implemented in PineForge runtime.",
|
|
2832
|
+
)
|
|
2833
|
+
self._reject_unknown_element_type(node, elem_spec)
|
|
2741
2834
|
args_e = [self._visit_expr(a) for a in node.args]
|
|
2742
2835
|
rows = args_e[0] if args_e else "0"
|
|
2743
2836
|
cols = args_e[1] if len(args_e) > 1 else "0"
|
|
@@ -2952,6 +3045,16 @@ class CallVisitor:
|
|
|
2952
3045
|
hint="Check the spelling; this namespace may not be supported "
|
|
2953
3046
|
"by PineForge.",
|
|
2954
3047
|
)
|
|
3048
|
+
elif namespace is not None:
|
|
3049
|
+
# A UDT name is a value type, not a namespace: its constructor,
|
|
3050
|
+
# copy and typed methods return above. Anything left is a call
|
|
3051
|
+
# the codegen cannot lower; emitting it raw would write the
|
|
3052
|
+
# user's type name as a C++ namespace qualifier.
|
|
3053
|
+
full = f"{namespace}.{func_name}"
|
|
3054
|
+
self._codegen_error(
|
|
3055
|
+
node,
|
|
3056
|
+
f"{full}(...) is not implemented in PineForge runtime.",
|
|
3057
|
+
)
|
|
2955
3058
|
|
|
2956
3059
|
# Generic function call (user-defined or unknown)
|
|
2957
3060
|
# Determine which params are series (need Series<double> arg, not scalar)
|
|
@@ -3126,7 +3229,8 @@ class CallVisitor:
|
|
|
3126
3229
|
# Mirror Pine default `timeframe.period` instead of hard-coding 15m.
|
|
3127
3230
|
all_args.append("script_tf_")
|
|
3128
3231
|
ordered_arg_nodes.append(None)
|
|
3129
|
-
|
|
3232
|
+
# Every non-null namespace is refused above (unknown namespace, or a
|
|
3233
|
+
# member call on a user type), so the emitted head is never qualified.
|
|
3130
3234
|
# Use safe name for user-defined functions to avoid member name collision
|
|
3131
3235
|
emit_name = self._func_safe_name(func_name) if func_name in self._func_names else func_name
|
|
3132
3236
|
# Per-call-site variant: if this function has TA/series calls, call the correct variant
|
|
@@ -3155,7 +3259,7 @@ class CallVisitor:
|
|
|
3155
3259
|
# Inside a per-call-site variant: propagate call-site index to
|
|
3156
3260
|
# sub-functions that also have variants (for state isolation)
|
|
3157
3261
|
emit_name = f"{self._func_safe_name(func_name)}_cs{self._active_call_site_idx}"
|
|
3158
|
-
call_head =
|
|
3262
|
+
call_head = emit_name
|
|
3159
3263
|
if namespace is None and func_name in self._func_names:
|
|
3160
3264
|
return self._ordered_user_call_expr(
|
|
3161
3265
|
call_head,
|
|
@@ -1177,14 +1177,44 @@ class ExprVisitor:
|
|
|
1177
1177
|
or name in self._current_func_locals
|
|
1178
1178
|
or name in self._udt_var_types
|
|
1179
1179
|
):
|
|
1180
|
-
|
|
1181
|
-
|
|
1180
|
+
# A member the codegen has no lowering for. A user type's
|
|
1181
|
+
# field is a real C++ member (chart.point keeps its fields
|
|
1182
|
+
# this way); a builtin-backed receiver has no Pine member, so
|
|
1183
|
+
# writing the name raw would read arbitrary C++ state.
|
|
1184
|
+
recv_spec = self._type_spec_from_expr(node.object)
|
|
1185
|
+
tuple_cpp = getattr(
|
|
1186
|
+
self, "_tuple_binding_cpp_types_by_name", {}
|
|
1187
|
+
).get(name)
|
|
1188
|
+
point = (
|
|
1189
|
+
(recv_spec is not None and recv_spec.name == "chart.point")
|
|
1190
|
+
or self._infer_type(node.object) == "ChartPoint"
|
|
1191
|
+
or tuple_cpp == "ChartPoint"
|
|
1192
|
+
)
|
|
1193
|
+
if point and node.member in ("time", "index", "price"):
|
|
1194
|
+
safe = self._call_site_var_name(
|
|
1195
|
+
node.object, self._safe_name(name)
|
|
1196
|
+
)
|
|
1197
|
+
return f"{safe}.{node.member}"
|
|
1198
|
+
full = f"{name}.{node.member}"
|
|
1199
|
+
self._codegen_error(
|
|
1200
|
+
node,
|
|
1201
|
+
f"{full}(...) is not implemented in PineForge runtime.",
|
|
1182
1202
|
)
|
|
1183
|
-
return f"{safe}.{node.member}"
|
|
1184
1203
|
if name not in self.ctx.series_vars:
|
|
1185
1204
|
# Unknown identifier — likely an enum value
|
|
1186
1205
|
return f'std::string("{self._cpp_string_escape(node.member)}")'
|
|
1187
|
-
|
|
1206
|
+
recv_spec = self._type_spec_from_expr(node.object)
|
|
1207
|
+
point = (
|
|
1208
|
+
(recv_spec is not None and recv_spec.name == "chart.point")
|
|
1209
|
+
or self._infer_type(node.object) == "ChartPoint"
|
|
1210
|
+
)
|
|
1211
|
+
if point and node.member in ("time", "index", "price"):
|
|
1212
|
+
return f"{obj}.{node.member}"
|
|
1213
|
+
full = f"{node.member}"
|
|
1214
|
+
self._codegen_error(
|
|
1215
|
+
node,
|
|
1216
|
+
f"{full}(...) is not implemented in PineForge runtime.",
|
|
1217
|
+
)
|
|
1188
1218
|
|
|
1189
1219
|
def _operand_na_kind(self, node, cpp_type: str) -> str | None:
|
|
1190
1220
|
"""Classify a relational operand by the ``na`` sentinel it can carry.
|
|
@@ -315,6 +315,11 @@ class StmtVisitor:
|
|
|
315
315
|
# unrelated same-named global/callable UDT must not target-
|
|
316
316
|
# type a later ``name := na`` as ``State{}``.
|
|
317
317
|
self._lexical_udt_types[name] = None
|
|
318
|
+
self._tuple_binding_cpp_types_by_name[name] = (
|
|
319
|
+
tuple_cpp_types[index]
|
|
320
|
+
if index < len(tuple_cpp_types)
|
|
321
|
+
else "double"
|
|
322
|
+
)
|
|
318
323
|
if (getattr(self, "_active_func_name", None) is not None
|
|
319
324
|
and not self._decl_binding_is_series(
|
|
320
325
|
id(node), name
|
|
@@ -650,6 +650,11 @@ class Parser:
|
|
|
650
650
|
|
|
651
651
|
def _parse_type_hint_string(self) -> str:
|
|
652
652
|
"""Parse primitive, UDT, array<T>, map<K,V>, or postfix-array (``T[]``) hints."""
|
|
653
|
+
# A type hint is a type grammar, never an arbitrary token's value: a
|
|
654
|
+
# string or number here would reach the emitted C++ type position.
|
|
655
|
+
if (self._current().type not in TYPE_KEYWORDS
|
|
656
|
+
and self._current().type != TokenType.IDENT):
|
|
657
|
+
self._consume(TokenType.IDENT) # raises a located ParseError
|
|
653
658
|
base = self._advance().value
|
|
654
659
|
# Library type qualified by its import alias: ``lib.Type``.
|
|
655
660
|
while self._check(TokenType.DOT) and self._peek().type == TokenType.IDENT:
|
|
@@ -676,8 +681,12 @@ class Parser:
|
|
|
676
681
|
continue
|
|
677
682
|
if tok.type == TokenType.COMMA:
|
|
678
683
|
parts.append(",")
|
|
679
|
-
|
|
684
|
+
elif (tok.type in TYPE_KEYWORDS
|
|
685
|
+
or tok.type in (TokenType.IDENT, TokenType.DOT)):
|
|
680
686
|
parts.append(str(tok.value))
|
|
687
|
+
else:
|
|
688
|
+
# A string/number/operator inside <...> is not a type.
|
|
689
|
+
self._consume(TokenType.IDENT)
|
|
681
690
|
self._advance()
|
|
682
691
|
base = f"{base}<{''.join(parts)}>"
|
|
683
692
|
|
|
@@ -712,11 +721,20 @@ class Parser:
|
|
|
712
721
|
break
|
|
713
722
|
depth -= 1
|
|
714
723
|
current.append(">")
|
|
715
|
-
elif tok.type == TokenType.COMMA
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
724
|
+
elif tok.type == TokenType.COMMA:
|
|
725
|
+
# A comma at depth 0 separates arguments; inside a nested
|
|
726
|
+
# <...> it belongs to that type (map<string, float>).
|
|
727
|
+
if depth == 0:
|
|
728
|
+
args.append("".join(current).strip())
|
|
729
|
+
current = []
|
|
730
|
+
else:
|
|
731
|
+
current.append(",")
|
|
732
|
+
elif (tok.type in TYPE_KEYWORDS
|
|
733
|
+
or tok.type in (TokenType.IDENT, TokenType.DOT)):
|
|
719
734
|
current.append(str(tok.value))
|
|
735
|
+
else:
|
|
736
|
+
# Template arguments are type names, not literal text.
|
|
737
|
+
self._consume(TokenType.IDENT)
|
|
720
738
|
self._advance()
|
|
721
739
|
return args
|
|
722
740
|
|
|
@@ -740,6 +758,12 @@ class Parser:
|
|
|
740
758
|
return i + 1 < len(self.tokens) and self.tokens[i + 1].type == TokenType.LPAREN
|
|
741
759
|
elif tt in (TokenType.NEWLINE, TokenType.EOF_TOKEN) and depth > 0:
|
|
742
760
|
return False
|
|
761
|
+
elif tt not in TYPE_KEYWORDS and tt not in (
|
|
762
|
+
TokenType.IDENT, TokenType.DOT, TokenType.COMMA,
|
|
763
|
+
):
|
|
764
|
+
# Not the type grammar: this '<' is an ordinary comparison,
|
|
765
|
+
# not the opening of template arguments.
|
|
766
|
+
return False
|
|
743
767
|
i += 1
|
|
744
768
|
return False
|
|
745
769
|
|
|
@@ -18,7 +18,7 @@ A script's imports resolve only through its own manifest, never through the
|
|
|
18
18
|
case-wide directory alone: otherwise a probe that pins no library would
|
|
19
19
|
transpile on a shard neighbour's pin, and measure differently by case
|
|
20
20
|
composition. ``transpile()`` is handed the source text, not a slug (the frozen
|
|
21
|
-
verifier
|
|
21
|
+
campaign verifier (commit 3bac0b7b, ``scripts/verify-engine-local.py:1698``) calls
|
|
22
22
|
``transpile((d / "strategy.pine").read_text())``), so the manifest is found by
|
|
23
23
|
content: the one ``requests.json`` whose ``probe.strategySha256`` is the sha256
|
|
24
24
|
of the script. That sha is of the strategy file's bytes, and ``read_text()``
|
|
@@ -1932,6 +1932,27 @@ class SupportChecker:
|
|
|
1932
1932
|
self._err(node, f"array.{name}(...) is not implemented in PineForge runtime.")
|
|
1933
1933
|
self._visit_children(node)
|
|
1934
1934
|
return
|
|
1935
|
+
if ns == "array" and name in ("new", "from"):
|
|
1936
|
+
# The element type names a C++ type in the emitted default
|
|
1937
|
+
# initialiser; it must be a Pine type, never arbitrary text.
|
|
1938
|
+
targs = (getattr(node.callee, "annotations", None) or {}).get("template_args") or []
|
|
1939
|
+
targs = [str(t).replace(" ", "") for t in targs]
|
|
1940
|
+
if targs:
|
|
1941
|
+
t = targs[0]
|
|
1942
|
+
allowed_prim = {"float", "int", "bool", "string", "color"}
|
|
1943
|
+
allowed_udt = {
|
|
1944
|
+
"line", "label", "box", "linefill", "chart.point",
|
|
1945
|
+
"table", "polyline",
|
|
1946
|
+
}
|
|
1947
|
+
if ("<" not in t and ">" not in t
|
|
1948
|
+
and t not in allowed_prim
|
|
1949
|
+
and t not in self._user_types
|
|
1950
|
+
and t not in self._user_enums
|
|
1951
|
+
and t not in allowed_udt):
|
|
1952
|
+
full = t
|
|
1953
|
+
self._err(node, f"{full}(...) is not implemented in PineForge runtime.")
|
|
1954
|
+
self._visit_children(node)
|
|
1955
|
+
return
|
|
1935
1956
|
if ns == "map" and name not in SUPPORTED_MAP:
|
|
1936
1957
|
self._err(node, f"map.{name}(...) is not implemented in PineForge runtime.")
|
|
1937
1958
|
self._visit_children(node)
|
pineforge_codegen-1.6.2/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.6.2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/call_handlers.py
RENAMED
|
File without changes
|
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/analyzer/diagnostics.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/capabilities.py
RENAMED
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/checked_settings.py
RENAMED
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/collection_history.py
RENAMED
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/constant_fold.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/helpers_syminfo.py
RENAMED
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/host_members.py
RENAMED
|
File without changes
|
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/order_shapes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/session_market.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/codegen/tv_number_format.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/diagnostics_catalog.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/request_feed_inventory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pineforge_codegen-1.6.2 → pineforge_codegen-1.6.3}/pineforge_codegen/timeframe_token_cli.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|