mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-11-19 07:31:35 +00:00
all the classes
This commit is contained in:
parent
09054569f0
commit
819ea8fb1b
@ -0,0 +1,22 @@
|
||||
package com.htmlism.scratchpad
|
||||
|
||||
import cats.Semigroup
|
||||
import cats.syntax.all._
|
||||
|
||||
case class AsmProgram[A : Reg, MA <: MutationStatus, Z : Semigroup](a: StatefulRegister[A, MA], z: Z):
|
||||
def map(f: StatefulRegister[A, MA] => Z): AsmProgram[A, MA, Z] =
|
||||
AsmProgram(a, z |+| f(a))
|
||||
|
||||
def widen[B : Reg]: AsmProgram2[A, MA, B, Unknown, Z] =
|
||||
AsmProgram2(a, ??? : StatefulRegister[B, Unknown], z)
|
||||
|
||||
case class AsmProgram2[A : Reg, MA <: MutationStatus, B : Reg, MB <: MutationStatus, Z : Semigroup](a: StatefulRegister[A, MA], b: StatefulRegister[B, MB], z: Z):
|
||||
def map(f: (StatefulRegister[A, MA], StatefulRegister[B, MB]) => Z): AsmProgram2[A, MA, B, MB, Z] =
|
||||
AsmProgram2(a, b, z |+| f(a, b))
|
||||
|
||||
def widen[C : Reg]: AsmProgram3[A, MA, B, MB, C, Unknown, Z] =
|
||||
AsmProgram3(a, b, ??? : StatefulRegister[C, Unknown], z)
|
||||
|
||||
case class AsmProgram3[A : Reg, MA <: MutationStatus, B : Reg, MB <: MutationStatus, C : Reg, MC <: MutationStatus, Z : Semigroup](a: StatefulRegister[A, MA], b: StatefulRegister[B, MB], c: StatefulRegister[C, MC], z: Z):
|
||||
def map(f: (StatefulRegister[A, MA], StatefulRegister[B, MB], StatefulRegister[C, MC]) => Z): AsmProgram3[A, MA, B, MB, C, MC, Z] =
|
||||
AsmProgram3(a, b, c, z |+| f(a, b, c))
|
@ -0,0 +1,72 @@
|
||||
package com.htmlism.scratchpad
|
||||
|
||||
object Generator extends App:
|
||||
val allLetters =
|
||||
('A' to 'Z')
|
||||
.map(_.toString)
|
||||
|
||||
for (n <- 1 to 22)
|
||||
val classNum =
|
||||
if (n == 1) "" else n
|
||||
|
||||
val letters =
|
||||
allLetters.take(n)
|
||||
|
||||
val typeParametersLong =
|
||||
letters.flatMap { s =>
|
||||
List(s"$s : Reg", s"M$s <: MutationStatus")
|
||||
}
|
||||
.appended("Z : Semigroup")
|
||||
.mkString(", ")
|
||||
|
||||
val typeParametersShort =
|
||||
letters.flatMap { s =>
|
||||
List(s"$s", s"M$s")
|
||||
}
|
||||
.mkString(", ")
|
||||
|
||||
val parameters =
|
||||
letters.map { s =>
|
||||
s"${s.toLowerCase}: StatefulRegister[$s, M$s]"
|
||||
}
|
||||
.appended("z: Z")
|
||||
.mkString(", ")
|
||||
|
||||
val nPlus =
|
||||
n + 1
|
||||
|
||||
val functionArgs =
|
||||
val base =
|
||||
letters.map { s =>
|
||||
s"StatefulRegister[$s, M$s]"
|
||||
}
|
||||
.mkString(", ")
|
||||
|
||||
if (n == 1) base else s"($base)"
|
||||
|
||||
val arguments =
|
||||
letters
|
||||
.map(_.toLowerCase)
|
||||
.mkString(", ")
|
||||
|
||||
val newLetter =
|
||||
allLetters(n)
|
||||
|
||||
println(s"case class AsmProgram$classNum[$typeParametersLong]($parameters):")
|
||||
println(s" def map(f: $functionArgs => Z): AsmProgram$classNum[$typeParametersShort, Z] =")
|
||||
println(s" AsmProgram$classNum($arguments, z |+| f($arguments))")
|
||||
println()
|
||||
println(s" def widen[$newLetter : Reg]: AsmProgram$nPlus[$typeParametersShort, $newLetter, Unknown, Z] =")
|
||||
println(s" AsmProgram$nPlus($arguments, ??? : StatefulRegister[$newLetter, Unknown], z)")
|
||||
println()
|
||||
|
||||
//case class AsmProgram[A : Reg, FA <: MutationStatus, Z : Semigroup](a: StatefulRegister[A, FA], z: Z):
|
||||
// def map(f: StatefulRegister[A, FA] => Z): AsmProgram[A, FA, Z] =
|
||||
// AsmProgram(a, z |+| f(a))
|
||||
//
|
||||
// def widen[B : Reg]: AsmProgram2[A, FA, B, Unknown, Z] =
|
||||
// AsmProgram2(a, ??? : StatefulRegister[B, Unknown], z)
|
||||
//
|
||||
//case class AsmProgram2[A : Reg, FA <: MutationStatus, B: Reg, FB <: MutationStatus, Z : Semigroup](a: StatefulRegister[A, FA], b: StatefulRegister[B, FB], z: Z):
|
||||
// def map(f: (StatefulRegister[A, FA], StatefulRegister[B, FB]) => Z): AsmProgram2[A, FA, B, FB, Z] =
|
||||
// AsmProgram2(a, b, z |+| f(a, b))
|
@ -22,17 +22,6 @@ class Reg[A]
|
||||
object ScratchPad:
|
||||
trait ReadWrite[A] extends Read[A] with Write[A]
|
||||
|
||||
case class AsmProgram[A : Reg, FA <: MutationStatus, Z : Semigroup](a: StatefulRegister[A, FA], z: Z):
|
||||
def map(f: StatefulRegister[A, FA] => Z): AsmProgram[A, FA, Z] =
|
||||
AsmProgram(a, z |+| f(a))
|
||||
|
||||
def widen[B : Reg]: AsmProgram2[A, FA, B, Unknown, Z] =
|
||||
AsmProgram2(a, ??? : StatefulRegister[B, Unknown], z)
|
||||
|
||||
case class AsmProgram2[A : Reg, FA <: MutationStatus, B: Reg, FB <: MutationStatus, Z : Semigroup](a: StatefulRegister[A, FA], b: StatefulRegister[B, FB], z: Z):
|
||||
def map(f: (StatefulRegister[A, FA], StatefulRegister[B, FB]) => Z): AsmProgram2[A, FA, B, FB, Z] =
|
||||
AsmProgram2(a, b, z |+| f(a, b))
|
||||
|
||||
val startA =
|
||||
??? : StatefulRegister[Accumulator, Unknown]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user