Skip to content

Commit 2169621

Browse files
committed
Very broken snapshots
1 parent 2db631d commit 2169621

File tree

7 files changed

+50
-17
lines changed

7 files changed

+50
-17
lines changed

main.kar

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
str s2 "I love men? !>"
2-
lit s1 24
3-
str f1 "kys"
4-
printr s1
5-
call io.println
6-
printr s1
1+
2+
lit f1 15
3+
call alloc f1

src/main/kotlin/Main.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ fun main(args: Array<String>): Unit = runBlocking(newSingleThreadContext("Kotlin
2525
println("Usage: mvm <command> [options]")
2626
exitProcess(1)
2727
}
28+
29+
2830
when (args[0]) {
2931
"irun" -> {
3032
if (args.size < 2) {
@@ -50,8 +52,9 @@ fun main(args: Array<String>): Unit = runBlocking(newSingleThreadContext("Kotlin
5052
println("Usage: mvm tokenise <file.kar>")
5153
exitProcess(1)
5254
}
53-
println("Deprecated!")
54-
// VarRedundancy(globalInfo = parser(init, File(args[1]).readLines())).cleanRedundancy().forEach(::println)
55+
println(
56+
"Deprecated!"
57+
) // VarRedundancy(globalInfo = parser(init, File(args[1]).readLines())).cleanRedundancy().forEach(::println)
5558
}
5659

5760

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import internals.instructions.xFloats.xMul
4949
import internals.instructions.xFloats.xPow
5050
import internals.instructions.xFloats.xSub
5151
import kernel.process.KProcess
52+
import os
5253

5354

5455
class Execute(val kp: KProcess) {
@@ -62,9 +63,11 @@ class Execute(val kp: KProcess) {
6263
kp.vm.errors.invalidPcValueException((kp.vm.pc).toString())
6364
}
6465

66+
os.snapShotManager.populateSnapShotRegister(kp) // Broken???
6567

6668
exeWhen(command.name, command.values)
6769

70+
os.snapShotManager.snapShotRegisters(kp) // Also broken????
6871
kp.vm.pc++
6972

7073
}
@@ -112,8 +115,7 @@ class Execute(val kp: KProcess) {
112115
suspend fun exeWhen(name: String, args: Array<Any?>): Unit? { // This has to be suspended. I know it's terrible!
113116
val vm = kp.vm
114117
kp.currentInstruction = InstructData(name, args)
115-
116-
kp.debug.act()
118+
// kp.debug.act()
117119

118120

119121
when (name) {

src/main/kotlin/kernel/SnapShotManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import data.registers.RegisterType
44
import data.registers.Registers
55
import internals.Vm
66
import kernel.process.KProcess
7-
7+
//@Depre
88
class SnapShotManager(private val registers: Registers) {
99

1010
private val snapshots = mutableMapOf<KProcess, Map<RegisterType, Long>>()
@@ -16,9 +16,9 @@ class SnapShotManager(private val registers: Registers) {
1616

1717
}
1818

19-
fun snapShotRegisters(kProcess: KProcess) {
19+
fun snapShotRegisters(kProcess: KProcess) { //TODO NOT WORKING!!!
2020
val allRegisters = mutableMapOf<RegisterType, Long>()
21-
for (i in RegisterType.entries) {
21+
for (i in RegisterType.entries) { // NOT WORKING!
2222
allRegisters[i] = registers.read(i)
2323
}
2424
snapshots[kProcess] = allRegisters // println("${kProcess.file.name}:${kProcess.vm.pc} -> [SNAPSHOT]")

src/main/kotlin/kernel/libEx/executeKt.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ suspend fun ExecuteLib.executeKt(name: String) {
1111
val newVm = Vm()
1212
val registerReserves =
1313
vm.registers.registers.map { (k, v) -> k to v.copy() }.toMap()
14+
1415
val newKp = KProcess(newVm, File("\$lib-$name"), isKlib = true)
15-
os.snapShotManager.snapShotRegisters(newKp)
16+
// os.snapShotManager.snapShotRegisters(newKp)
1617
for (registerType in registerReserves) vm.registers.registers[registerType.key] = registerType.value
1718
if (!Klib(newKp).match(name)) vm.errors.missingLibraryException(name) // Kt should be the last resort
1819
currentFunction = name
20+
1921
}

src/main/kotlin/kernel/libEx/executeMar.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ import java.io.File
1111
@OptIn(UnstableSnapShots::class)
1212
suspend fun ExecuteLib.executeMar(file: File) {
1313

14-
val localKp = KProcess(Vm(), file)
15-
os.snapShotManager.snapShotRegisters(kp)
14+
val localKp = KProcess(Vm(), file) // os.snapShotManager.snapShotRegisters(kp)
15+
val registerReserves = vm.registers.registers.map { (k, v) -> k to v.copy() }.toMap()
1616

1717
val oldInstructs = kp.instructionMemory
1818

1919
localKp.instructionMemory = parserReturn(localKp.vm, file.readLines())
2020
localKp.notifyOS()
21+
for (registerType in registerReserves) vm.registers.registers[registerType.key] = registerType.value
2122

2223
kp.instructionMemory = oldInstructs
2324

24-
os.snapShotManager.populateSnapShotRegister(kp)
25+
// os.snapShotManager.populateSnapShotRegister(kp)
2526
}

src/main/kotlin/kilb/Ll.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package kilb
2+
3+
import kernel.process.KProcess
4+
5+
class Ll(kp: KProcess) {
6+
val h = kp.addressSpace.heap
7+
fun create(): Long {
8+
val initP = h.alloc(2)
9+
return initP
10+
}
11+
12+
fun add(ll: Long, element: Long) {
13+
// val addr = h.get()
14+
}
15+
16+
fun getAt(index: Long) {
17+
18+
}
19+
20+
fun removeAt(index: Long) {}
21+
22+
fun clean() {}
23+
24+
fun findL() {}
25+
26+
fun findR() {}
27+
28+
}

0 commit comments

Comments
 (0)