mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-12-29 08:29:54 +00:00
use generated code instead
This commit is contained in:
parent
304dbbed19
commit
d89f7a3e87
@ -15,7 +15,7 @@ object CodeGenerator extends App:
|
|||||||
val typeParameterList =
|
val typeParameterList =
|
||||||
letters.mkString(", ")
|
letters.mkString(", ")
|
||||||
|
|
||||||
println(s"trait Asm$n[$typeParameterList]:")
|
println(s"sealed trait Asm$n[$typeParameterList]:")
|
||||||
println(" def xs: List[String]")
|
println(" def xs: List[String]")
|
||||||
println
|
println
|
||||||
println(" def oComment: Option[String]")
|
println(" def oComment: Option[String]")
|
||||||
@ -38,7 +38,7 @@ object CodeGenerator extends App:
|
|||||||
println(" copy(oComment = Some(s))")
|
println(" copy(oComment = Some(s))")
|
||||||
println
|
println
|
||||||
println(
|
println(
|
||||||
s"case class Asm${n}Instructions[$typeParameterList](xs: List[String], oComment: Option[String]) extends Asm${n}[$typeParameterList]:"
|
s"case class Asm${n}Instructions[$typeParameterList](xs: List[String], oComment: Option[String] = None) extends Asm${n}[$typeParameterList]:"
|
||||||
)
|
)
|
||||||
println(s" def comment(s: String): Asm$n[$typeParameterList] =")
|
println(s" def comment(s: String): Asm$n[$typeParameterList] =")
|
||||||
println(" copy(oComment = Some(s))")
|
println(" copy(oComment = Some(s))")
|
||||||
|
@ -3,18 +3,47 @@ package com.htmlism.scratchpad
|
|||||||
sealed trait Asm1[A]:
|
sealed trait Asm1[A]:
|
||||||
def xs: List[String]
|
def xs: List[String]
|
||||||
|
|
||||||
def widenWith[B]: Asm2[A, B] =
|
def oComment: Option[String]
|
||||||
Asm2Instructions(xs)
|
|
||||||
|
|
||||||
case class Asm1Instructions[A](xs: List[String]) extends Asm1[A]
|
def comment(s: String): Asm1[A]
|
||||||
|
|
||||||
|
def andThen(that: Asm1[A]): Asm1[A] =
|
||||||
|
AndThen1[A](this, that, None)
|
||||||
|
|
||||||
|
def widenWith[B]: Asm2[A, B] =
|
||||||
|
Asm2Instructions(xs, oComment)
|
||||||
|
|
||||||
|
case class AndThen1[A](left: Asm1[A], right: Asm1[A], oComment: Option[String]) extends Asm1[A]:
|
||||||
|
def xs: List[String] =
|
||||||
|
left.xs ++ right.xs
|
||||||
|
|
||||||
|
def comment(s: String): Asm1[A] =
|
||||||
|
copy(oComment = Some(s))
|
||||||
|
|
||||||
|
case class Asm1Instructions[A](xs: List[String], oComment: Option[String] = None) extends Asm1[A]:
|
||||||
|
def comment(s: String): Asm1[A] =
|
||||||
|
copy(oComment = Some(s))
|
||||||
|
|
||||||
sealed trait Asm2[A, B]:
|
sealed trait Asm2[A, B]:
|
||||||
def xs: List[String]
|
def xs: List[String]
|
||||||
|
|
||||||
def andThen(that: Asm2[A, B]): Asm2[A, B] =
|
def oComment: Option[String]
|
||||||
AndThen2(this, that)
|
|
||||||
|
|
||||||
case class Asm2Instructions[A, B](xs: List[String]) extends Asm2[A, B]:
|
def comment(s: String): Asm2[A, B]
|
||||||
|
|
||||||
|
def andThen(that: Asm2[A, B]): Asm2[A, B] =
|
||||||
|
AndThen2[A, B](this, that, None)
|
||||||
|
|
||||||
|
case class AndThen2[A, B](left: Asm2[A, B], right: Asm2[A, B], oComment: Option[String]) extends Asm2[A, B]:
|
||||||
|
def xs: List[String] =
|
||||||
|
left.xs ++ right.xs
|
||||||
|
|
||||||
|
def comment(s: String): Asm2[A, B] =
|
||||||
|
copy(oComment = Some(s))
|
||||||
|
|
||||||
|
case class Asm2Instructions[A, B](xs: List[String], oComment: Option[String] = None) extends Asm2[A, B]:
|
||||||
|
def comment(s: String): Asm2[A, B] =
|
||||||
|
copy(oComment = Some(s))
|
||||||
// TODO not tested
|
// TODO not tested
|
||||||
// B type needs to be a class type, with evidence, not a case class
|
// B type needs to be a class type, with evidence, not a case class
|
||||||
def swap[AA, BB](f: (R[A], R[B]) => (R[AA], R[BB])): Asm2Instructions[AA, BB] =
|
def swap[AA, BB](f: (R[A], R[B]) => (R[AA], R[BB])): Asm2Instructions[AA, BB] =
|
||||||
@ -24,10 +53,6 @@ object Asm2Instructions:
|
|||||||
def from[A, B](t2: (R[A], R[B]), xs: List[String]) =
|
def from[A, B](t2: (R[A], R[B]), xs: List[String]) =
|
||||||
Asm2Instructions[A, B](xs)
|
Asm2Instructions[A, B](xs)
|
||||||
|
|
||||||
case class AndThen2[A, B](x: Asm2[A, B], y: Asm2[A, B]) extends Asm2[A, B]:
|
|
||||||
def xs: List[String] =
|
|
||||||
x.xs ++ y.xs
|
|
||||||
|
|
||||||
trait Asm3[A, B, C]:
|
trait Asm3[A, B, C]:
|
||||||
def xs: List[String]
|
def xs: List[String]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user