Represents a for statement made up of variable initialisers and a block of statements referred to as the body . The following illustrates: function sum(int[] xs) -> int: int r = 0 for i in 0..|xs|: r = r + xs[i] return r @author David J. Pearce
| 2146 | * |
| 2147 | */ |
| 2148 | public static class For extends AbstractItem implements Loop { |
| 2149 | public For(Decl.StaticVariable var, Tuple<Expr> invariant, Tuple<Decl.Variable> modified, Stmt.Block trueBranch) { |
| 2150 | super(STMT_for, var, invariant, modified, trueBranch); |
| 2151 | } |
| 2152 | |
| 2153 | @Override |
| 2154 | public Syntactic.Item clone(Syntactic.Item[] operands) { |
| 2155 | return new For((Decl.StaticVariable) operands[0], (Tuple<Expr>) operands[1], (Tuple<Decl.Variable>) operands[2], (Stmt.Block) operands[2]); |
| 2156 | } |
| 2157 | |
| 2158 | public Decl.StaticVariable getVariable() { |
| 2159 | return (Decl.StaticVariable) operands[0]; |
| 2160 | } |
| 2161 | |
| 2162 | @Override |
| 2163 | public Tuple<Expr> getInvariant() { |
| 2164 | return (Tuple<Expr>) operands[1]; |
| 2165 | } |
| 2166 | |
| 2167 | @Override |
| 2168 | public Tuple<Decl.Variable> getModified() { |
| 2169 | return (Tuple<Decl.Variable>)operands[2]; |
| 2170 | } |
| 2171 | |
| 2172 | public void setModified(Tuple<Decl.Variable> modified) { |
| 2173 | operands[2] = modified; |
| 2174 | } |
| 2175 | |
| 2176 | @Override |
| 2177 | public Stmt.Block getBody() { |
| 2178 | return (Stmt.Block) operands[3]; |
| 2179 | } |
| 2180 | |
| 2181 | public static final Descriptor DESCRIPTOR_0 = new Descriptor(Operands.FOUR, Data.ZERO, "STMT_for") { |
| 2182 | @Override |
| 2183 | public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) { |
| 2184 | return new For((Decl.StaticVariable) operands[0], (Tuple<Expr>) operands[1], (Tuple<Decl.Variable>) operands[2], (Stmt.Block) operands[2]); |
| 2185 | } |
| 2186 | }; |
| 2187 | } |
| 2188 | |
| 2189 | /** |
| 2190 | * <p> |
nothing calls this directly
no outgoing calls
no test coverage detected