Repository navigation
feat: sourceで使えるクラスとスコープ付き参照を追加 - #120
Draft
milkeclair wants to merge 27 commits into
Draft
milkeclair wants to merge 27 commits into
milkeclair wants to merge 27 commits into
Conversation
milkeclair
force-pushed
the
feat/class-runtime
branch
4 times, most recently
from
November 16, 2026 11:42
cde6a2c to
8a13bdc
Compare
Collect unquoted method blocks through the DEBUG trap and keep instance state behind immutable scoped handles. Share dispatcher programs and preserve typed attribute values, return status and existing traps. Refs #90.
Missing associative lookups can retain unset parameter nodes even when visible element counts are zero. Explicitly remove each deleted active-state entry and rebuild empty instance tables after the last deletion so repeated object graphs reuse bounded storage.
Reuse existing predicates and collection APIs, separate generated-command responsibilities, and directly test each runtime function at its namespace path. Keep isolated source, attribute and reference scenarios for whole-shell contracts.
Use the reserved z_cls_ prefix for both local runtime variables and persistent state. Release the unused double-underscore prefix for ordinary identifiers, and cover caller-local shadowing and attributes with the former prefix. Expand declarations and command groups, initialize bindings at use, and separate test phases without changing class dispatch or typed snapshots.
Separate call validation, saved-scalar access, restored execution, native accessors and instance release. Keep restoration and canonical snapshots in one owning scope, with no fallback status protocol or shared API changes. Cover every extracted function directly and retain source, reentry, typed-value and readonly-reference scenarios.
Keep the eight source DSL entrypoints public and mark twenty internal leaf names private using the existing completion convention. Update generated dispatch and DEBUG callbacks, reuse signed-integer and type-flag predicates, and retain native operations where normalization would alter literal values or parameter shape. Verify the real shell completion cache and caller-visible behavior.
Follow main after implicit value conversion and z.return removal. Update obsolete fixtures and docs, remove old getter-loop isolation, and retain scalar/array and owning-scope accessor contracts with focused regressions.
Follow the updated repository policy for README and function comments while preserving parser markers and executable code. State assumptions and concrete outcomes in public DSL examples, including a labelled PID-dependent reference example.
milkeclair
force-pushed
the
feat/class-runtime
branch
from
November 16, 2026 23:27
8a13bdc to
42619f3
Compare
Match existing function comments for operations without a reply value. Only change the REPLY description; retain runtime behavior, examples and all other documentation markers.
Use direct scoped expectations and dedicated null/array matchers instead of custom observation hashes. Capture status and reply in ordinary locals when both are required. Normalize fixture comments, reject unknown fixture cases, and keep production behavior and original scenarios intact.
Replace case-based scenario scripts and their custom failure function with standard z.t cases. Keep state and reference checks in their local scopes, and assert isolated option and DEBUG results in the parent test. Preserve all 29 integration cases and retain a small fixture for actual child-shell initialization.
The child inherited z_mode=test and printed its own zero-test summary in normal output mode, adding a line to the observed result. Clear that mode before loading z so the fixture initializes a regular child shell. Reproduced the CI failure without compact output and verified both output modes.
Use the existing execution function scope for method locals, return and arguments. Remove test wrappers that do not isolate a readonly binding, shadowed local or shell option. Extend the existing execution test to cover local isolation and positional arguments.
Spell out all five option cases instead of generating it declarations at runtime. Indent class bodies and retain the missing-end fixture as incomplete input. Use the existing z string-prefix predicate in the counter method.
An EXIT trap runs in its caller environment. Keep the method body scope so its trap sees the method arguments instead of the dispatcher's caller arguments. Extend the existing execution case to assert the trap argument alongside method locals, return value and status.
Use the shell-word and line split APIs added on main when saving the DEBUG trap. Keep the splitter results in a local REPLY so the caller result is preserved, and extend the capture test with array, whitespace and empty-element values. Keep the execution and snapshot hot paths unchanged.
Bind the instance ID in each method scope and route reads and writes to the stored instance attributes. Commit successful setter updates immediately and retain the Zsh types used by accessors.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
変更内容
Refs #90。通常の
sourceで平坦なクラス定義を読み込みます。draw/drewとfn/fn.doneが境界です。属性にはdefault=が必須で、空文字列も初期値にできます。定義の開始を拒否した場合は対応するdrewまで読み飛ばして1を返し、外側の定義を維持します。各メソッドに実体IDを持つreadonlyローカル変数
selfを用意します。$self.incrementで同じ実体のメソッドを呼び出し、$self.count.getと$self.count.setで保存済みの属性へアクセスします。getterとsetterは実体IDと属性名で値を特定するため、利用者のlocal countから独立します。成功したsetterはその場で値を更新し、メソッドがあとで非0終了してもその値を保持します。不正な数値式と奇数個の連想配列引数は元の値を保って失敗します。参照を変換する代入先は生成前に拒否します。メソッド実行に通常のZshの
errexit規則を適用し、定義時のDEBUGトラップとオプションも復元します。fixtureを対応ディレクトリへまとめ、テストは実装に対応するファイルに配置しました。内部関数のコメントには使用例と結果を記載しています。LSの認識と診断は、このブランチをbaseとする#121に含めています。
内部では、メソッドの登録と定義スコープの判定を共通化しています。メソッドを実行する経路では実行中の実体を管理し、型付き属性を操作する経路では宣言の復元・取得/更新・保存を扱います。
検証
countが10の状態で、呼出元がlocal count=3を持ったままcounter.add count=3を実行しました。呼出元は3、実体とREPLYは13です。入れ子呼出し、別実体から戻った後のself、型付き属性、失敗時の元の値も検証しました。