NAME ^

Parrot::PackFile - A Parrot Bytecode File

SYNOPSIS ^

  use Parrot::PackFile;

DESCRIPTION ^

Parrot::PackFile contains all the functions required to process a Parrot bytecode file. It is not intended to understand the contents of the bytecode file's segments, but merely to dissect and reconstruct data from the various segments. See docs/parrotbyte.pod for information about the structure of the frozen bycode.

Class Methods ^

new()

Returns a new instance.

Instance Methods ^

magic()

Get the magic number.

wordsize()

Returns the packfiles wordsize.

byteorder()

Returns the packfiles byte order.

major()

Returns the packfiles major version number.

minor()

Returns the packfiles minor version number.

flags()

Returns the packfiles flags.

pad()

Returns an MD5 hex fingerprint of the ops.

floattype()

Returns the packfiles float type.

opcodetype()

Returns the packfiles opcode type.

fixup_table()

Returns an instance of Parrot::PackFile::FixupTable.

const_table()

Returns an instance of Parrot::PackFile::ConstTable.

byte_code($code)

byte_code()

Gets/sets the byte code.

unpack($string)

Unpack the contents from the string.

    Magic: 4-byte signed integer
    Fixup: 4-byte length N + N bytes
    Const: 4-byte length N + N bytes
    BCode: N bytes
TODO - Now that we have a portable bytecode format, with file specified wordsize, this routine is inherently broken since it uses the native sizes.

unpack_filehandle($filehandle)

Unpack the contents from the filehandle.

unpack_file($file)

Unpack the contents from the named file.

pack()

Pack the contents to a string.

pack_filehandle($filehandle)

Pack the contents to a string and write it to the filehandle.

pack_file($file)

Pack the contents to a string and write it to the named file.

SEE ALSO ^

Parrot::PackFile::ConstTable

Parrot::PackFile::Constant

Parrot::PackFile::FixupTable

build_tools/pbc2c.pl

HISTORY ^

Author: Gregor N. Purdy <gregor@focusresearch.com>

Gregor writes:

"Packfile" is a proposed term based on the fact that the file contains more than just byte code, and another language (Java) calls its binary files by a broader notion of what's in them (Class Files). Since Perl has packages, and since we use pack() to write them, we'll call them PackFiles (at least for now).

That does, however, beg the question of file extension. Should we name the files "foo.pack" instead of "foo.pbc"?


parrot