Global

Methods

arrayConstantFolding(code, args) → {string}

Does constant folding on Array operations.
Parameters:
Name Type Description
code Object an AST node containing the expression statement
args Array arguments used on the function call. I.E. for [1].concat('d', 'e'), args = ['d', 'e']
Source:
Returns:
the resulting js code to be used by escodegen
Type
string

binaryConstantFolding(n)

Does ConstantFolding on binaryExpression nodes. I.E. turns 2+3 into 5.
Parameters:
Name Type Description
n Object an AST node representing a binaryExpression.
Source:

constantFolding(code) → {string}

A function that does constant folding onto the code it receives
Parameters:
Name Type Description
code string A string containing the code to do the constant folding on
Source:
Returns:
Returns the resulting code
Type
string

getValue(node) → {*}

Extracts the "value" of an AST node, it being its id, raw value, or array of elements
Parameters:
Name Type Description
node Object
Source:
Returns:
the value contained in the node
Type
*

isConstant(code) → {bool}

Checks if an AST node's info is of constant nature
Parameters:
Name Type Description
code Object to be checked
Source:
Returns:
Type
bool

newArrayNode(array) → {Object}

Translates a js Array into an AST node containing its information
Parameters:
Name Type Description
array Array to be translated
Source:
Returns:
the resulting AST node
Type
Object

newNode(literal) → {Object}

Creates a new AST node containing the info received
Parameters:
Name Type Description
literal string to be assigned as value of the node
Source:
Returns:
the resulting AST node
Type
Object