jasy.script.optimize package

Submodules

jasy.script.optimize.BlockReducer module

exception jasy.script.optimize.BlockReducer.Error(line)[source]

Bases: Exception

jasy.script.optimize.BlockReducer.cleanParens(node)[source]

Automatically tries to remove superfluous parens which are sometimes added for more clearance and readability but which are not required for parsing and just produce overhead.

jasy.script.optimize.BlockReducer.combineAssignments(condition, thenExpression, elseExpression, compressor)[source]

Combines then and else expression to one assignment when they both assign to the same target node and using the same operator.

jasy.script.optimize.BlockReducer.combineExpressions(condition, thenExpression, elseExpression)[source]

Combines then and else expression using a hook statement.

jasy.script.optimize.BlockReducer.combineToCommaExpression(node)[source]

This method tries to combine a block with multiple statements into one semicolon statement with a comma expression containing all expressions from the previous block. This only works when the block exclusively consists of expressions as this do not work with other statements. Still this conversion reduces the size impact of many blocks and leads to the removal of a lot of curly braces in the result code.

Example: {x++;y+=3} => x++,x+=3

jasy.script.optimize.BlockReducer.compactIf(node, thenPart, condition)[source]

Reduces the size of a if statement (without elsePart) using boolean operators instead of the typical keywords e.g. “if(something)make()” is translated to “something&&make()” which is two characters shorter.

This however only works when the thenPart is only based on expressions and does not contain other statements.

jasy.script.optimize.BlockReducer.containsIf(node)[source]

Checks whether the given node contains another if-statement

jasy.script.optimize.BlockReducer.containsIfElse(node)[source]

Checks whether the given node contains another if-else-statement

jasy.script.optimize.BlockReducer.createHook(condition, thenPart, elsePart)[source]

Creates a hook expression with the given then/else parts.

jasy.script.optimize.BlockReducer.createReturn(value)[source]

Creates a return statement with the given value.

jasy.script.optimize.BlockReducer.endsWithReturnOrThrow(node)[source]

Used by the automatic elsePart removal logic to find out whether the given node ends with a return or throw which is bascially the allowance to remove the else keyword as this is not required to keep the logic intact.

jasy.script.optimize.BlockReducer.fixParens(node)[source]

Automatically wraps the given node into parens when it was moved into another block and is not parsed there in the same way as it was the case previously.

The method needs to be called after the node has been moved to the target node.

jasy.script.optimize.BlockReducer.mergeParts(node, thenPart, elsePart, condition, compressor)[source]

Merges if statement with a elsePart using a hook. Supports two different ways of doing this: using a hook expression outside, or using a hook expression inside an assignment.

Example: if(test) first(); else second() => test ? first() : second(); if(foo) x=1; else x=2 => x = foo ? 1 : 2;

jasy.script.optimize.BlockReducer.optimize(node)[source]
jasy.script.optimize.BlockReducer.reworkElse(node, elsePart)[source]

If an if ends with a return/throw we are able to inline the content of the else to the same parent as the if resides into.

This method deals with all the nasty details of this operation.

jasy.script.optimize.ClosureWrapper module

jasy.script.optimize.ClosureWrapper.optimize(node)[source]

jasy.script.optimize.CombineDeclarations module

exception jasy.script.optimize.CombineDeclarations.Error(line)[source]

Bases: Exception

jasy.script.optimize.CombineDeclarations.optimize(node)[source]

jasy.script.optimize.CryptPrivates module

exception jasy.script.optimize.CryptPrivates.Error(name, line)[source]

Bases: Exception

jasy.script.optimize.CryptPrivates.optimize(node, contextId='')[source]

jasy.script.optimize.LocalVariables module

exception jasy.script.optimize.LocalVariables.Error(name, line)[source]

Bases: Exception

jasy.script.optimize.LocalVariables.optimize(node)[source]

Node to optimize with the global variables to ignore as names.

jasy.script.optimize.Translation module

jasy.script.optimize.Translation.hasText(node)[source]
jasy.script.optimize.Translation.optimize(node, translation)[source]
jasy.script.optimize.Translation.collectTranslations(node)[source]

Module contents