mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-11-16 03:07:34 +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 {
|
||||
def toAsm: String = {
|
||||
val commentLine =
|
||||
val groupCommentLine =
|
||||
"; " + comment
|
||||
|
||||
val definitionLines =
|
||||
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")
|
||||
}
|
||||
}
|
||||
@ -75,6 +83,9 @@ class DefinitionGroupContext {
|
||||
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]) {
|
||||
lazy val value: String =
|
||||
implicitly[Operand[A]]
|
||||
|
@ -24,7 +24,7 @@ object ReadWriteLocation {
|
||||
new Definable[ReadWriteLocation[A]] {
|
||||
def toDefinitions(x: ReadWriteLocation[A]): List[Definition[ZeroAddress]] =
|
||||
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]] {
|
||||
def toDefinitions(x: VolatileDevice[A]): List[Definition[ZeroAddress]] =
|
||||
List {
|
||||
Definition(x.name, x.address)
|
||||
Definition(x.name, x.address, "Volatile generator for A values")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user