604 Commits

Author SHA1 Message Date
Islon Scherer
2ffd201172 move handling of strings to parser (#962) 2025-02-19 17:19:48 +01:00
Daniel Chao
ee23a8c3f4 Make CliktCommands classes (#963)
Missed these three classes.

This prevents the AOT compiler from statically initializing CLI argument
default values (like working dir).
2025-02-18 08:29:59 -08:00
Daniel Chao
28b128f86f Run spotless formatting (#958)
When we updated spotless's Java and Kotlin formatter, we changed the underlying
formatting rules.
However, due to spotless ratcheting, these formatting changes don't get applied unless a file
gets touched in a commit.

To avoid future PRs introducing lines of change that aren't related to the intention of the PR,
this is a one-time format of all files.
2025-02-17 07:36:43 -08:00
Islon Scherer
d270829ed3 fix calculation of spans in parser (#957) 2025-02-15 12:11:55 +01:00
Michael Case
350b71a634 Fix incorrect glob example (#956)
Correct glob docs and use realistic file extensions.
2025-02-14 13:31:04 -08:00
Daniel Chao
28df90527b Add docs for various keywords (#955) 2025-02-14 13:30:22 -08:00
Daniel Chao
eabfcdd333 Allow -DcommitId flag when building Pkl (#954)
This is to allow building Pkl in environments that don't have access
to git.
2025-02-14 09:36:47 -08:00
Daniel Chao
1a4f9ee72e Improve handling of errors when analysis fails (#948)
Modules that cannot be loaded for one reason or another now cause a Pkl Exception,
with the offending import highlighted as part of the stack trace.
2025-02-13 14:00:48 -08:00
Daniel Chao
65cf3237b7 Add parser benchmarks (#953)
The current benchmark is not too useful now that we have a linear parser.

This changes the benchmarks to parse the standard library, and also the language snippet tests.

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2025-02-13 11:22:31 -08:00
Daniel Chao
d00d0ba79f Update dependencies (#938) 2025-02-13 10:19:24 -08:00
Josh B
f56b1bb84f Test and document supercalls using the same method/property name (#943) 2025-02-12 21:10:37 -08:00
Islon Scherer
b526902bf0 Replace ANTLR with hand-rolled parser (#917)
Co-authored-by: Kushal Pisavadia <kushi.p@gmail.com>
Co-authored-by: Daniel Chao <daniel.h.chao@gmail.com>
2025-02-12 18:11:00 +01:00
Daniel Chao
7c3f8ad261 Improve documentation about Set/Map ordering (#944)
The language reference and stdlib are both slightly incorrect;
maps and sets are ordered when iterated on, but unordered in terms of
equality.
2025-02-12 06:43:51 -08:00
Daniel Chao
7ed710c226 Make commands classes instead of objects (#946)
Making these classes caused native-image to statically initialize
them at build time, which included CLI argument default values
(like working dir).

This turns them back into classes.

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2025-02-11 06:38:19 -08:00
Josh B
ad99e4a7f7 Correctly set allowed modules/resoures when external reader scheme contain regex control characters (#941) 2025-02-07 14:03:40 -08:00
Daniel Chao
e85e888f92 [docs] Add documetation about release/evolution/roadmap (#937) 2025-02-05 11:24:41 -08:00
Daniel Chao
3b6fbdff15 Remove usages of VmFunction#apply(Object) (#936)
These call sites should use `ApplyVmFunction1Node` instead.
2025-02-05 09:18:42 -08:00
Daniel Chao
9784cd7265 Turn CLI commands into objects, self register subcommands (#935)
Usages of `RootCommand` no longer need to initialize a new instance, nor register subcommands.
2025-02-05 09:18:23 -08:00
Daniel Chao
aadcccd0fc Run a simple eval script (#928)
Execute `1 + 1` instead of eval'ing `circleci.pkl` (might cause
spurious failures due to requirement on network connection).
2025-02-04 07:21:57 -08:00
Daniel Chao
9075ca0729 Fix native gvm ci (#930)
* Update GraalVM checksum
* Fix: download JDK on macOS

Signed-off-by: Sam Gammon <sam@elide.dev>
Co-authored-by: Sam Gammon <sam@elide.dev>
2025-02-04 07:21:42 -08:00
Sam Gammon
5e12dfb200 fix: upgrade ci jobs to jdk 21 (#926)
Signed-off-by: Sam Gammon <sam@elide.dev>
2025-02-03 17:17:07 -08:00
Sam Gammon
408242a44c Upgrade GraalVM and Truffle, set up multi-JDK testing, bump development Java to 21 (#876)
This updates the GraalVM and Truffle libraries to 2024.1.2.

This also updates the build logic to compile Java sources using Java 21, due to some compile-only dependencies within GraalVM/Truffle using class file version 65. However, the produced artifact is still compatible with Java 17.

This also changes the Gradle build logic to use toolchains, and to test the Java libraries with JDK 17 and 21.

One consequence of this change is that Truffle is no longer shaded within the fat jars.

feat: support for jvm21+ toolchain
feat: support for gradle toolchains
feat: pass -PnativeArch=native to build with -march=native
test: multi-jdk testing support
test: support for jvm-test-suite plugin
test: add tasks to run jpkl eval on multiple jdks
test: make jdk exec tests respect multi-jdk flags and ranges
fix: remove mrjar classes at >jvm17 from fatjars
fix: use jdk21 to run the tests (needed for Unsafe.ensureInitialized)
fix: truffle svm dependency is required after graalvm 24.0.0
fix: warnings for gvm flag usage, renamed truffle svm macro
fix: build with --add-modules=jdk.unsupported where needed
fix: don't use gu tool for modern graalvm versions
fix: catch Throwable instead of deprecated-for-removal ThreadDeath
chore: buildinfo changes for JVM targets, toolchains
chore: enforce testing at exactly jdk21
chore: enforce build tooling at jdk21+
chore: bump graalvm/truffle libs → 24.1.2
chore: toolchains for buildSrc

Signed-off-by: Sam Gammon <sam@elide.dev>
2025-02-03 14:57:40 -08:00
Stanley Cheung
8cfd2357c6 Fix typo in tutorial part 2 (#921) 2025-01-31 07:53:22 -08:00
Sam Gammon
3fa935b390 fix: downstream native-image builds (#914)
SVM (SubstrateVM) compile configuration classes
must be included within the `cli` jar to prevent
downstream `native-image` builds from failing.

Fat JARs cannot be used with `native-image`, so
these classes can still safely be excluded here.

Fixes and closes apple/pkl#907

Signed-off-by: Sam Gammon <sam@elide.dev>
2025-01-29 20:31:05 -08:00
Kushal Pisavadia
aa8a0f18e8 Simplify inputs for javadocJar (#916)
Also, rename `dummy` to `placeholder`
2025-01-29 09:46:39 -08:00
Daniel Chao
3815a0206b Optimization: execute const object bodies and typechecks only once (#915)
If the object member is const, it only needs to be executed once, and all children in the prototype chain can use its cached value.

There is a possible other optimization here, not included in this PR: we can avoid adding these values to the child object's cachedMembers.
2025-01-29 07:19:55 -08:00
odenix
90df0662af Overhaul implementation of for-generators (#844)
Motivation:
* fix known bugs and limitations of for-generators
* improve code health by removing complex workarounds

Changes:
* simplify AstBuilder code related to for-generators
  * track for-generators via `SymbolTable.enterForGenerator()`
  * add `RestoreForBindingsNode` during initial AST construction
    instead of calling `MemberNode.replaceBody()` later on
  * simplify some unnecessarily complex code
* remove workarounds and band-aids such as:
  * `isInIterable`
  * `executeAndSetEagerly`
  * adding dummy slots in `AmendFunctionNode`
* overhaul implementation of for-generators
  * store keys and values of for-generator iterations in regular instead of auxiliary frame slots
    * set them via `TypeNode.executeAndSet()`
    * `ResolveVariableNode` no longer needs to search auxiliary slots
    * `Read(Enclosing)AuxiliarySlot` is no longer needed
  * at the start of each for-generator iteration, create a new `VirtualFrame`
    that is a copy of the current frame (arguments + slots)
    and stores the iteration key and value in additional slots.
  * execute for-generator iteration with the newly created frame
    * `childNode.execute(newFrame)`
    * Pkl objects created during the iteration will materialize this frame
  * store newly created frames in `owner.extraStorage`
    if their for-generator slots may be accessed when a generated member is executed
    * resolving variable names to for-generator variables at parse time would make this analysis more precise
  * when a generated member is executed,
	  * retrieve the corresponding frame stored in `owner.extraStorage`
	  * copy the retrieved frame's for-generator slots into slots of the current frame

Result:
* for-generators are implemented in a correct, reasonably simple, and reasonably efficient way
  * complexity is fully contained within package `generator` and `AstBuilder`
* for-generator keys and values can be accessed from all nested scopes:
  * key and value expressions of generated members
  * condition expressions of nested when-generators
  * iterable expressions of nested for-generators
* for-generator keys and values can be accessed from within objects created by the expressions listed above
* sibling for-generators can use the same key/value variable names
* parent/child for-generators can use the same key/value variable names
* fixes https://github.com/apple/pkl/issues/741
2025-01-28 14:06:42 -08:00
Kushal Pisavadia
11169d6691 Upgrade gradle to 8.12.1 (from 8.12) and fix some build warnings (#910)
Build warning fixes:

* Return `tasks.register` as `tasks.create` is deprecated
* Use property accessor `.files` instead of function `.files()`
2025-01-27 15:01:19 -08:00
Daniel Chao
5dc672731d Bump minimum Gradle version to 8.2 (#901)
The Kotlin 2.0 version upgrade made us incompatible with Gradle 8.1.

Given that it is now over 1.5 years old, this drops support for it, and
raises the minimum version to 8.2.
2025-01-27 10:04:31 -08:00
odenix
258eda8630 Update Kotlin to 2.0 (#900)
- update Kotlin from 1.7.10 to 2.0.21
  - Kotlin 1.6 dependencies in Gradle lock files are expected because kotlinc,
    which is also used by some tests, internally uses some 1.6 dependencies
    for backwards compatibility reasons.
- update kotlinx-html and kotlinx-serialization
- adapt Kotlin code where necessary
- use Kotlin stdlib Path APIs where possible
- fix IntelliJ Kotlin inspection warnings
- reformat code with `./gradlew spotlessApply`
  - ktfmt adds lots of trailing commas
- Add workaround to fix IntelliJ "unresolved reference" errors
2025-01-23 14:41:59 -08:00
Daniel Chao
cdd6d52642 Only run Gradle compatibility tests against minimum and maximum release (#898)
Currently, we run against every release version, which is taking 20
minutes to run in CI, and this will grow as Gradle creates more
releases.

This limits the amount of Gradle versions being tested against;
theoretically, only testing against the minimum version and the maximum
version should ensure that we are compatible with every version in the
range.
2025-01-22 14:08:45 -08:00
Daniel Chao
29049ac437 Import release notes for 0.27.2 (#897) 2025-01-22 09:36:48 -08:00
Daniel Chao
2a9b10097d Revert "Upgrade Kotlin to 1.7.21 (#887)" (#896)
This reverts commit 273d1219a6.
2025-01-22 08:33:06 -08:00
Daniel Chao
257bd6f699 Allow jar:nested: URIs in default security manager (#895)
Nested jars built by spring boot can possibly represent classpath
resource URIs as "jar:nested:".

This changes Pkl to by default trust them with the same level as
modulepath URIs.
2025-01-22 06:42:47 -08:00
Vic
75bd21420b Document where to find all keywords (#892) 2025-01-21 13:03:43 -08:00
Kushal Pisavadia
273d1219a6 Upgrade Kotlin to 1.7.21 (#887)
What's new: https://kotlinlang.org/docs/whatsnew1720.html

Releases
--------

- https://github.com/JetBrains/kotlin/releases/tag/v1.7.20
- https://github.com/JetBrains/kotlin/releases/tag/v1.7.21
2025-01-17 14:12:31 +00:00
Daniel Chao
ec7d7267dc Update dependencies (#883)
Most of these dependencies are test dependencies.
2025-01-15 05:39:14 -08:00
Daniel Chao
3096da1920 Update gradle to 8.12 (#884) 2025-01-15 05:38:51 -08:00
Daniel Chao
100dd0560e Support jpkl executable for Windows (#872)
This updates the script used to start the executable to support
Windows as well.

For Windows support, the executable needs to be named `jpkl.bat`.
2025-01-14 05:16:59 -08:00
Josh B
3296dd8a89 Fix NPE when handling ExternalReader specs with null arguments (#882) 2025-01-14 04:51:09 -08:00
Josh B
160e4a5636 YamlRenderer: allow all primitive scalar types as map keys (#879) 2025-01-13 16:22:52 -08:00
Josh B
267de3c789 Fix page size for Linux AArch64 native executables (#875)
Graal Native Image is assuming 4k page size here, which is a naughty assumption to make in the modern Linux-on-ARM landscape.
Two very common hardware configurations require 16k minumum page size: the Raspberry Pi 5 and Asahi Linux (running on Apple Silicon hardware).

This change forces 64k pages for Linux/AArch64 native executables to guarantee compatibility with these platforms.
DEVELOPMENT.adoc is also updated to cover the additional dependencies required for building native executables on Linux.
2025-01-07 15:55:27 +00:00
Daniel Chao
f6c74e90a8 Update license year (#871)
* Update license header file spec to use placeholder year
* Update spotless to use ratchet formatting (only format files that have changed)
2025-01-07 10:15:07 +00:00
Stefan M.
467e64f98e Make Test Report locale independent (#868)
Format numbers with `.` decimals
2025-01-02 09:29:48 -08:00
Josh Soref
d9c65d484a Fix spelling errors (#846)
Also: change checksums due to filename and content changes, and fix language snippet test output to produce correct error messages
2024-12-23 12:49:56 -08:00
Daniel Chao
a014e8d1d1 Add comment about const check (#859) 2024-12-23 11:38:33 -08:00
Daniel Chao
6fd82a5bb8 Clarify terminology on renderer converters (#860) 2024-12-20 10:36:51 -08:00
Daniel Chao
29fb99ffea Update JDK version in dev docs (#848) 2024-12-20 10:36:35 -08:00
Daniel Chao
efe1608bd6 Fix compile error (#857)
PRs https://github.com/apple/pkl/pull/789 and https://github.com/apple/pkl/pull/837 being merged caused a compile error; this fixes them.
2024-12-19 12:15:30 -08:00
Josh B
6cab47067b Fix CreateEvaluatorRequest decoding (#853)
Handle case when request specifies external reader with null arguments
2024-12-19 09:59:22 -08:00