simplify iterators

This commit is contained in:
Mark Canlas 2020-08-15 17:34:33 -04:00
parent 6d5da43684
commit 00575f46f7
2 changed files with 7 additions and 12 deletions

View File

@ -15,7 +15,6 @@
## TODO
- assembly doc w/ define support
- label region as assembly doc
- add mapping support
- postfix operations to accumulator values
- loops

View File

@ -24,13 +24,11 @@ package object dsl {
}
def enum[A](implicit ctx: AsmDocumentContext, ev: EnumAsm[A]): Unit = {
val (_, xs) =
val xs =
ev.all
.map(ev.label)
.foldLeft(0 -> List.empty[(String, Int)]) {
case ((next, acc), s) =>
(next + 1) -> (acc :+ (s -> next))
}
.toList
.zip(List.iterate(0, ev.all.size)(_ + 1))
val grp =
DefinitionGroup(
@ -47,13 +45,11 @@ package object dsl {
}
def bitField[A](implicit ctx: AsmDocumentContext, ev: BitField[A]): Unit = {
val (_, xs) =
val xs =
ev.all
.map(ev.label)
.foldLeft(1 -> List.empty[(String, Int)]) {
case ((next, acc), s) =>
(next << 1) -> (acc :+ (s -> next))
}
.toList
.zip(List.iterate(1, ev.all.size)(_ << 1))
val grp =
DefinitionGroup(