Refactor Value and EvaluatorOutput models in order to get rid of optionals(?)

This commit is contained in:
2020-03-14 13:25:42 +01:00
parent d8744670ed
commit 5b03f55cd4
30 changed files with 60 additions and 78 deletions

View File

@@ -13,7 +13,7 @@ class ExitFunction : Function("exit") {
override fun define(new: FunctionDefinitionTool) {
new function simple(optional(ofType(INT))) body { _, arguments ->
val exitCode = arguments.getOrNull(0) ?: Value.int(0)
exitProcess(exitCode.value!! as Int)
exitProcess(exitCode.value as Int)
}
}
}

View File

@@ -10,7 +10,7 @@ import io.smnp.type.model.Value
class SleepFunction : Function("sleep") {
override fun define(new: FunctionDefinitionTool) {
new function simple(ofType(INT)) body { _, (milli) ->
Thread.sleep((milli.value!! as Int).toLong())
Thread.sleep((milli.value as Int).toLong())
Value.void()
}
}