Skip to content
Siorki edited this page Mar 27, 2016 · 11 revisions

Environment

RegPack is a packer for Javascript code, initially developed for js1k and mainly targeted at the demoscene for categories up to 4k.

RegPack is written in Javascript and can be run either from a browser or the CLI with Node.js.

Objective

This series of articles are the high-level design document for RegPack. They are a recommended read for :

  • users willing to understand the inner clockwork and get the best from the tool,
  • developers intending to contribute to the project.

Overview

When given a string as input, RegPack performs a series of operations to shorten its size. They can be split into two major phases :

Preprocessing refactors the code to optimize for size and prepare for the packer. The output of this phase is still valid Javascript that can be executed as-is and is semantically equivalent to the original input.

Packing performs lossless compression on the code, producing a string as output. It can only be executed after being unpacked : an short routine is appended that will decode it to the exact program that was provided as input.

Each phase comprises several steps, whose execution is not necessarily linear and may incur branching. This is detailed further in the upcoming pages.

Summary

  • Preprocessor
  • Environment factorization

    Refactoring w/ setInterval() Context method hashing Variable renaming

  • Crusher and packer

    Crusher Packer, character class Packer, negated character class

  • Visualization tools (GUI-only)
  • History and version contents

Current scope

This document was written in April 2016 and covers RegPack up to version 4.0.x. Planned features for major version 5 are mentioned yet may not be covered in details.

Clone this wiki locally