diff --git a/scratchpad/src/main/scala/com/htmlism/scratchpad/Load.scala b/scratchpad/src/main/scala/com/htmlism/scratchpad/Load.scala index 99578da..a61a3aa 100644 --- a/scratchpad/src/main/scala/com/htmlism/scratchpad/Load.scala +++ b/scratchpad/src/main/scala/com/htmlism/scratchpad/Load.scala @@ -9,7 +9,7 @@ trait Load[A]: Asm1Instructions(List(instruction)) // from register - def from[B <: Address: ReadAddress]: Asm2Instructions[A, B] = + def from[B <: Address: ReadByteAddress]: Asm2Instructions[A, B] = Asm2Instructions(List(instruction)) object Load: diff --git a/scratchpad/src/main/scala/com/htmlism/scratchpad/addresses.scala b/scratchpad/src/main/scala/com/htmlism/scratchpad/addresses.scala index a7f293e..4c324d9 100644 --- a/scratchpad/src/main/scala/com/htmlism/scratchpad/addresses.scala +++ b/scratchpad/src/main/scala/com/htmlism/scratchpad/addresses.scala @@ -9,12 +9,21 @@ class ZeroPageAddress(val n: Int, val alias: String) extends Address class AbsoluteAddress(val n: Int, val alias: String) extends Address -sealed trait ReadAddress[A] extends Address +sealed trait ReadByteAddress[A] extends Address -sealed trait WriteAddress[A] extends Address +sealed trait WriteByteAddress[A] extends Address -trait Volatile[A] extends ReadAddress[A] +/** + * To be extended by the address companion object, to signify that this is a volatile resource of length byte + */ +trait VolatileByte[A] extends ReadByteAddress[A] -trait ReadWriteAddress[A] extends ReadAddress[A] with WriteAddress[A] +/** + * To be extended by the address companion object, to signify that this is a read/write resource of length byte + */ +trait ReadWriteByteAddress[A] extends ReadByteAddress[A] with WriteByteAddress[A] -trait WriteOnlyAddress[A] extends WriteAddress[A] +/** + * To be extended by the address companion object, to signify that this is a write-only resource of length byte + */ +trait WriteOnlyByteAddress[A] extends WriteByteAddress[A] diff --git a/scratchpad/src/main/scala/com/htmlism/scratchpad/syntax/package.scala b/scratchpad/src/main/scala/com/htmlism/scratchpad/syntax/package.scala index d77bbf7..54b2ae9 100644 --- a/scratchpad/src/main/scala/com/htmlism/scratchpad/syntax/package.scala +++ b/scratchpad/src/main/scala/com/htmlism/scratchpad/syntax/package.scala @@ -1,14 +1,14 @@ package com.htmlism.scratchpad package object syntax: - implicit class WriteRegisterOps[Addr](reg: WriteAddress[Addr]): + implicit class WriteRegisterOps[Addr](reg: WriteByteAddress[Addr]): def writeConst[A: Loadable](x: A): syntax.PartiallyAppliedWrite[A, Addr] = new syntax.PartiallyAppliedWrite(reg, x) def writeFrom[R: Store]: Asm2[R, Addr] = StoreTo[R, Addr]() - class PartiallyAppliedWrite[Addr: Loadable, A](reg: WriteAddress[A], x: Addr): + class PartiallyAppliedWrite[Addr: Loadable, A](reg: WriteByteAddress[A], x: Addr): def apply[R: Load: Store: Register]: String = val literal = summon[Loadable[Addr]].show(x) diff --git a/scratchpad/src/test/scala/com/htmlism/scratchpad/FeatureSpec.scala b/scratchpad/src/test/scala/com/htmlism/scratchpad/FeatureSpec.scala index da597e0..9862d58 100644 --- a/scratchpad/src/test/scala/com/htmlism/scratchpad/FeatureSpec.scala +++ b/scratchpad/src/test/scala/com/htmlism/scratchpad/FeatureSpec.scala @@ -5,7 +5,7 @@ import org.scalatest.matchers.should._ import com.htmlism.scratchpad.syntax._ -object ExampleRegister extends ZeroPageAddress(0x01, "example") with WriteOnlyAddress[ExampleRegister] +object ExampleRegister extends ZeroPageAddress(0x01, "example") with WriteOnlyByteAddress[ExampleRegister] class ExampleRegister