-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zhirkevich Alexander Y
authored and
Zhirkevich Alexander Y
committed
Aug 2, 2024
1 parent
e00fd53
commit 56786a1
Showing
39 changed files
with
517 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
skriptie/src/commonMain/kotlin/io/github/alexzhirkevich/skriptie/Script.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package io.github.alexzhirkevich.skriptie | ||
|
||
public fun interface Script<C : ScriptRuntime> { | ||
public operator fun invoke(context: C): Any? | ||
public fun interface Script { | ||
public operator fun invoke(context: ScriptRuntime): Any? | ||
} | ||
|
||
public fun <C : ScriptRuntime> Expression<C>.asScript(): Script<C> = Script { invoke(it) } | ||
public fun Expression.asScript(): Script = Script { invoke(it) } | ||
|
20 changes: 10 additions & 10 deletions
20
skriptie/src/commonMain/kotlin/io/github/alexzhirkevich/skriptie/ScriptEngine.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
package io.github.alexzhirkevich.skriptie | ||
|
||
public interface ScriptEngine<C : ScriptRuntime> : ScriptInterpreter<C> { | ||
public interface ScriptEngine : ScriptInterpreter { | ||
|
||
public val context : C | ||
public val runtime : ScriptRuntime | ||
|
||
public fun reset() { | ||
context.reset() | ||
runtime.reset() | ||
} | ||
} | ||
|
||
public fun <C : ScriptRuntime> ScriptEngine<C>.invoke(script: String) : Any? { | ||
return interpret(script).invoke(context) | ||
public fun ScriptEngine.invoke(script: String) : Any? { | ||
return interpret(script).invoke(runtime) | ||
} | ||
|
||
public fun <C : ScriptRuntime> ScriptEngine( | ||
context: C, | ||
interpreter: ScriptInterpreter<C> | ||
): ScriptEngine<C> = object : ScriptEngine<C>, ScriptInterpreter<C> by interpreter { | ||
override val context: C | ||
public fun ScriptEngine( | ||
context: ScriptRuntime, | ||
interpreter: ScriptInterpreter | ||
): ScriptEngine = object : ScriptEngine, ScriptInterpreter by interpreter { | ||
override val runtime: ScriptRuntime | ||
get() = context | ||
} |
4 changes: 2 additions & 2 deletions
4
skriptie/src/commonMain/kotlin/io/github/alexzhirkevich/skriptie/ScriptInterpreter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package io.github.alexzhirkevich.skriptie | ||
|
||
public interface ScriptInterpreter<C : ScriptRuntime> { | ||
public interface ScriptInterpreter { | ||
|
||
public fun interpret(script : String) : Script<C> | ||
public fun interpret(script : String) : Script | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.