mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 21:21:33 +00:00
fix game of life support in evaluator
This commit is contained in:
@ -5,12 +5,14 @@ import com.kenai.jffi.Function
|
||||
import gay.pizza.pork.ast.gen.ArgumentSpec
|
||||
import gay.pizza.pork.evaluator.*
|
||||
import gay.pizza.pork.execution.ArgumentList
|
||||
import gay.pizza.pork.execution.NativeFunction
|
||||
import gay.pizza.pork.execution.NativeProvider
|
||||
import gay.pizza.pork.execution.None
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.absolutePathString
|
||||
import kotlin.io.path.exists
|
||||
|
||||
class FfiNativeProvider : ExpandedNativeProvider {
|
||||
class FfiNativeProvider : ExpandedNativeProvider, NativeProvider {
|
||||
private val internalFunctions = mutableMapOf<String, (ArgumentList) -> Any>(
|
||||
"ffiStructDefine" to ::ffiStructDefine,
|
||||
"ffiStructAllocate" to ::ffiStructAllocate,
|
||||
@ -208,6 +210,10 @@ class FfiNativeProvider : ExpandedNativeProvider {
|
||||
return structType.read(address, 0)
|
||||
}
|
||||
|
||||
override fun provideNativeFunction(definitions: List<String>): NativeFunction {
|
||||
throw RuntimeException("Invalid Native Function Usage")
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun typeConversion(type: FfiType): Type = when (type) {
|
||||
FfiPrimitiveType.UnsignedByte -> Type.UINT8
|
||||
|
@ -4,11 +4,13 @@ import gay.pizza.pork.ast.gen.ArgumentSpec
|
||||
import gay.pizza.pork.evaluator.CallableFunction
|
||||
import gay.pizza.pork.evaluator.SlabContext
|
||||
import gay.pizza.pork.evaluator.ExpandedNativeProvider
|
||||
import gay.pizza.pork.execution.NativeFunction
|
||||
import gay.pizza.pork.execution.NativeProvider
|
||||
import gay.pizza.pork.execution.None
|
||||
import java.lang.invoke.MethodHandles
|
||||
import java.lang.invoke.MethodType
|
||||
|
||||
class JavaNativeProvider : ExpandedNativeProvider {
|
||||
class JavaNativeProvider : ExpandedNativeProvider, NativeProvider {
|
||||
private val lookup = MethodHandles.lookup()
|
||||
|
||||
override fun provideNativeFunction(
|
||||
@ -62,4 +64,8 @@ class JavaNativeProvider : ExpandedNativeProvider {
|
||||
"static-setter" -> lookup.findStaticSetter(javaClass, symbol, returnType)
|
||||
else -> throw RuntimeException("Unknown Handle Kind: $kind")
|
||||
}
|
||||
|
||||
override fun provideNativeFunction(definitions: List<String>): NativeFunction {
|
||||
throw RuntimeException("Invalid Native Function Usage")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user