| 1092 | } |
| 1093 | |
| 1094 | public final static class Row { |
| 1095 | /** |
| 1096 | * Default comparator for typing rows. |
| 1097 | */ |
| 1098 | public static Comparator<Row> COMPARATOR(Subtyping.Environment env) { |
| 1099 | return new Comparator<Row>() { |
| 1100 | |
| 1101 | @Override |
| 1102 | public int compare(Row o1, Row o2) { |
| 1103 | Type[] o1_types = o1.types; |
| 1104 | Type[] o2_types = o2.types; |
| 1105 | if(o1_types.length < o2_types.length) { |
| 1106 | return -1; |
| 1107 | } else if(o1_types.length > o2_types.length) { |
| 1108 | return 1; |
| 1109 | } |
| 1110 | // |
| 1111 | for(int i=0;i!=o1_types.length;++i) { |
| 1112 | Type t1 = o1_types[i]; |
| 1113 | Type t2 = o2_types[i]; |
| 1114 | boolean left = env.isSatisfiableSubtype(t1, t2); |
| 1115 | boolean right = env.isSatisfiableSubtype(t2, t1); |
| 1116 | // |
| 1117 | if(left && !right) { |
| 1118 | return -1; |
| 1119 | } else if(!left && right) { |
| 1120 | return 1; |
| 1121 | } |
| 1122 | } |
| 1123 | return 0; |
| 1124 | } |
| 1125 | }; |
| 1126 | } |
| 1127 | |
| 1128 | private Subtyping.Constraints constraints; |
| 1129 | private Type[] types; |
| 1130 | |
| 1131 | public Row(Subtyping.Constraints constraints, Type... types) { |
| 1132 | this.constraints = constraints; |
| 1133 | this.types = types; |
| 1134 | } |
| 1135 | |
| 1136 | public Type get(int index) { |
| 1137 | return types[index]; |
| 1138 | } |
| 1139 | |
| 1140 | public Type[] getAll(int... indices) { |
| 1141 | Type[] ts = new Type[indices.length]; |
| 1142 | for (int i = 0; i != indices.length; ++i) { |
| 1143 | ts[i] = types[indices[i]]; |
| 1144 | } |
| 1145 | return ts; |
| 1146 | } |
| 1147 | |
| 1148 | public int size() { |
| 1149 | return types.length; |
| 1150 | } |
| 1151 |
nothing calls this directly
no outgoing calls
no test coverage detected