Package: TupleInfo

TupleInfo

nameinstructionbranchcomplexitylinemethod
TupleInfo(boolean, List)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
consCheckExp(String, String, String, NameGen)
M: 0 C: 100
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 12
100%
M: 0 C: 1
100%
getLeafTypesRecursively()
M: 23 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package org.overture.codegen.vdm2jml.predgen.info;
2:
3: import java.util.LinkedList;
4: import java.util.List;
5:
6: import org.overture.codegen.vdm2jml.JmlGenerator;
7: import org.overture.codegen.vdm2jml.runtime.V2J;
8: import org.overture.codegen.vdm2jml.util.NameGen;
9:
10: public class TupleInfo extends AbstractTypeInfo
11: {
12:         public static final String IS_TUP_METHOD_NAME = "isTup";
13:         public static final String GET_FIELD_METHOD_NAME = "field";
14:
15:         private List<AbstractTypeInfo> types;
16:
17:         public TupleInfo(boolean optional, List<AbstractTypeInfo> types)
18:         {
19:                 super(optional);
20:                 this.types = types;
21:         }
22:
23:         @Override
24:         public List<LeafTypeInfo> getLeafTypesRecursively()
25:         {
26:                 List<LeafTypeInfo> leaves = new LinkedList<>();
27:
28:•                for (AbstractTypeInfo t : types)
29:                 {
30:                         leaves.addAll(t.getLeafTypesRecursively());
31:                 }
32:
33:                 return leaves;
34:         }
35:
36:         @Override
37:         public String consCheckExp(String enclosingClass, String javaRootPackage,
38:                         String arg, NameGen nameGen)
39:         {
40:                 StringBuilder sb = new StringBuilder();
41:                 int tupleSize = types.size();
42:
43:                 // e.g. V2J.isTup(t)
44:                 sb.append(consSubjectCheckExtraArg(V2J.class.getSimpleName(), IS_TUP_METHOD_NAME, arg, tupleSize
45:                                 + ""));
46:
47:•                for (int i = 0; i < types.size(); i++)
48:                 {
49:                         // e.g. V2J.field(t,2)
50:                         String fieldArg = consSubjectCheckExtraArg(V2J.class.getSimpleName(), GET_FIELD_METHOD_NAME, arg, i
51:                                         + "");
52:
53:                         // e.g. Utils.is_nat1(V2J.field(t,2))
54:                         String fieldCheck = types.get(i).consCheckExp(enclosingClass, javaRootPackage, fieldArg, nameGen);
55:
56:                         sb.append(JmlGenerator.JML_AND);
57:                         sb.append(fieldCheck);
58:                 }
59:
60:                 String tupleCheck = "(" + sb.toString() + ")";
61:
62:•                if (isOptional())
63:                 {
64:                         return "(" + consIsNullCheck(arg) + JmlGenerator.JML_OR + tupleCheck
65:                                         + ")";
66:                 } else
67:                 {
68:                         // e.g. (V2J.isTup(t) && Utils.is_nat1(V2J.field(t,1)) && Utils.is_bool(V2J.field(t,2)))
69:                         return tupleCheck;
70:                 }
71:
72:         }
73:
74: }