mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 21:21:33 +00:00
ffi: new native function format
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user