コード例 #1
0
 /**
  * Applies the <b>(ATTR)</b> rule to the <code>pNode</code> using the <code>pContext</code>.
  *
  * @param pContext The big step proof pContext.
  * @param pNode The node to apply the <b>(ATTR)</b> rule to.
  */
 public void applyAttr(BigStepProofContext pContext, BigStepProofNode pNode) {
   Row row = (Row) pNode.getExpression();
   Expression[] rowExpressions = row.getExpressions();
   Attribute attribute = (Attribute) rowExpressions[0];
   pContext.addProofNode(pNode, attribute.getE());
   pContext.addProofNode(pNode, row.tailRow());
 }
コード例 #2
0
 /**
  * Updates the <code>node</code> to which <b>(SEND)</b> was applied previously.
  *
  * @param pContext The big step proof context.
  * @param pNode The node to update according to <b>(SEND)</b>.
  */
 public void updateSend(BigStepProofContext pContext, BigStepProofNode pNode) {
   if ((pNode.getChildCount() == 1) && (pNode.getChildAt(0).isProven())) {
     Send send = (Send) pNode.getExpression();
     ObjectExpr objectExpr = (ObjectExpr) pNode.getChildAt(0).getResult().getValue();
     Row row = objectExpr.getRow();
     Expression newRow;
     newRow = row.substitute(objectExpr.getId(), objectExpr);
     pContext.addProofNode(pNode, new Send(newRow, send.getId()));
   } else if ((pNode.getChildCount() == 2)
       && (pNode.getChildAt(0).isProven())
       && (pNode.getChildAt(1).isProven())) {
     pContext.setProofNodeResult(pNode, pNode.getChildAt(1).getResult());
   }
 }
コード例 #3
0
 /**
  * Applies the <b>(SEND-SKIP)</b> rule to the <code>pNode</code> using the <code>pContext</code>.
  *
  * @param pContext The big step proof pContext.
  * @param pNode The node to apply the <b>(SEND-SKIP)</b> rule to.
  */
 public void applySendSkip(BigStepProofContext pContext, BigStepProofNode pNode) {
   Send send = (Send) pNode.getExpression();
   Row row = (Row) send.getE();
   if (!row.isValue()) {
     throw new IllegalArgumentException("Can not apply SEND-SKIP"); // $NON-NLS-1$
   }
   Expression[] rowExpressions = row.getExpressions();
   Identifier methodName;
   if (rowExpressions[0] instanceof Method) {
     Method method = (Method) rowExpressions[0];
     methodName = method.getId();
   } else if (rowExpressions[0] instanceof CurriedMethod) {
     CurriedMethod curriedMethod = (CurriedMethod) rowExpressions[0];
     methodName = curriedMethod.getIdentifiers()[0];
   } else {
     throw new IllegalArgumentException("Can not apply SEND-SKIP"); // $NON-NLS-1$
   }
   boolean definedLater = false;
   for (int i = 1; i < row.getExpressions().length; i++) {
     Expression rowChild = rowExpressions[i];
     if ((rowChild instanceof Method) && (((Method) rowChild).getId().equals(send.getId()))) {
       definedLater = true;
       break;
     } else if ((rowChild instanceof CurriedMethod)
         && (((CurriedMethod) rowChild).getIdentifiers()[0].equals(send.getId()))) {
       definedLater = true;
       break;
     }
   }
   if ((definedLater) || (!(send.getId().equals(methodName)))) {
     pContext.addProofNode(pNode, new Send(row.tailRow(), send.getId()));
   } else {
     throw new IllegalArgumentException("Can not apply SEND-SKIP"); // $NON-NLS-1$
   }
 }
コード例 #4
0
 /**
  * Applies the <b>(VAL)</b> rule to the <code>pNode</code> using the <code>pContext</code>.
  *
  * @param pContext The big step proof pContext.
  * @param pNode The node to apply the <b>(VAL)</b> rule to.
  */
 @Override
 public void applyValue(BigStepProofContext pContext, BigStepProofNode pNode) {
   if ((!pNode.getExpression().isValue()) || (pNode.getExpression() instanceof Row)) {
     throw new IllegalArgumentException("Can not apply VAL"); // $NON-NLS-1$
   }
   pContext.setProofNodeResult(pNode, pNode.getExpression());
 }
コード例 #5
0
 /**
  * Applies the <b>(SEND)</b> rule to the <code>pNode</code> using the <code>pContext</code>.
  *
  * @param pContext The big step proof pContext.
  * @param pNode The node to apply the <b>(SEND)</b> rule to.
  */
 public void applySend(BigStepProofContext pContext, BigStepProofNode pNode) {
   Send send = (Send) pNode.getExpression();
   if (send.getE() instanceof Row) {
     throw new IllegalArgumentException("Can not apply SEND"); // $NON-NLS-1$
   }
   pContext.addProofNode(pNode, send.getE());
 }
コード例 #6
0
 /**
  * Applies the <b>(OMEGA)</b> rule to the <code>pNode</code> using the <code>pContext</code>.
  *
  * @param pContext The big step proof pContext.
  * @param pNode The node to apply the <b>(OMEGA)</b> rule to.
  */
 public void applyOmega(BigStepProofContext pContext, BigStepProofNode pNode) {
   Row row = (Row) pNode.getExpression();
   if (!row.isValue()) {
     throw new IllegalArgumentException("Can not apply OMEGA"); // $NON-NLS-1$
   }
   pContext.setProofNodeResult(pNode, row);
 }
コード例 #7
0
 /**
  * Updates the <code>node</code> to which <b>(OBJECT)</b> was applied previously.
  *
  * @param pContext The big step proof context.
  * @param pNode The node to update according to <b>(OBJECT)</b>.
  */
 public void updateObject(BigStepProofContext pContext, BigStepProofNode pNode) {
   if ((pNode.getChildCount() == 1) && (pNode.getChildAt(0).isProven())) {
     ObjectExpr oldObjectExpr = (ObjectExpr) pNode.getExpression();
     Row row = (Row) pNode.getChildAt(0).getResult().getValue();
     pContext.setProofNodeResult(
         pNode, new ObjectExpr(oldObjectExpr.getId(), oldObjectExpr.getTau(), row));
   }
 }
コード例 #8
0
 /**
  * Applies the <b>(OBJECT)</b> rule to the <code>pNode</code> using the <code>pContext</code>.
  *
  * @param pContext The big step proof pContext.
  * @param pNode The node to apply the <b>(OBJECT)</b> rule to.
  */
 public void applyObject(BigStepProofContext pContext, BigStepProofNode pNode) {
   ObjectExpr objectExpr = (ObjectExpr) pNode.getExpression();
   Row row = objectExpr.getRow();
   if (row.isValue()) {
     throw new IllegalArgumentException("Can not apply OBJECT"); // $NON-NLS-1$
   }
   pContext.addProofNode(pNode, row);
 }
コード例 #9
0
 /**
  * Applies the <b>(METHOD)</b> rule to the <code>pNode</code> using the <code>pContext</code>.
  *
  * @param pContext The big step proof pContext.
  * @param pNode The node to apply the <b>(METHOD)</b> rule to.
  */
 public void applyMethod(BigStepProofContext pContext, BigStepProofNode pNode) {
   Row row = (Row) pNode.getExpression();
   Expression[] rowExpressions = row.getExpressions();
   if ((!(rowExpressions[0] instanceof Method))
       && (!(rowExpressions[0] instanceof CurriedMethod))) {
     throw new IllegalArgumentException("Can not apply METHOD"); // $NON-NLS-1$
   }
   pContext.addProofNode(pNode, row.tailRow());
 }
コード例 #10
0
 /**
  * Updates the <code>node</code> to which <b>(METHOD)</b> was applied previously.
  *
  * @param pContext The big step proof context.
  * @param pNode The node to update according to <b>(METHOD)</b>.
  */
 public void updateMethod(BigStepProofContext pContext, BigStepProofNode pNode) {
   if ((pNode.getChildCount() == 1) && (pNode.getChildAt(0).isProven())) {
     Row row = (Row) pNode.getExpression();
     Row childRow = (Row) pNode.getChildAt(0).getResult().getValue();
     Expression[] newRowExpressions = new Expression[row.getExpressions().length];
     newRowExpressions[0] = row.getExpressions()[0];
     for (int i = 1; i < newRowExpressions.length; i++) {
       newRowExpressions[i] = childRow.getExpressions()[i - 1];
     }
     pContext.setProofNodeResult(pNode, new Row(newRowExpressions));
   }
 }
コード例 #11
0
 /**
  * Applies the <b>(SEND-ATTR)</b> rule to the <code>pNode</code> using the <code>pContext</code>.
  *
  * @param pContext The big step proof pContext.
  * @param pNode The node to apply the <b>(SEND-ATTR)</b> rule to.
  */
 public void applySendAttr(BigStepProofContext pContext, BigStepProofNode pNode) {
   Send send = (Send) pNode.getExpression();
   Row row = (Row) send.getE();
   if (!row.isValue()) {
     throw new IllegalArgumentException("Can not apply SEND-ATTR"); // $NON-NLS-1$
   }
   Expression[] rowExpressions = row.getExpressions();
   Attribute attribute = (Attribute) rowExpressions[0];
   Expression[] newRowExpressions = new Expression[row.getExpressions().length - 1];
   for (int i = 0; i < newRowExpressions.length; i++) {
     newRowExpressions[i] = rowExpressions[i + 1].substitute(attribute.getId(), attribute.getE());
   }
   pContext.addProofNode(pNode, new Send(new Row(newRowExpressions), send.getId()));
 }
コード例 #12
0
 /**
  * Updates the <code>node</code> to which <b>(ATTR)</b> was applied previously.
  *
  * @param pContext The big step proof context.
  * @param pNode The node to update according to <b>(ATTR)</b>.
  */
 public void updateAttr(BigStepProofContext pContext, BigStepProofNode pNode) {
   if ((pNode.getChildCount() == 2)
       && (pNode.getChildAt(0).isProven())
       && (pNode.getChildAt(1).isProven())) {
     Row row = (Row) pNode.getExpression();
     Expression childExpression = pNode.getChildAt(0).getResult().getValue();
     Row childRow = (Row) pNode.getChildAt(1).getResult().getValue();
     Attribute attribute = (Attribute) row.getExpressions()[0];
     Expression[] newRowExpressions = new Expression[row.getExpressions().length];
     Attribute newAttribute = new Attribute(attribute.getId(), childExpression);
     newRowExpressions[0] = newAttribute;
     for (int i = 1; i < newRowExpressions.length; i++) {
       newRowExpressions[i] = childRow.getExpressions()[i - 1];
     }
     pContext.setProofNodeResult(pNode, new Row(newRowExpressions));
   }
 }
コード例 #13
0
 /**
  * Applies the <b>(SEND-EXEC)</b> rule to the <code>pNode</code> using the <code>pContext</code>.
  *
  * @param pContext The big step proof pContext.
  * @param pNode The node to apply the <b>(SEND-EXEC)</b> rule to.
  */
 public void applySendExec(BigStepProofContext pContext, BigStepProofNode pNode) {
   Send send = (Send) pNode.getExpression();
   Row row = (Row) send.getE();
   if (!row.isValue()) {
     throw new IllegalArgumentException("Can not apply SEND-EXEC"); // $NON-NLS-1$
   }
   Expression[] rowExpressions = row.getExpressions();
   Identifier methodName;
   Expression methodExpression;
   if (rowExpressions[0] instanceof Method) {
     Method method = (Method) rowExpressions[0];
     methodExpression = method.getE();
     methodName = method.getId();
   } else if (rowExpressions[0] instanceof CurriedMethod) {
     CurriedMethod curriedMethod = (CurriedMethod) rowExpressions[0];
     methodExpression = curriedMethod.getE();
     Identifier[] identifiers = curriedMethod.getIdentifiers();
     MonoType[] types = curriedMethod.getTypes();
     for (int i = identifiers.length - 1; i > 0; i--) {
       methodExpression = new Lambda(identifiers[i], types[i], methodExpression);
     }
     methodName = identifiers[0];
   } else {
     throw new IllegalArgumentException("Can not apply SEND-EXEC"); // $NON-NLS-1$
   }
   if (!(send.getId().equals(methodName))) {
     throw new IllegalArgumentException("Can not apply SEND-EXEC"); // $NON-NLS-1$
   }
   boolean definedLater = false;
   for (int i = 1; i < row.getExpressions().length; i++) {
     Expression rowChild = rowExpressions[i];
     if ((rowChild instanceof Method) && (((Method) rowChild).getId().equals(send.getId()))) {
       definedLater = true;
       break;
     } else if ((rowChild instanceof CurriedMethod)
         && (((CurriedMethod) rowChild).getIdentifiers()[0].equals(send.getId()))) {
       definedLater = true;
       break;
     }
   }
   if (!definedLater) {
     pContext.addProofNode(pNode, methodExpression);
   } else {
     throw new IllegalArgumentException("Can not apply SEND-EXEC"); // $NON-NLS-1$
   }
 }
コード例 #14
0
 /**
  * Updates the <code>node</code> to which <b>(SEND-SKIP)</b> was applied previously.
  *
  * @param pContext The big step proof context.
  * @param pNode The node to update according to <b>(SEND-SKIP)</b>.
  */
 public void updateSendSkip(BigStepProofContext pContext, BigStepProofNode pNode) {
   if (pNode.getChildAt(0).isProven()) {
     pContext.setProofNodeResult(pNode, pNode.getChildAt(0).getResult());
   }
 }