ffi: new native function format

This commit is contained in:
2023-09-22 00:26:24 -07:00
parent f60715dfb3
commit 83c24843a3
14 changed files with 75 additions and 57 deletions

View File

@ -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() }

View File

@ -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")
}

View File

@ -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
}