MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / DoWhile

Class DoWhile

src/main/java/wyil/lang/WyilFile.java:2062–2107  ·  view source on GitHub ↗

Represents a do-while statement whose body is made up from a block of statements separated by indentation. As an example: function sum([int] xs) -> int requires |xs| > 0: int r = 0 int i = 0 do: r = r + xs[i] i = i + 1 while i < |xs| where i >= 0 return r <p

Source from the content-addressed store, hash-verified

2060 *
2061 */
2062 public static class DoWhile extends AbstractItem implements Loop {
2063 public DoWhile(Expr condition, Tuple<Expr> invariant, Tuple<Decl.Variable> modified, Stmt.Block body) {
2064 super(STMT_dowhile, condition, invariant, modified, body);
2065 }
2066
2067 public Expr getCondition() {
2068 return (Expr) super.get(0);
2069 }
2070
2071 @Override
2072 @SuppressWarnings("unchecked")
2073 public Tuple<Expr> getInvariant() {
2074 return (Tuple<Expr>) super.get(1);
2075 }
2076
2077 @Override
2078 @SuppressWarnings("unchecked")
2079 public Tuple<Decl.Variable> getModified() {
2080 return (Tuple<Decl.Variable>) super.get(2);
2081 }
2082
2083 public void setModified(Tuple<Decl.Variable> modified) {
2084 operands[2] = modified;
2085 }
2086
2087 @Override
2088 public Stmt.Block getBody() {
2089 return (Stmt.Block) super.get(3);
2090 }
2091
2092 @SuppressWarnings("unchecked")
2093 @Override
2094 public Syntactic.Item clone(Syntactic.Item[] operands) {
2095 return new DoWhile((Expr) operands[0], (Tuple<Expr>) operands[1], (Tuple<Decl.Variable>) operands[2],
2096 (Stmt.Block) operands[3]);
2097 }
2098
2099 public static final Descriptor DESCRIPTOR_0 = new Descriptor(Operands.FOUR, Data.ZERO, "STMT_dowhile") {
2100 @SuppressWarnings("unchecked")
2101 @Override
2102 public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) {
2103 return new DoWhile((Expr) operands[0], (Tuple<Expr>) operands[1],
2104 (Tuple<Decl.Variable>) operands[2], (Stmt.Block) operands[3]);
2105 }
2106 };
2107 }
2108
2109 /**
2110 * Represents a fail statement for the form "<code>fail</code>". This causes an

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected