diff --git a/AGENTS.md b/AGENTS.md index 40c4fb2..cdff595 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,3 +12,9 @@ - `void` is a singleton of class `Void` (syntax sugar for return type). - Object members are always allowed even on unknown types; non-Object members require explicit casts. Remove `inspect` from Object and use `toInspectString()` instead. - Do not reintroduce bytecode fallback opcodes (e.g., `GET_NAME`, `EVAL_*`, `CALL_FALLBACK`) or runtime name-resolution fallbacks; all symbol resolution must stay compile-time only. + +## Bytecode frame-first migration plan +- Treat frame slots as the only storage for locals/temps by default; avoid pre-creating scope slot mappings for compiled functions. +- Create closure references only when a capture is detected; use a direct frame+slot reference (foreign slot ref) instead of scope slots. +- Keep Scope as a lazy reflection facade: resolve name -> slot only on demand for Kotlin interop (no eager name mapping on every call). +- Avoid PUSH_SCOPE/POP_SCOPE in bytecode for loops/functions unless dynamic name access or Kotlin reflection is requested. diff --git a/docs/samples/happy_numbers.lyng.bad b/docs/samples/happy_numbers.lyng.bad index ec71429..3bbf68d 100644 --- a/docs/samples/happy_numbers.lyng.bad +++ b/docs/samples/happy_numbers.lyng.bad @@ -4,15 +4,21 @@ test the Lyng way. It is not meant to be effective. */ -fun naiveCountHappyNumbers() { +fun naiveCountHappyNumbers(): Int { var count = 0 - for( n1 in 0..9 ) - for( n2 in 0..9 ) - for( n3 in 0..9 ) - for( n4 in 0..9 ) - for( n5 in 0..9 ) - for( n6 in 0..9 ) + for( n1 in 0..9 ) { + for( n2 in 0..9 ) { + for( n3 in 0..9 ) { + for( n4 in 0..9 ) { + for( n5 in 0..9 ) { + for( n6 in 0..9 ) { if( n1 + n2 + n3 == n4 + n5 + n6 ) count++ + } + } + } + } + } + } count } @@ -28,4 +34,3 @@ for( r in 1..900 ) { assert( found == 55252 ) delay(0.05) } - diff --git a/lyng/src/jvmTest/kotlin/net/sergeych/lyng_cli/FsIntegrationJvmTest.kt b/lyng/src/jvmTest/kotlin/net/sergeych/lyng_cli/FsIntegrationJvmTest.kt index ae606d3..2484fa7 100644 --- a/lyng/src/jvmTest/kotlin/net/sergeych/lyng_cli/FsIntegrationJvmTest.kt +++ b/lyng/src/jvmTest/kotlin/net/sergeych/lyng_cli/FsIntegrationJvmTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ class FsIntegrationJvmTest { """ import lyng.io.fs // list current folder files - println( Path(".").list().toList() ) + println( Path(".").list() ) """.trimIndent() ) } diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt index 527dffa..0bcaf81 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt @@ -1131,6 +1131,7 @@ class Compiler( "