Encode bytecode version in first byte of binary
This commit is contained in:
parent
29e5f97dae
commit
11500fefed
1 changed files with 4 additions and 1 deletions
|
|
@ -18,6 +18,9 @@ import Compiler
|
|||
|
||||
type Bytecode = BL.ByteString
|
||||
|
||||
version1 :: Bu.Builder
|
||||
version1 = P.execPut $ B.putWord8 1
|
||||
|
||||
toBinary :: Command -> P.Put
|
||||
toBinary (Const i) = do
|
||||
P.putWord8 0x0001
|
||||
|
|
@ -28,4 +31,4 @@ toBinary Mult = P.putWord8 0x0006
|
|||
toBinary Div = P.putWord8 0x0007
|
||||
|
||||
assemble :: [Command] -> Bytecode
|
||||
assemble cmds = Bu.toLazyByteString $ mconcat (map (P.execPut . toBinary) cmds)
|
||||
assemble cmds = Bu.toLazyByteString $ mconcat $ version1:map (P.execPut . toBinary) cmds
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue