better docs/AI instructions/readme

This commit is contained in:
sergeych committed 2026-02-19 01:06:08 +03:00
1 parent 087143b022
commit 45f3658742
7 files changed
+50 -131

No files matched your search

+8 -25
View File
@@ -1,37 +1,20 @@
AI State (for session restart)
Project: /home/sergeych/dev/ling_lib
Project: /home/sergeych/dev/lyng
Module focus: :lynglib
Current focus
- Enforce compile-time name/member resolution only; no runtime scope lookup or fallback.
- Bytecode uses memberId-based ops (CALL_MEMBER_SLOT/GET_MEMBER_SLOT/SET_MEMBER_SLOT).
- Runtime lookup opcodes (CALL_VIRTUAL/GET_FIELD/SET_FIELD) and fallback callsites are removed.
- Use FrameSlotRef for captures and only materialize Scope for Kotlin interop; use frame.ip -> pos mapping for diagnostics.
- Closures capture frame slots directly; materialize `Scope` only for Kotlin interop or explicit dynamic helpers.
- Object members are allowed on unknown types; other members require a statically known receiver type or explicit cast.
- Type system is Kotlin-style: `T` non-null, `T?` nullable, `!!` asserts non-null; `void` is a singleton of class `Void`.
- Type expressions: unions/intersections with bounds, declaration-site variance (`in`/`out`), and structural equality.
Key recent changes
- Removed method callsite PICs and fallback opcodes; bytecode now relies on compile-time member ids only.
- Operator dispatch emits memberId calls when known; falls back to Obj opcodes for allowed built-ins without name lookup.
- Object members are allowed on unknown types; other members still require a statically known receiver type.
- Added frame.ip -> pos mapping; call-site ops restore pos after args to keep stack traces accurate.
- Loop var overrides now take precedence in slot resolution to keep loop locals in frame slots.
- LocalSlotRef now falls back to name lookup when slot plans are missing (closure safety).
- Updated AI helper docs to reflect static typing, type expressions, and compile-time-only name resolution.
Known failing tests
- None (jvmTest passing).
Files touched recently
- notes/type_system_spec.md (spec updated)
- AGENTS.md (type inference reminders)
- lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt
- lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt
- lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt
- Not checked in this session.
Last test run
- ./gradlew :lynglib:jvmTest
Spec decisions (notes/type_system_spec.md)
- Nullability: Kotlin-style, T non-null, T? nullable, !! asserts non-null.
- void is singleton of class Void (syntax sugar).
- Untyped params default to Object (non-null); syntax sugar: fun foo(x?) and class X(a,b?).
- Object member access requires explicit cast; remove inspect, use toInspectString().
- Not checked in this session.