aboutsummaryrefslogtreecommitdiff
path: root/src/reduce
AgeCommit message (Collapse)Author
2024-02-26compiler: JIT zig reduceAndrew Kelley
See #19063
2023-11-24frontend: move BuiltinFn to std.zig namespaceMeghan Denny
2023-11-07Apply same reductions to whileAdam Goertz
2023-11-06zig-reduce: Reduce `if` expressionsAdam Goertz
Perform these transformations in this priority order: 1. If the `else` expression is missing or an empty block, replace the condition with `if (true)` if it is not already. 2. If the `then` block is empty, replace the condition with `if (false)` if it is not already. 3. If the condition is `if (true)`, replace the `if` expression with the contents of the `then` expression. 4. If the condition is `if (false)`, replace the `if` expression with the contents of the `else` expression.
2023-11-04zig reduce: add reduction for removing var declsAndrew Kelley
2023-11-04zig reduce: don't try to remove discard statementsAndrew Kelley
those are handled separately
2023-11-04zig reduce: delete statements from blocksAndrew Kelley
2023-11-04zig reduce: add transformation for removing container fieldsAndrew Kelley
2023-11-04zig reduce: run results through astgenAndrew Kelley
and use that to fix up usused variable declarations and parameters that are caused by transformations. also add a transformation to replace global variable init with `undefined`.
2023-11-04zig reduce: rename identifiers when inlining an `@import`Andrew Kelley
2023-11-04zig reduce: add transformation for inlining file-based `@import`Andrew Kelley
One thing is missing for it to be useful, however, which is dealing with ambiguous reference errors introduced by the inlining process.
2023-11-03zig reduce: add transformation of replacing var init with undefinedAndrew Kelley
2023-11-03zig reduce: add "delete unused globals" transformAndrew Kelley
While walking the AST looking for reductions, notice if any globals are unreferenced, and if they are, add a transformation for removing the global.
2023-11-03zig reduce: redesignAndrew Kelley
Now it works like this: 1. Walk the AST of the source file looking for independent reductions and collecting them all into an array list. 2. Randomize the list of transformations. A future enhancement will add priority weights to the sorting but for now they are completely shuffled. 3. Apply a subset consisting of 1/2 of the transformations and check for interestingness. 4. If not interesting, half the subset size again and check again. 5. Repeat until the subset size is 1, then march the transformation index forward by 1 with each non-interesting attempt. At any point if a subset of transformations succeeds in producing an interesting result, restart the whole process, reparsing the AST and re-generating the list of all possible transformations and shuffling it again. As for std.zig.render, the fixups operate based on AST Node Index rather than Nth index of the function occurence. This allows precise control over how to mutate the input.