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

Class Constant

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

Represents the use of a constant within some expression. For example, in x + 1 the expression 1 is a constant expression. @author David J. Pearce

Source from the content-addressed store, hash-verified

2706 *
2707 */
2708 public static class Constant extends AbstractExpr implements Expr {
2709 public Constant(Type type, Value value) {
2710 super(EXPR_constant, type, value);
2711 }
2712
2713 public Value getValue() {
2714 return (Value) get(1);
2715 }
2716
2717 @Override
2718 public Constant clone(Syntactic.Item[] operands) {
2719 return new Constant((Type) operands[0], (Value) operands[1]);
2720 }
2721
2722 @Override
2723 public String toString() {
2724 return getValue().toString();
2725 }
2726
2727 public static final Descriptor DESCRIPTOR_0 = new Descriptor(Operands.TWO, Data.ZERO, "EXPR_constant") {
2728 @Override
2729 public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) {
2730 return new Constant((Type) operands[0], (Value) operands[1]);
2731 }
2732 };
2733 }
2734
2735 /**
2736 * Represents the use of a static variable within an expression. A static

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected