-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: package of fixes for main
Elide
object
- fix: native library init - fix: deprecate native `TypeError` object - fix: use of `ValueError` as native host object - fix: use of entrypoint `facade.js` - fix: typescript engine detection - fix: initialization of cli args - fix: server engine symbol at `Elide.http` - fix: adopt buffer symbols properly - fix: native kqueue server - chore: update facade js - chore: update `runtime` module - chore: update `gvm` module - chore: update `@types/node` Signed-off-by: Sam Gammon <[email protected]>
- Loading branch information
Showing
30 changed files
with
321 additions
and
144 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
32 changes: 32 additions & 0 deletions
32
packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/ElideAPI.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2024 Elide Technologies, Inc. | ||
* | ||
* Licensed under the MIT license (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/license/mit/ | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
package elide.runtime.gvm.internals.intrinsics | ||
|
||
import elide.annotations.API | ||
import elide.runtime.intrinsics.js.node.ProcessAPI | ||
import elide.vm.annotations.Polyglot | ||
|
||
/** | ||
* # Elide API | ||
*/ | ||
@API public interface ElideAPI { | ||
/** | ||
* | ||
*/ | ||
@get:Polyglot public val process: ProcessAPI | ||
|
||
/** | ||
* | ||
*/ | ||
@get:Polyglot public val version: String | ||
} |
90 changes: 90 additions & 0 deletions
90
packages/graalvm/src/main/kotlin/elide/runtime/gvm/internals/intrinsics/ElideIntrinsic.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (c) 2024 Elide Technologies, Inc. | ||
* | ||
* Licensed under the MIT license (the "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/license/mit/ | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
@file:OptIn(DelicateElideApi::class) | ||
|
||
package elide.runtime.gvm.internals.intrinsics | ||
|
||
import org.graalvm.polyglot.Value | ||
import org.graalvm.polyglot.proxy.ProxyObject | ||
import java.util.LinkedList | ||
import elide.annotations.Singleton | ||
import elide.runtime.core.DelicateElideApi | ||
import elide.runtime.gvm.GuestLanguage | ||
import elide.runtime.gvm.internals.intrinsics.js.AbstractJsIntrinsic | ||
import elide.runtime.gvm.internals.intrinsics.js.JsSymbol.JsSymbols.asPublicJsSymbol | ||
import elide.runtime.gvm.internals.node.process.NodeProcess | ||
import elide.runtime.intrinsics.GuestIntrinsic.MutableIntrinsicBindings | ||
import elide.runtime.intrinsics.js.node.ProcessAPI | ||
import elide.vm.annotations.Polyglot | ||
|
||
// Symbol where the main Elide API is installed for guest use. | ||
private const val ELIDE_SYMBOL = "Elide" | ||
|
||
// Stubbed version of Elide. | ||
private const val ELIDE_VERSION_STUBBED = "stubbed" | ||
|
||
// Properties and methods made available for guest use. | ||
private val BASE_ELIDE_PROPS_AND_METHODS = arrayOf( | ||
"process", | ||
"version", | ||
) | ||
|
||
public fun installElideBuiltin(name: String, value: Any) { | ||
ElideIntrinsic.install(name, value) | ||
} | ||
|
||
@Intrinsic(ELIDE_SYMBOL, internal = false) @Singleton internal class ElideIntrinsic : | ||
ElideAPI, | ||
ProxyObject, | ||
AbstractJsIntrinsic() { | ||
companion object { | ||
private val SINGLETON = ElideIntrinsic() | ||
|
||
internal fun install(name: String, value: Any) { | ||
SINGLETON.install(name, value) | ||
} | ||
} | ||
|
||
// All properties and methods for guest use, including deferred properties. | ||
private val deferredPropsAndMethods = LinkedList<String>() | ||
|
||
// Mapped property values for deferred properties | ||
private val mappedDeferredValue = HashMap<String, Any>() | ||
|
||
override fun install(bindings: MutableIntrinsicBindings) { | ||
bindings[ELIDE_SYMBOL.asPublicJsSymbol()] = SINGLETON | ||
} | ||
|
||
internal fun install(name: String, value: Any) { | ||
deferredPropsAndMethods.add(name) | ||
mappedDeferredValue[name] = value | ||
} | ||
|
||
override fun supports(language: GuestLanguage): Boolean = language.engine == "js" | ||
|
||
@get:Polyglot override val process: ProcessAPI get() = NodeProcess.obtain() | ||
@get:Polyglot override val version: String get() = ELIDE_VERSION_STUBBED | ||
|
||
override fun getMemberKeys(): Array<String> = BASE_ELIDE_PROPS_AND_METHODS + deferredPropsAndMethods.toTypedArray() | ||
override fun hasMember(key: String?): Boolean = key in BASE_ELIDE_PROPS_AND_METHODS || key in deferredPropsAndMethods | ||
|
||
override fun putMember(key: String?, value: Value?) { | ||
// no-op from guest code | ||
} | ||
|
||
override fun getMember(key: String?): Any? = when (key) { | ||
"process" -> process | ||
"version" -> version | ||
else -> mappedDeferredValue[key] | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.