feat(frontend): lower singleton receivers and resolve inherited engine statics#49
Merged
Conversation
- document singleton receiver lowering gaps across frontend and backend - define the `load_static "@globalscope"` design and binding contracts - outline phased tests, implementation steps, and acceptance criteria
- Validate singleton metadata in ClassRegistry before publishing value bindings. - Materialize singleton identifiers as @globalscope load_static receivers and lower backend singleton reads as borrowed objects. - Split singleton lookup and return type metadata for module-local Godot wrappers. - Cover executable/property-init pipelines, binding usage, codegen snapshots, and LIR round-trip. - Update frontend/backend/LIR implementation docs with completed phase status.
- Add runtime test-suite case for singleton property init, return, void, and argument calls. - Add body-lowering guard test for published singleton bindings without registry metadata. - Update singleton receiver lowering plan status and bundled test resource list.
- Store top-binding resolved values and access status in FrontendBinding. - Reuse published resolved values in expression and chain receiver analysis. - Refresh local binding payloads after slot type writeback and cover drift cases.
- Add runtime fixture for later-local shadowing and self-referential initializer drift. - Register the new script in the unit test compile runner. - Record the new regression coverage in the frontend lowering plan.
- Implement tryApplyDualRoleTypeMetaBias with fail-closed rules for constants, enums, static methods, and .new() on dual-role names - Value-winner authority via resolveVisibleValue prevents shadowing override by local/param/property bindings - Signal defensive coverage in fail-closed instance-namespace checks - Reorder analyze(classRegistry, analysisData) to match codebase convention - Add 20+ unit tests with custom ExtensionAPI fixtures and plan doc updates
…ss, hasEngineClassConstant into ClassRegistry - Remove 6 duplicate private method definitions across FrontendTopBindingAnalyzer, FrontendChainReductionHelper, and FrontendConstructorResolutionSupport - Route all callers through the three new public ClassRegistry methods
- Add dual_role_singleton_static_constant.gd fixture exercising IP/ResourceUID/DisplayServer engine class constants via TYPE_META static load in executable body and property initializer. - Add dual_role_singleton_mixed_use_sites.gd fixture verifying SINGLETON instance call and TYPE_META static load routes do not pollute each other within the same body. - Register both fixtures in EXPECTED_SCRIPT_PATHS and record Step 9 end-to-end validation in the lowering plan.
- Add findEngineClassEnumValue / findBuiltinClassEnumValue to ClassRegistry - Rewire LoadStaticInsnGen, FrontendTopBindingAnalyzer, and FrontendChainReductionHelper to resolve enum values via ClassRegistry - Mirror the new helper paths in CLoadStaticInsnGenTest and FrontendChainReductionHelperTest coverage - Sync doc/module_impl/backend/load_static_implementation.md, frontend_chain_binding_expr_type_implementation.md, and frontend_singleton_receiver_lowering_plan.md with the routed lookups
- Walk the engine `inherits` chain in ClassRegistry for static constants and enum values (direct-first with cycle detection); keep builtin lookups direct-only to match the metadata model - Wire the inherited lookups through dual-role bias, chain reduction, and backend literal emit so all three layers stay consistent - Fix singleton fail-closed symmetry by filtering static properties in the instance-property hierarchy check - Clarify engine "not found" diagnostics to mention the searched superclasses - Add an end-to-end runtime fixture for an inherited engine class constant - Sync affected docs and mark the prior direct-only boundary as resolved
…t source - Rename `frontend_singleton_receiver_lowering_plan.md` to `frontend_singleton_implementation.md` and rewrite as long-term source of truth - Drop step-by-step progress, completion status, and verification dates; keep only current contracts, architecture, and risk boundaries - Strip "Step N" references from `FrontendExprTypeAnalyzer` and the dual-role test sections so code comments describe current behavior only
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.
Summary
This PR extends frontend singleton and static-member resolution so singleton receivers lower through
load_static, dual-role singleton bindings keep stable semantics across use sites, and inherited engine class static members resolve correctly. It also updates the C backend support required by the new lowering path, including builtin constructor runtime helpers andload_staticcode generation coverage.What changed
load_static, engine method binds, and builtin constructor runtime helpers.doc/module_impl/frontendanddoc/module_impl/backend, plus related IR notes.Why
load_staticand builtin-constructor support so the frontend semantic fixes could compile end to end.Affected packages/files
gd.script.gdcc.frontend.sema.analyzergd.script.gdcc.frontend.sema.analyzer.supportgd.script.gdcc.frontend.lowering.*gd.script.gdcc.scope.ClassRegistrygd.script.gdcc.backend.c.gen.*src/main/c/codegen/include_451/gdcc/*src/test/java/gd/script/gdcc/frontend/*src/test/java/gd/script/gdcc/backend/c/*src/test/test_suite/unit_test/{script,validation}/runtime/*doc/module_impl/frontend/frontend_singleton_implementation.mddoc/module_impl/backend/load_static_implementation.mdValidation
./gradlew.bat classes --no-daemon --info --console=plainpowershell -ExecutionPolicy Bypass -File script/run-gradle-targeted-tests.ps1 -Tests FrontendTopBindingAnalyzerTest,FrontendLoweringBodyInsnPassTest,CLoadStaticInsnGenTest,CConstructInsnGenTestResult:
BUILD SUCCESSFULRisks / Notes
load_staticC emission compatibility.Key behaviors covered (Optional)
load_staticin runtime and lowering tests.load_staticC codegen paths are covered by targeted backend tests.Diff stats (Optional)
Breaking changes (Optional)
Related docs (Optional)
doc/gdcc_low_ir.mddoc/module_impl/frontend/frontend_singleton_implementation.mddoc/module_impl/frontend/frontend_top_binding_analyzer_implementation.mddoc/module_impl/backend/load_static_implementation.mddoc/module_impl/backend/godot_binding_implementation.mdCloses #36