mirror of
https://github.com/apple/pkl.git
synced 2026-05-28 17:49:15 +02:00
Resolve variables at parse time (#1429)
This replaces `ResolveVariableNode` and `ResolveMethodNode` with their resolution. When we build the truffle node tree, we determine whether names resolve to: * lexical scope * base module * implicit this Then, we use this information to directly construct the underlying nodes (`ReadPropertyNode`, `ReadLocalPropertyNode`, etc). Additionally, `AstBuilder` determines whether the property access must be const or not. This introduces a `BaseModuleMembers` registry, which gets generated as part of Java compilation.
This commit is contained in:
@@ -61,6 +61,7 @@ dependencies {
|
||||
add("generatorImplementation", libs.javaPoet)
|
||||
add("generatorImplementation", libs.truffleApi)
|
||||
add("generatorImplementation", libs.jspecify)
|
||||
add("generatorImplementation", projects.pklParser)
|
||||
|
||||
javaExecutableConfiguration(project(":pkl-cli", "javaExecutable"))
|
||||
}
|
||||
@@ -140,6 +141,36 @@ tasks.test {
|
||||
maxHeapSize = "1g"
|
||||
}
|
||||
|
||||
val generateBaseModuleMembers by
|
||||
tasks.registering(JavaExec::class) {
|
||||
group = "build"
|
||||
|
||||
val outputDir = layout.buildDirectory.dir("generated/sources/baseModuleMembers")
|
||||
|
||||
val basePklFile = layout.projectDirectory.file("../stdlib/base.pkl")
|
||||
|
||||
inputs
|
||||
.file(basePklFile)
|
||||
.withPropertyName("basePkl")
|
||||
.withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
|
||||
outputs.dir(outputDir)
|
||||
|
||||
classpath =
|
||||
generatorSourceSet.get().runtimeClasspath + tasks.processResources.get().outputs.files
|
||||
mainClass = "org.pkl.core.generator.BaseModuleMembersGenerator"
|
||||
|
||||
argumentProviders.add(
|
||||
CommandLineArgumentProvider {
|
||||
listOf(basePklFile.asFile.absolutePath, outputDir.get().asFile.absolutePath)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
sourceSets.main { java.srcDir(layout.buildDirectory.dir("generated/sources/baseModuleMembers")) }
|
||||
|
||||
tasks.compileJava { dependsOn(generateBaseModuleMembers) }
|
||||
|
||||
val testJavaExecutable by
|
||||
tasks.registering(Test::class) {
|
||||
configureExecutableTest("LanguageSnippetTestsEngine")
|
||||
|
||||
Reference in New Issue
Block a user