From a8607795df772df30e7af4d3ed599df98990e7c7 Mon Sep 17 00:00:00 2001 From: anyunderstanding Date: Sat, 28 Dec 2024 22:16:28 +0100 Subject: wow very toll kotlin transpiler works 100% every time <3 --- lllars/llltranspiler/src/main/kotlin/Ast.kt | 65 +++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 lllars/llltranspiler/src/main/kotlin/Ast.kt (limited to 'lllars/llltranspiler/src/main/kotlin/Ast.kt') diff --git a/lllars/llltranspiler/src/main/kotlin/Ast.kt b/lllars/llltranspiler/src/main/kotlin/Ast.kt new file mode 100644 index 0000000..4612dd7 --- /dev/null +++ b/lllars/llltranspiler/src/main/kotlin/Ast.kt @@ -0,0 +1,65 @@ +package me.any + +import AccessSerializer +import AddresationSerializer +import InstructionSerializer +import kotlinx.serialization.Serializable + +@Serializable(with = AccessSerializer::class) +interface Access + +@Serializable +data class SAccess(val sAddress: Access) : Access + +@Serializable +data class Address(val address: Int) : Access + + +enum class Operation { + ADD, SUB, MUL, DIV, AND, OR, XOR +} + +@Serializable(with = AddresationSerializer::class) +interface Addresation + +data class AddressAddresation(val address: Access) : Addresation + + +data class BinaryOperation( + val op: Operation, + val left: Access, + val right: Access +) : Addresation + +interface SysCall + +class WriteSysCall : SysCall +class ReadSysCall : SysCall + +enum class BranchPolarity { + IFTRUE, IFFALSE +} + +@Serializable(with = InstructionSerializer::class) +interface Instruction + +@Serializable +data class Comment(val comment: String = "") : Instruction + +@Serializable +data class Write(val target: Int, val source: Addresation) : Instruction + +@Serializable +data class LarsCode(val call: SysCall) : Instruction + +@Serializable +data class Label(val label: String) : Instruction + +@Serializable +data class GoTo(val label: String) : Instruction + +@Serializable +data class Branch(val polarity: BranchPolarity, val address: Address, val label: String) : Instruction + +@Serializable +data class Program(val instructions: List) \ No newline at end of file -- cgit v1.2.3