org.mozilla.javascript

Class Decompiler

public class Decompiler extends Object

Field Summary
static intCASE_GAP_PROP
Decompilation property to specify identation offset for case labels.
static intINDENT_GAP_PROP
Decompilation property to specify default identation offset.
static intINITIAL_INDENT_PROP
Decompilation property to specify initial ident value.
static intONLY_BODY_FLAG
Flag to indicate that the decompilation should omit the function header and trailing brace.
static intTO_SOURCE_FLAG
Flag to indicate that the decompilation generates toSource result.
Method Summary
static Stringcompress(String encodedSource, int flags, UintMap properties, ScriptOrFnNode parseTree)
Compress the script

static Stringdecompile(String source, int flags, UintMap properties)
Decompile the source information associated with this js function/script back into a string.

Field Detail

CASE_GAP_PROP

public static final int CASE_GAP_PROP
Decompilation property to specify identation offset for case labels.

INDENT_GAP_PROP

public static final int INDENT_GAP_PROP
Decompilation property to specify default identation offset.

INITIAL_INDENT_PROP

public static final int INITIAL_INDENT_PROP
Decompilation property to specify initial ident value.

ONLY_BODY_FLAG

public static final int ONLY_BODY_FLAG
Flag to indicate that the decompilation should omit the function header and trailing brace.

TO_SOURCE_FLAG

public static final int TO_SOURCE_FLAG
Flag to indicate that the decompilation generates toSource result.

Method Detail

compress

public static String compress(String encodedSource, int flags, UintMap properties, ScriptOrFnNode parseTree)
Compress the script

Parameters: encodedSource encoded source string flags Flags specifying format of decompilation output properties Decompilation properties parseTree Mapping for each function node and corresponding parameters & variables names

Returns: compressed script

decompile

public static String decompile(String source, int flags, UintMap properties)
Decompile the source information associated with this js function/script back into a string. For the most part, this just means translating tokens back to their string representations; there's a little bit of lookahead logic to decide the proper spacing/indentation. Most of the work in mapping the original source to the prettyprinted decompiled version is done by the parser.

Parameters: source encoded source tree presentation flags flags to select output format properties indentation properties