mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-09-27 21:55:33 +00:00
add resource comments
This commit is contained in:
parent
f432fdc767
commit
cfb6bbbc92
@ -50,14 +50,22 @@ case class Subroutine(name: String, fragment: AsmFragment, jumpRegistry: ListSet
|
|||||||
|
|
||||||
case class DefinitionGroup(comment: String, xs: List[Definition[_]]) extends TopLevelAsmDocumentFragment {
|
case class DefinitionGroup(comment: String, xs: List[Definition[_]]) extends TopLevelAsmDocumentFragment {
|
||||||
def toAsm: String = {
|
def toAsm: String = {
|
||||||
val commentLine =
|
val groupCommentLine =
|
||||||
"; " + comment
|
"; " + comment
|
||||||
|
|
||||||
val definitionLines =
|
val definitionLines =
|
||||||
xs
|
xs
|
||||||
.map(d => f"define ${d.name}%-20s${d.value}")
|
.map { d =>
|
||||||
|
d.comment match {
|
||||||
|
case Some(c) =>
|
||||||
|
f"define ${d.name}%-20s${d.value} ; $c"
|
||||||
|
|
||||||
(commentLine :: definitionLines)
|
case None =>
|
||||||
|
f"define ${d.name}%-20s${d.value}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(groupCommentLine :: definitionLines)
|
||||||
.mkString("\n")
|
.mkString("\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,6 +83,9 @@ class DefinitionGroupContext {
|
|||||||
DefinitionGroup(s, xs.toList)
|
DefinitionGroup(s, xs.toList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param comment Typically used by resources to describe their type safety
|
||||||
|
*/
|
||||||
case class Definition[A: Operand](name: String, x: A, comment: Option[String]) {
|
case class Definition[A: Operand](name: String, x: A, comment: Option[String]) {
|
||||||
lazy val value: String =
|
lazy val value: String =
|
||||||
implicitly[Operand[A]]
|
implicitly[Operand[A]]
|
||||||
|
@ -24,7 +24,7 @@ object ReadWriteLocation {
|
|||||||
new Definable[ReadWriteLocation[A]] {
|
new Definable[ReadWriteLocation[A]] {
|
||||||
def toDefinitions(x: ReadWriteLocation[A]): List[Definition[ZeroAddress]] =
|
def toDefinitions(x: ReadWriteLocation[A]): List[Definition[ZeroAddress]] =
|
||||||
List {
|
List {
|
||||||
Definition(x.name, x.address)
|
Definition(x.name, x.address, "Read/write location for A values")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ object VolatileDevice {
|
|||||||
new Definable[VolatileDevice[A]] {
|
new Definable[VolatileDevice[A]] {
|
||||||
def toDefinitions(x: VolatileDevice[A]): List[Definition[ZeroAddress]] =
|
def toDefinitions(x: VolatileDevice[A]): List[Definition[ZeroAddress]] =
|
||||||
List {
|
List {
|
||||||
Definition(x.name, x.address)
|
Definition(x.name, x.address, "Volatile generator for A values")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user