Skip to content

Commit b903433

Browse files
committed
new run state
1 parent 6cb567b commit b903433

File tree

5 files changed

+9
-12
lines changed

5 files changed

+9
-12
lines changed

src/main/kotlin/engine/execution/Execute.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Execute(val kp: KProcess) {
3737
parser(kp, kp.file.readLines())
3838
}
3939

40-
fun singleEvent(command: InstructData) {
40+
suspend fun singleEvent(command: InstructData) {
4141
kp.vm.pc++
4242
if (kp.vm.pc - 1 < 0) {
4343
kp.vm.errors.InvalidPcValueException((kp.vm.pc - 1).toString())
@@ -50,10 +50,10 @@ class Execute(val kp: KProcess) {
5050
}
5151

5252

53-
fun run(command: List<InstructData>) {
53+
suspend fun run(command: List<InstructData>) {
5454
val vm = kp.vm
5555
while (true) {
56-
when (vm.runtimeState) {
56+
when (kp.runtimeState) {
5757

5858
RuntimeStates.RUNNING -> {/* pass */
5959

@@ -87,7 +87,7 @@ class Execute(val kp: KProcess) {
8787
// }
8888

8989

90-
fun exeWhen(name: String, args: Array<Any?>): Unit? { // This has to be suspended I know its terrible!
90+
suspend fun exeWhen(name: String, args: Array<Any?>): Unit? { // This has to be suspended I know its terrible!
9191
val vm = kp.vm
9292
kp.currentInstruction = InstructData(name, args)
9393

src/main/kotlin/internals/Vm.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import data.registers.read
77
import data.vfs.Vfs
88
import environment.VMErrors
99
import helpers.Helpers
10-
import helpers.RuntimeStates
1110
import internals.instructions.arithmetic.Arithmetic
1211
import internals.instructions.bitwise.Bitwise
1312
import internals.instructions.controlFlow.ControlFlow
@@ -52,9 +51,6 @@ class Vm {
5251
var heap: Heap? = null
5352

5453

55-
var runtimeState = RuntimeStates.RUNNING
56-
57-
5854
}
5955

6056

src/main/kotlin/kernel/KProcess.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package kernel
33
import data.memory.ProcessMemory
44
import engine.execution.InstructData
55
import environment.reflection.reflection
6+
import helpers.RuntimeStates
67
import internals.Vm
78
import internals.debug.Debug
89
import os
910
import java.io.File
1011

1112
data class KProcess(val vm: Vm, var file: File) {
1213
val debug = Debug(this)
13-
14+
var runtimeState = RuntimeStates.RUNNING
1415
val addressSpace = ProcessMemory(this)
1516
var currentInstruction: InstructData = InstructData(name = "init", arrayOf())
1617

src/main/kotlin/kernel/systemCalls/SystemCall.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SystemCall(val vm: Vm) {
2424
val errors = vm.errors
2525
val registers = vm.registers
2626

27-
fun execute(
27+
suspend fun execute(
2828
callId: RegisterType,
2929
s2: RegisterType,
3030
s3: RegisterType,

src/main/kotlin/kernel/systemCalls/calls/spawn.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ fun SystemCall.share_m(vm_id: RegisterType, fromX: RegisterType, toX: RegisterTy
2020

2121
fun SystemCall.pause_t(vmToPause: RegisterType) {
2222
val x = reflection.vmTracker.groupBy(KProcess::id)
23-
x[registers.read(vmToPause).toInt()]!![0].vm.runtimeState = RuntimeStates.PAUSED
23+
x[registers.read(vmToPause).toInt()]!![0].runtimeState = RuntimeStates.PAUSED
2424
}
2525

2626
fun SystemCall.continue_t(vmToPause: RegisterType) {
2727
val x = reflection.vmTracker.groupBy(KProcess::id)
28-
x[registers.read(vmToPause).toInt()]!![0].vm.runtimeState = RuntimeStates.RUNNING
28+
x[registers.read(vmToPause).toInt()]!![0].runtimeState = RuntimeStates.RUNNING
2929
}

0 commit comments

Comments
 (0)