public ANotUnaryExpIR negate(SExpIR exp) { ANotUnaryExpIR negated = new ANotUnaryExpIR(); negated.setType(exp.getType().clone()); negated.setExp(exp); return negated; }
public SExpIR consBoolCheck(String boolVarName, boolean negate) { AIdentifierVarExpIR boolVarExp = new AIdentifierVarExpIR(); boolVarExp.setType(new ABoolBasicTypeIR()); boolVarExp.setIsLocal(true); boolVarExp.setName(boolVarName); if (negate) { ANotUnaryExpIR negated = new ANotUnaryExpIR(); negated.setType(new ABoolBasicTypeIR()); negated.setExp(boolVarExp); return negated; } else { return boolVarExp; } }
negated.setType(new ABoolBasicTypeIR()); negated.setExp(javaFormat.getJavaFormatAssistant().consInstanceOf(record, paramName)); ifStm.setIfExp(negated);
@Override public SExpIR caseAImpliesBooleanBinaryExp(AImpliesBooleanBinaryExp node, IRInfo question) throws AnalysisException { // A => B is constructed as !A || B STypeIR typeCg = node.getType().apply(question.getTypeVisitor(), question); SExpIR leftExpCg = node.getLeft().apply(question.getExpVisitor(), question); SExpIR rightExpCg = node.getRight().apply(question.getExpVisitor(), question); ANotUnaryExpIR notExp = new ANotUnaryExpIR(); notExp.setType(typeCg); notExp.setExp(leftExpCg); AOrBoolBinaryExpIR orExp = new AOrBoolBinaryExpIR(); orExp.setType(typeCg); orExp.setLeft(notExp); orExp.setRight(rightExpCg); return orExp; }
private ANotUnaryExpIR transNotEquals(ANotEqualsBinaryExpIR notEqual) { ANotUnaryExpIR notUnary = new ANotUnaryExpIR(); notUnary.setType(new ABoolBasicTypeIR()); AEqualsBinaryExpIR equal = new AEqualsBinaryExpIR(); equal.setType(new ABoolBasicTypeIR()); equal.setLeft(notEqual.getLeft().clone()); equal.setRight(notEqual.getRight().clone()); notUnary.setExp(equal); // Replace the "notEqual" expression with the transformed expression INode parent = notEqual.parent(); // It may be the case that the parent is null if we execute e.g. [1] <> [1] in isolation if (parent != null) { parent.replaceChild(notEqual, notUnary); notEqual.parent(null); } return notUnary; }
@Override public SExpIR caseAEquivalentBooleanBinaryExp( AEquivalentBooleanBinaryExp node, IRInfo question) throws AnalysisException { // A <=> B is constructed as !(A ^ B) STypeIR typeCg = node.getType().apply(question.getTypeVisitor(), question); SExpIR leftExpCg = node.getLeft().apply(question.getExpVisitor(), question); SExpIR rightExpCg = node.getRight().apply(question.getExpVisitor(), question); AXorBoolBinaryExpIR xorExp = new AXorBoolBinaryExpIR(); xorExp.setType(typeCg); xorExp.setLeft(leftExpCg); xorExp.setRight(rightExpCg); ANotUnaryExpIR notExp = new ANotUnaryExpIR(); notExp.setType(typeCg.clone()); notExp.setExp(question.getExpAssistant().isolateExpression(xorExp)); return notExp; }