mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 21:21:33 +00:00
native: pass argument specs in order to support varadic ffi
This commit is contained in:
@ -9,7 +9,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)
|
||||
nativeFunctionProvider.provideNativeFunction(native.definition.text, node.arguments)
|
||||
}
|
||||
|
||||
private val nativeCached by lazy { resolveMaybeNative() }
|
||||
|
@ -1,12 +1,14 @@
|
||||
package gay.pizza.pork.evaluator
|
||||
|
||||
import gay.pizza.pork.ast.ArgumentSpec
|
||||
|
||||
class InternalNativeProvider(val quiet: Boolean = false) : NativeProvider {
|
||||
private val functions = mutableMapOf(
|
||||
"print" to CallableFunction(::printValues),
|
||||
"println" to CallableFunction(::printLine)
|
||||
)
|
||||
|
||||
override fun provideNativeFunction(definition: String): CallableFunction {
|
||||
override fun provideNativeFunction(definition: String, arguments: List<ArgumentSpec>): CallableFunction {
|
||||
return functions[definition] ?: throw RuntimeException("Unknown Internal Function: $definition")
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package gay.pizza.pork.evaluator
|
||||
|
||||
import gay.pizza.pork.ast.ArgumentSpec
|
||||
|
||||
interface NativeProvider {
|
||||
fun provideNativeFunction(definition: String): CallableFunction
|
||||
fun provideNativeFunction(definition: String, arguments: List<ArgumentSpec>): CallableFunction
|
||||
}
|
||||
|
Reference in New Issue
Block a user