Add local string Buffer, fix speed issues
This commit is contained in:
@@ -27,7 +27,9 @@ class B93Interpreter : Interpreter {
|
|||||||
override val outputChanged: Event<OutputEvent> = Event()
|
override val outputChanged: Event<OutputEvent> = Event()
|
||||||
|
|
||||||
override val stdInput = LinkedList<Char>()
|
override val stdInput = LinkedList<Char>()
|
||||||
override val stdOutput = LinkedList<Char>()
|
override val stdOutput = LinkedList<String>()
|
||||||
|
private var outBuf: StringBuffer = StringBuffer()
|
||||||
|
private var bufLimit = 10
|
||||||
|
|
||||||
private val fungeMods = HashMap<Vec,Value>()
|
private val fungeMods = HashMap<Vec,Value>()
|
||||||
|
|
||||||
@@ -174,13 +176,18 @@ class B93Interpreter : Interpreter {
|
|||||||
val vv = pop()
|
val vv = pop()
|
||||||
val v = vv.value
|
val v = vv.value
|
||||||
val out = when (type) {
|
val out = when (type) {
|
||||||
'.' -> v.toString().toList() + ' '
|
'.' -> v.toString() + ' '
|
||||||
',' -> listOf(v.toChar())
|
',' -> v.toChar().toString()
|
||||||
else -> listOf()
|
else -> null
|
||||||
}
|
}
|
||||||
stdOutput.addAll(out)
|
return out?.let{
|
||||||
outputChanged.invoke(OutputEvent())
|
outBuf.append(it)
|
||||||
return true
|
if (outBuf.length > bufLimit) {
|
||||||
|
stdOutput.add(outBuf.toString())
|
||||||
|
outBuf.delete(0, outBuf.length)
|
||||||
|
outputChanged.invoke(OutputEvent())
|
||||||
|
}
|
||||||
|
} != null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stepIP(): Boolean {
|
private fun stepIP(): Boolean {
|
||||||
@@ -255,6 +262,9 @@ class B93Interpreter : Interpreter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun terminate(): Boolean {
|
private fun terminate(): Boolean {
|
||||||
|
stdOutput.add(outBuf.toString())
|
||||||
|
outBuf.delete(0, outBuf.length)
|
||||||
|
outputChanged.invoke(OutputEvent())
|
||||||
ip.mode = IpMode.Inactive
|
ip.mode = IpMode.Inactive
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ interface Interpreter {
|
|||||||
val outputChanged: Event<OutputEvent>
|
val outputChanged: Event<OutputEvent>
|
||||||
|
|
||||||
val stdInput: Queue<Char>
|
val stdInput: Queue<Char>
|
||||||
val stdOutput: Queue<Char>
|
val stdOutput: Queue<String>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If [ip] is inactive after this step, indicating execution has halted, then return `false`
|
* @return If [ip] is inactive after this step, indicating execution has halted, then return `false`
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class ActionView(val interp: Interpreter, val ioView: IOView) : View() {
|
|||||||
|
|
||||||
button("run") {
|
button("run") {
|
||||||
setOnAction {
|
setOnAction {
|
||||||
runTimeline.rate = 1000.0
|
runTimeline.rate = 10000000.0
|
||||||
runTimeline.playFromStart()
|
runTimeline.playFromStart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,7 @@ class CodeView(val interp: Interpreter) : View() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val root = textarea(srcProperty) {
|
override val root = textarea(srcProperty) {
|
||||||
|
prefRowCount = 25
|
||||||
|
prefColumnCount = 80
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,35 @@ class EditorView : View("Befide") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
codeView.src = """64+"!dlroW ,olleH">:#,_@"""
|
codeView.src = """>84*>:#v_55+"ude.ub@yelruta">:#,_@>188*+>\02p\12p\:22p#v_${'$'} 55+,1- v
|
||||||
|
^ 0 v +1\ _^#-+*< >22g02g*"_@"*-!1- #v_v>
|
||||||
|
>:>::3g: ,\188 ^^ -1\g21\g22<p3\"_":<
|
||||||
|
________________________________@_________________________________^ p3\"@":<"""
|
||||||
|
// codeView.src = """--------------------------------------------------------------------------------
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// |-
|
||||||
|
// """.trimMargin()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,9 +16,11 @@ class IOView(val interp: Interpreter) : View() {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
interp.outputChanged += {
|
interp.outputChanged += {
|
||||||
|
var str = ""
|
||||||
while (!interp.stdOutput.isEmpty()) {
|
while (!interp.stdOutput.isEmpty()) {
|
||||||
output += interp.stdOutput.remove()
|
str += interp.stdOutput.remove()
|
||||||
}
|
}
|
||||||
|
output += str
|
||||||
}
|
}
|
||||||
// add listeners to interp, handle streams, idk
|
// add listeners to interp, handle streams, idk
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user