Builds an IR with given Stmts. This method sets the indexes of given Stmts, so client code does not need to set the indexes. @param stmts statements of the IR being built.
(List<Stmt> stmts)
| 141 | * @param stmts statements of the IR being built. |
| 142 | */ |
| 143 | public IR build(List<Stmt> stmts) { |
| 144 | int i = 0; |
| 145 | for (Stmt stmt : stmts) { |
| 146 | stmt.setIndex(i++); |
| 147 | } |
| 148 | return new DefaultIR(method, thisVar, params, returnVars, |
| 149 | vars, stmts, List.of()); |
| 150 | } |
| 151 | |
| 152 | private Var newVar(String name, Type type) { |
| 153 | Var var = new Var(method, name, type, varCounter++); |
no test coverage detected