@Override public SExpIR caseANotUnaryExp(ANotUnaryExp node, IRInfo question) throws AnalysisException { return question.getExpAssistant().handleUnaryExp(node, new ANotUnaryExpIR(), question); }
/** * Creates a deep clone of this {@link ANotUnaryExpIR} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link ANotUnaryExpIR} node */ public ANotUnaryExpIR clone(Map<INode,INode> oldToNewMap) { ANotUnaryExpIR node = new ANotUnaryExpIR( _sourceNode, _tag, _metaData, cloneNode(_type, oldToNewMap), cloneNode(_exp, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Returns a deep clone of this {@link ANotUnaryExpIR} node. * @return a deep clone of this {@link ANotUnaryExpIR} node */ public ANotUnaryExpIR clone() { return new ANotUnaryExpIR( _sourceNode, _tag, _metaData, cloneNode(_type), cloneNode(_exp) ); }
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; } }
ANotUnaryExpIR negated = new ANotUnaryExpIR(); negated.setType(new ABoolBasicTypeIR()); negated.setExp(javaFormat.getJavaFormatAssistant().consInstanceOf(record, paramName));
@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; }