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

Class Function

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

Represents a function declaration in a Whiley source file. For example: function f(int x) -> (int y) // Parameter must be positive requires x > 0 // Return must be negative ensures y < 0: // body return -x Here, a function f is defined which accepts onl

Source from the content-addressed store, hash-verified

916 *
917 */
918 public static class Function extends FunctionOrMethod {
919
920 public Function(Tuple<Modifier> modifiers, Identifier name, Tuple<Template.Variable> template,
921 Tuple<Decl.Variable> parameters, Tuple<Decl.Variable> returns, Tuple<Expr> requires,
922 Tuple<Expr> ensures, Stmt.Block body) {
923 super(DECL_function, modifiers, name, template, parameters, returns, requires, ensures, body);
924 }
925
926 @Override
927 public WyilFile.Type.Function getType() {
928 return new WyilFile.Type.Function(project(getParameters()),project(getReturns()));
929 }
930
931 @Override
932 @SuppressWarnings("unchecked")
933 public Function clone(Syntactic.Item[] operands) {
934 return new Function((Tuple<Modifier>) operands[0], (Identifier) operands[1],
935 (Tuple<Template.Variable>) operands[2], (Tuple<Decl.Variable>) operands[3],
936 (Tuple<Decl.Variable>) operands[4], (Tuple<Expr>) operands[5], (Tuple<Expr>) operands[6],
937 (Stmt.Block) operands[7]);
938 }
939
940 @Override
941 public String toString() {
942 return "function " + getName() + " : " + getType();
943 }
944
945 public static final Descriptor DESCRIPTOR_0 = new Descriptor(Operands.EIGHT, Data.ZERO, "DECL_function") {
946 @SuppressWarnings("unchecked")
947 @Override
948 public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) {
949 return new Function((Tuple<Modifier>) operands[0], (Identifier) operands[1],
950 (Tuple<Template.Variable>) operands[2], (Tuple<Decl.Variable>) operands[3],
951 (Tuple<Decl.Variable>) operands[4], (Tuple<Expr>) operands[5], (Tuple<Expr>) operands[6],
952 (Stmt.Block) operands[7]);
953 }
954 };
955 }
956
957 /**
958 * <p>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected