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.Module

Description

Primitives to emit and parse Binary.Neko bytecode, including instruction definitions.

Synopsis

Documentation

data Module Source #

A Binary.Neko module. Consists of global entities and a list of instructions

Constructors

N 

Fields

Instances

readModule :: ByteString -> Either String Module Source #

Parse module from ByteString. Return module or return an error string

data ModuleHeader Source #

Internal type for module header (counts of entities in the module)

Constructors

ModuleHeader 

Fields

getModuleHeader :: Get ModuleHeader Source #

Pick module header fields from a bytestring. Requires bytestring to start with the first field.

getModule :: Get Module Source #

Get a full module from a bytestring

getModuleContents Source #

Arguments

:: Word32

number of globals

-> Word32

number of fields

-> Word32

code size

-> Get Module

decode module

Parse insides of a module from a bytestring. Bytesting is expected to start with the first section of the module.

getMagicCheck :: Get Bool Source #

A check for next four bytes matching neko magic value

getField :: Get String Source #

Grab a global field from a bytestring

getFields :: Word32 -> Get Hashtbl Source #

Get a list of fields into a hashtable indexed by their hash values

prepStrings :: [String] -> ByteString Source #

Produce a sequence of null-terminated strings

putFields :: Hashtbl -> Put Source #

Generate binary for fields

putModule :: Module -> Put Source #

Generate binary for a module TODO: we are not running any checks on sizes of header fields (like we do while reading), that needs to be implemented, otherwise user will get surprised by Binary.Neko runtime.