Add support for function/methods invocation on Environment + create call stack model

This commit is contained in:
2020-03-10 21:57:21 +01:00
parent 82e86ebc6a
commit d29ef61245
10 changed files with 163 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
package io.smnp.ext.lang
import io.smnp.callable.function.Function
import io.smnp.ext.ModuleDefinition
import io.smnp.ext.lang.function.DebugFunction
import io.smnp.ext.lang.method.ListAccessMethod
import io.smnp.ext.lang.method.MapAccessMethod
import org.pf4j.Extension
@@ -10,7 +10,7 @@ import org.pf4j.Extension
class LangModule : ModuleDefinition {
override fun modulePath() = "smnp.lang"
override fun functions() = emptyList<Function>()
override fun functions() = listOf(DebugFunction())
override fun methods() = listOf(ListAccessMethod(), MapAccessMethod())
}

View File

@@ -0,0 +1,15 @@
package io.smnp.ext.lang.function
import io.smnp.callable.function.Function
import io.smnp.callable.function.FunctionDefinitionTool
import io.smnp.callable.signature.Signature.Companion.simple
import io.smnp.type.model.Value
class DebugFunction : Function("debug") {
override fun define(new: FunctionDefinitionTool) {
new function simple() define { env, _ ->
env.printCallStack()
Value.void()
}
}
}