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

Class While

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

Represents a while statement made up a condition and a block of statements referred to as the body . The following illustrates: function sum([int] xs) -> int: int r = 0 int i = 0 while i < |xs| where i >= 0: r = r + xs[i] i = i + 1 return r The optio

Source from the content-addressed store, hash-verified

2491 *
2492 */
2493 public static class While extends AbstractItem implements Loop {
2494 public While(Expr condition, Tuple<Expr> invariant, Tuple<Decl.Variable> modified, Stmt.Block body) {
2495 super(STMT_while, condition, invariant, modified, body);
2496 }
2497
2498 public Expr getCondition() {
2499 return (Expr) super.get(0);
2500 }
2501
2502 @Override
2503 @SuppressWarnings("unchecked")
2504 public Tuple<Expr> getInvariant() {
2505 return (Tuple<Expr>) super.get(1);
2506 }
2507
2508 @Override
2509 @SuppressWarnings("unchecked")
2510 public Tuple<Decl.Variable> getModified() {
2511 return (Tuple<Decl.Variable>) super.get(2);
2512 }
2513
2514 public void setModified(Tuple<Decl.Variable> modified) {
2515 operands[2] = modified;
2516 }
2517
2518 @Override
2519 public Stmt.Block getBody() {
2520 return (Stmt.Block) super.get(3);
2521 }
2522
2523 @SuppressWarnings("unchecked")
2524 @Override
2525 public Syntactic.Item clone(Syntactic.Item[] operands) {
2526 return new While((Expr) operands[0], (Tuple<Expr>) operands[1], (Tuple<Decl.Variable>) operands[2],
2527 (Stmt.Block) operands[3]);
2528 }
2529
2530 public static final Descriptor DESCRIPTOR_0 = new Descriptor(Operands.FOUR, Data.ZERO, "STMT_while") {
2531 @SuppressWarnings("unchecked")
2532 @Override
2533 public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) {
2534 return new While((Expr) operands[0], (Tuple<Expr>) operands[1],
2535 (Tuple<Decl.Variable>) operands[2], (Stmt.Block) operands[3]);
2536 }
2537 };
2538 }
2539 }
2540
2541 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected