Create smnp.io module with println() function
This commit is contained in:
0
modules/io/build.gradle
Normal file
0
modules/io/build.gradle
Normal file
7
modules/io/gradle.properties
Normal file
7
modules/io/gradle.properties
Normal file
@@ -0,0 +1,7 @@
|
||||
version=0.0.1
|
||||
|
||||
pluginVersion=0.1
|
||||
pluginId=smnp.io
|
||||
pluginClass=
|
||||
pluginProvider=Bartłomiej Pluta
|
||||
pluginDependencies=
|
||||
15
modules/io/src/main/kotlin/io/smnp/ext/io/IoModule.kt
Normal file
15
modules/io/src/main/kotlin/io/smnp/ext/io/IoModule.kt
Normal file
@@ -0,0 +1,15 @@
|
||||
package io.smnp.ext.io
|
||||
|
||||
import io.smnp.callable.method.Method
|
||||
import io.smnp.ext.ModuleDefinition
|
||||
import io.smnp.ext.io.function.PrintlnFunction
|
||||
import org.pf4j.Extension
|
||||
|
||||
@Extension
|
||||
class IoModule : ModuleDefinition {
|
||||
override fun modulePath() = "smnp.io"
|
||||
|
||||
override fun functions() = listOf(PrintlnFunction())
|
||||
|
||||
override fun methods() = emptyList<Method>()
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package io.smnp.ext.io.function
|
||||
|
||||
import io.smnp.callable.function.Function
|
||||
import io.smnp.callable.function.FunctionDefinitionTool
|
||||
import io.smnp.callable.signature.Signature.Companion.vararg
|
||||
import io.smnp.type.matcher.Matcher.Companion.allTypes
|
||||
import io.smnp.type.model.Value
|
||||
|
||||
class PrintlnFunction : Function("println") {
|
||||
override fun define(new: FunctionDefinitionTool) {
|
||||
new function vararg(allTypes()) define { _module, (vararg) ->
|
||||
// TODO: Implement equivalent of "toString()" method
|
||||
println((vararg.value!! as List<Value>).joinToString("") { it.value!!.toString() })
|
||||
Value.void()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,4 @@ include 'app'
|
||||
include 'modules'
|
||||
|
||||
include 'modules:lang'
|
||||
include 'modules:io'
|
||||
Reference in New Issue
Block a user