+toRealByteCode :: (ByteCode a b) -> (String, BCState)
+toRealByteCode x
+# (bc, st) = runBC x zero
+= (concat $ map (toString o map makeSafe o toByteVal) bc, st)
+
+readable :: BC -> String
+readable (BCPush d) = "BCPush " +++ concat (map safe d)
+ where
+ safe c
+ | isControl c = "\\d" +++ toString (toInt c)
+ = toString c
+readable b = printToString b
+
+toReadableByteCode :: (ByteCode a b) -> (String, BCState)
+toReadableByteCode x
+# (bc, st) = runBC x zero
+= (join "\n" $ map readable bc, st)
+
+//Start :: String
+//Start = toReadableByteCode bc
+// where
+// bc :: ByteCode Int Expr
+// bc = (lit 36 +. lit 42) +. lit 44
+getSDSBytes :: BCState -> String
+getSDSBytes {sdss} = concat $ map sd sdss
+ where sd (i, v) = "s" +++ toString (toChar i) +++ toString v +++ "\n"
+
+getTaskBytes :: Int String -> String
+getTaskBytes i b = "t" +++ to16bit i +++ to16bit (size b) +++ b
+//
+Start = getSDSBytes (snd bc`) +++ getTaskBytes 400 (fst bc`)
+//Start = fst $ toReadableByteCode $ unMain bc
+ where
+ bc` = toRealByteCode (unMain bc)
+ bc :: Main (ByteCode Int Stmt)
+ bc = sds \x=41 In
+ {main = x =. x +. lit 1 :. pub x}
+
+pub :: (ByteCode a b) -> ByteCode a b
+pub x = fmp makePub x