mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
duh
This commit is contained in:
@@ -85,11 +85,11 @@ object VMRunnerFactory {
|
||||
}
|
||||
|
||||
override suspend fun executeCommand(command: String) {
|
||||
engine.eval("\"use strict\";" + sanitiseJS(toSingleLine(command)), context)
|
||||
engine.eval("\"use strict\";" + encapsulateJS(sanitiseJS(command)), context)
|
||||
}
|
||||
|
||||
override suspend fun evalGlobal(command: String) {
|
||||
engine.eval("\"use strict\";" + toSingleLine(command), context)
|
||||
engine.eval("\"use strict\";" + sanitiseJS(command), context)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,6 +99,7 @@ object VMRunnerFactory {
|
||||
|
||||
|
||||
private fun toSingleLine(code: String) = code.replace(Regex("//[^\\n]*"), "").replace('\n', ' ')
|
||||
private fun sanitiseJS(code: String) = "eval('${toSingleLine(code).replace("\\", "\\\\")}')"
|
||||
private fun sanitiseJS(code: String) = toSingleLine(code).replace("\\", "\\\\")
|
||||
private fun encapsulateJS(code: String) = "eval('$code')"
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.torvald.tsvm.peripheral.GraphicsAdapter
|
||||
|
||||
class V2kRunTest(val appConfig: LwjglApplicationConfiguration) : ApplicationAdapter() {
|
||||
|
||||
val vm = VM(64.kB())
|
||||
val vm = VM(64.kB(), TheRealWorld())
|
||||
lateinit var gpu: GraphicsAdapter
|
||||
|
||||
lateinit var batch: SpriteBatch
|
||||
|
||||
Reference in New Issue
Block a user