Create some new standard library modules
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
package io.smnp.ext.lang
|
||||
|
||||
import io.smnp.ext.NativeModuleProvider
|
||||
import io.smnp.ext.lang.function.DebugFunction
|
||||
import io.smnp.ext.lang.function.TypeOfFunction
|
||||
import io.smnp.ext.lang.method.ListAccessMethod
|
||||
import io.smnp.ext.lang.method.MapAccessMethod
|
||||
import org.pf4j.Extension
|
||||
|
||||
@Extension
|
||||
class LangModule : NativeModuleProvider("smnp.lang") {
|
||||
override fun functions() = listOf(DebugFunction())
|
||||
override fun functions() = listOf(TypeOfFunction())
|
||||
override fun methods() = listOf(ListAccessMethod(), MapAccessMethod())
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
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() body { env, _ ->
|
||||
env.printCallStack()
|
||||
Value.void()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.matcher.Matcher.Companion.allTypes
|
||||
import io.smnp.type.model.Value
|
||||
|
||||
class TypeOfFunction : Function("typeOf") {
|
||||
override fun define(new: FunctionDefinitionTool) {
|
||||
new function simple(allTypes()) body { _, (obj) ->
|
||||
Value.string(obj.type.toString()) // TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user