Class IRRewriter
java.lang.Object
org.ek9lang.compiler.ir.support.IRRewriter
THE IR rewriter: rebuilds an instruction list bottom-up. Every composite is rebuilt with its rewritten nested lists
(
CompositeInstr.withNestedLists(UnaryOperator)), then every instruction - composite or not - is given to the rewrite, which
returns what replaces it (itself, nothing, or several). Instructions are immutable, so this is how any pass changes
IR: the ownership lowering now, the IR_OPTIMISATION passes later. Nothing unchanged is copied: an untouched list
comes back as the same list.-
Method Summary
Modifier and TypeMethodDescriptionRewrite an instruction list; the same list when nothing in it (at any depth) changed.static voidRewrite an operation's body in place (the operation takes the rebuilt body, or keeps its own when nothing changed).rewriteLists(List<IRInstr> instructions, UnaryOperator<List<IRInstr>> listRewrite) Rewrite a list and every list nested in it, bottom-up;listRewritereturns its argument unchanged (the same list) when it changes nothing.static voidrewriteLists(OperationInstr operation, UnaryOperator<List<IRInstr>> listRewrite) Rewrite an operation's body list by list: every nested list first (bottom-up), then the list that holds it.
-
Method Details
-
rewrite
Rewrite an operation's body in place (the operation takes the rebuilt body, or keeps its own when nothing changed). -
rewrite
-
rewriteLists
Rewrite an operation's body list by list: every nested list first (bottom-up), then the list that holds it. For a pass that needs to see a whole list at once - one instruction's replacement depending on what follows it in the same list. -
rewriteLists
-