neko-lib-0.0.1.0: Neko VM code generation and disassembly library

Copyright(c) Petr Penzin 2015
LicenseBSD2
Maintainerpenzin.dev@gmail.com
Stabilityexperimental
Portabilitycross-platform
Safe HaskellSafe
LanguageHaskell98

Binary.Neko.Instructions

Description

Types and primitives to deal with Binary.Neko instructions

Synopsis

Documentation

readInstructions Source #

Arguments

:: Word32

code size

-> Hashtbl

context (names of fields)

-> ByteString

bytes to read from

-> (ByteString, String, Maybe [Instruction])

unconsumed input, status message and list of instructions

Read instructions Consume bytestring, produce instructions and status message

readInstruction Source #

Arguments

:: Hashtbl

Names of fieds for the module

-> ByteString

Input

-> (Maybe Instruction, ByteString)

Result or nothing, unconsumed input

Read a single bytecode instruction

getInstructions Source #

Arguments

:: Word32

code size - number of instructions+arguments left to parse

-> Hashtbl

Builtins hashtable to provide context

-> Get [Instruction]

decoder

Grab instructions from a bytestring Decode bytestring, consuming one byte per instruction with no paramenters and two for instructions with parameters

getInstruction Source #

Arguments

:: Hashtbl

Builtins hashtable for getting names

-> Get Instruction

Instruction parser

Grab a single instruction from a bytestring Some instruction acces filds by using hashes of the names, therefore require a hash table with field names.

getOp Source #

Arguments

:: Word8

Operation number

-> Maybe Int32

Additional argument

-> Hashtbl

Some instructions require access to builtins hashtable

-> Get Instruction

Instruction parser

Second level of instruction read logic

opcode Source #

Arguments

:: Instruction

Instruction to process

-> (Word8, Maybe Word32)

Opcode and additional argument

Get integer opcode

putInstruction :: Instruction -> Put Source #

Write instruction out using Put monad

putInstructions :: [Instruction] -> Put Source #

Write a few instructions out using Put monad

hasParam :: Instruction -> Bool Source #

Determine whether instruction has a parameter