--- a/scala/abacus.scala Fri Feb 22 14:31:34 2013 +0000
+++ b/scala/abacus.scala Mon Feb 25 15:12:48 2013 +0000
@@ -18,7 +18,9 @@
case class Abacus(p: AProg) {
//simple composition
- def ++ (that: Abacus) = Abacus(this.p ::: that.p)
+ def ++ (that: Abacus) = Abacus(p ::: that.p)
+
+ def :+ (that: Abacus) = this ++ that.shift(p.length, -1)
def shift(offset: Int, jump: Int) = Abacus(p.map(_ match {
case Inc(n) => Inc(n)
@@ -56,5 +58,11 @@
def run(regs: Regs): Regs = run(AConfig(0, regs)).regs
}
+// some syntactical convenience
+object Abacus {
+ def apply(is: AInst*) : Abacus = Abacus(is.toList)
}
+
+}
+