/** * Applies the <b>(OBJECT-WIDTH)</b> rule to the <code>node</code> using the <code>context</code>. * * @param context the minimal typing proof context. * @param pNode the minimal typing proof node. */ public void applyObjectWidth( @SuppressWarnings("unused") MinimalTypingProofContext context, MinimalTypingProofNode pNode) { MinimalTypingTypesProofNode node = (MinimalTypingTypesProofNode) pNode; boolean goOn; ObjectType type = (ObjectType) node.getType(); ObjectType type2 = (ObjectType) node.getType2(); RowType r1 = (RowType) (type).getPhi(); RowType r2 = (RowType) (type2).getPhi(); Identifier[] ids1 = r1.getIdentifiers(); Identifier[] ids2 = r2.getIdentifiers(); MonoType[] types = r1.getTypes(); MonoType[] types2 = r2.getTypes(); for (int i = 0; i < ids2.length; i++) { goOn = false; for (int j = 0; j < ids1.length; j++) { if (ids2[i].equals(ids1[j])) { if (!(types2[i].equals(types[j]))) { throw new RuntimeException(Messages.getString("SubTypingException.5")); // $NON-NLS-1$ } goOn = true; break; } } if (!goOn) { throw new RuntimeException(Messages.getString("SubTypingException.5")); // $NON-NLS-1$ } node.getSeenTypes().add(new DefaultSubType(node.getType(), node.getType2())); } }
/** * Applies the <b>(OBJECT-DEPTH)</b> rule to the <code>node</code> using the <code>context</code>. * * @param context the minimal typing proof context. * @param pNode the minimal typing proof node. */ public void applyObjectDepth(MinimalTypingProofContext context, MinimalTypingProofNode pNode) { MinimalTypingTypesProofNode node = (MinimalTypingTypesProofNode) pNode; ObjectType type = (ObjectType) node.getType(); ObjectType type2 = (ObjectType) node.getType2(); RowType r1 = (RowType) (type).getPhi(); RowType r2 = (RowType) (type2).getPhi(); // boolean goOn; Identifier[] ids1 = r1.getIdentifiers(); Identifier[] ids2 = r2.getIdentifiers(); MonoType[] types = r1.getTypes(); MonoType[] types2 = r2.getTypes(); int index = r2.getIndexOfIdentifier(ids1[0]); if (ids1.length == ids2.length && index > -1) { /* * for ( int i = 0; i < ids1.length; i++ ) { goOn = false; for ( int j = * 0; j < ids2.length; j++ ) { if ( ids1[i].equals ( ids2[j] ) ) { // * generate new child node context.addProofNode ( node, types[i], * types2[j] ); goOn = true; } } if ( goOn ) continue; break; } */ context.addProofNode(node, types[0], types2[index]); } else throw new RuntimeException(Messages.getString("SubTypingException.5")); // $NON-NLS-1$ node.getSeenTypes().add(new DefaultSubType(node.getType(), node.getType2())); }