ffi: new native function format

This commit is contained in:
alex committed 2023-09-22 00:26:24 -07:00
1 parent f60715dfb3
commit 83c24843a3
14 files changed
+75 -57

No files matched your search

@@ -11,7 +11,7 @@ class FunctionContext(val compilationUnitContext: CompilationUnitContext, val no
val native = node.native!!
val nativeFunctionProvider =
compilationUnitContext.evaluator.nativeFunctionProvider(native.form.id)
nativeFunctionProvider.provideNativeFunction(native.definition.text, node.arguments)
nativeFunctionProvider.provideNativeFunction(native.definitions.map { it.text }, node.arguments)
}
private val nativeCached by lazy { resolveMaybeNative() }
@@ -10,7 +10,8 @@ class InternalNativeProvider(val quiet: Boolean = false) : NativeProvider {
"listInitWith" to CallableFunction(::listInitWith)
)
override fun provideNativeFunction(definition: String, arguments: List<ArgumentSpec>): CallableFunction {
override fun provideNativeFunction(definitions: List<String>, arguments: List<ArgumentSpec>): CallableFunction {
val definition = definitions[0]
return functions[definition] ?: throw RuntimeException("Unknown Internal Function: $definition")
}
@@ -3,5 +3,5 @@ package gay.pizza.pork.evaluator
import gay.pizza.pork.ast.ArgumentSpec
interface NativeProvider {
fun provideNativeFunction(definition: String, arguments: List<ArgumentSpec>): CallableFunction
fun provideNativeFunction(definitions: List<String>, arguments: List<ArgumentSpec>): CallableFunction
}